forked from coracle/zooid
Accept claims if user is already a member
This commit is contained in:
+2
-2
@@ -31,8 +31,8 @@ type Config struct {
|
|||||||
} `toml:"policy"`
|
} `toml:"policy"`
|
||||||
|
|
||||||
Groups struct {
|
Groups struct {
|
||||||
Enabled bool `toml:"enabled"`
|
Enabled bool `toml:"enabled"`
|
||||||
AutoJoin bool `toml:"auto_join"`
|
AutoJoin bool `toml:"auto_join"`
|
||||||
} `toml:"groups"`
|
} `toml:"groups"`
|
||||||
|
|
||||||
Management struct {
|
Management struct {
|
||||||
|
|||||||
+13
-13
@@ -283,9 +283,9 @@ func (g *GroupStore) CheckWrite(event nostr.Event) string {
|
|||||||
meta, found := g.GetMetadata(h)
|
meta, found := g.GetMetadata(h)
|
||||||
|
|
||||||
if event.Kind == nostr.KindSimpleGroupCreateGroup {
|
if event.Kind == nostr.KindSimpleGroupCreateGroup {
|
||||||
if found {
|
if found {
|
||||||
return "invalid: that group already exists"
|
return "invalid: that group already exists"
|
||||||
}
|
}
|
||||||
} else if !found {
|
} else if !found {
|
||||||
return "invalid: group not found"
|
return "invalid: group not found"
|
||||||
}
|
}
|
||||||
@@ -299,19 +299,19 @@ func (g *GroupStore) CheckWrite(event nostr.Event) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if event.Kind == nostr.KindSimpleGroupJoinRequest {
|
if event.Kind == nostr.KindSimpleGroupJoinRequest {
|
||||||
if g.IsMember(h, event.PubKey) {
|
if g.IsMember(h, event.PubKey) {
|
||||||
return "duplicate: already a member"
|
return "duplicate: already a member"
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.Kind == nostr.KindSimpleGroupLeaveRequest {
|
if event.Kind == nostr.KindSimpleGroupLeaveRequest {
|
||||||
if !g.IsMember(h, event.PubKey) {
|
if !g.IsMember(h, event.PubKey) {
|
||||||
return "duplicate: not currently a member"
|
return "duplicate: not currently a member"
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if HasTag(meta.Tags, "closed") && !g.HasAccess(h, event.PubKey) {
|
if HasTag(meta.Tags, "closed") && !g.HasAccess(h, event.PubKey) {
|
||||||
|
|||||||
@@ -298,6 +298,10 @@ func (m *ManagementStore) AllowPubkey(pubkey nostr.PubKey) error {
|
|||||||
// Joining
|
// Joining
|
||||||
|
|
||||||
func (m *ManagementStore) ValidateJoinRequest(event nostr.Event) (reject bool, err string) {
|
func (m *ManagementStore) ValidateJoinRequest(event nostr.Event) (reject bool, err string) {
|
||||||
|
if m.IsMember(event.PubKey) {
|
||||||
|
return false, ""
|
||||||
|
}
|
||||||
|
|
||||||
if m.PubkeyIsBanned(event.PubKey) {
|
if m.PubkeyIsBanned(event.PubKey) {
|
||||||
return true, "invalid: you have been banned from this relay"
|
return true, "invalid: you have been banned from this relay"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user