mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
nip29: handle 9007 create_group.
This commit is contained in:
parent
8aaf5b8f98
commit
f9fd760808
1
event.go
1
event.go
@ -49,6 +49,7 @@ const (
|
||||
KindSimpleGroupRemovePermission int = 9004
|
||||
KindSimpleGroupDeleteEvent int = 9005
|
||||
KindSimpleGroupEditGroupStatus int = 9006
|
||||
KindSimpleGroupCreateGroup int = 9007
|
||||
KindSimpleGroupJoinRequest int = 9021
|
||||
KindZapRequest int = 9734
|
||||
KindZap int = 9735
|
||||
|
@ -33,6 +33,7 @@ var ModerationEventKinds = KindRange{
|
||||
nostr.KindSimpleGroupRemovePermission,
|
||||
nostr.KindSimpleGroupDeleteEvent,
|
||||
nostr.KindSimpleGroupEditGroupStatus,
|
||||
nostr.KindSimpleGroupCreateGroup,
|
||||
}
|
||||
|
||||
var MetadataEventKinds = KindRange{
|
||||
|
@ -159,6 +159,9 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
|
||||
|
||||
return egs, nil
|
||||
},
|
||||
nostr.KindSimpleGroupCreateGroup: func(evt *nostr.Event) (Action, error) {
|
||||
return &CreateGroup{evt.PubKey}, nil
|
||||
},
|
||||
}
|
||||
|
||||
type DeleteEvent struct {
|
||||
@ -297,3 +300,22 @@ func (a EditGroupStatus) Apply(group *nip29.Group) {
|
||||
|
||||
group.LastMetadataUpdate = a.When
|
||||
}
|
||||
|
||||
type CreateGroup struct {
|
||||
Creator string
|
||||
}
|
||||
|
||||
func (CreateGroup) PermissionName() nip29.Permission { return nip29.PermEditGroupStatus }
|
||||
func (a CreateGroup) Apply(group *nip29.Group) {
|
||||
group.Members[a.Creator] = &nip29.Role{
|
||||
Permissions: map[nip29.Permission]struct{}{
|
||||
nip29.PermAddUser: {},
|
||||
nip29.PermRemoveUser: {},
|
||||
nip29.PermEditMetadata: {},
|
||||
nip29.PermAddPermission: {},
|
||||
nip29.PermRemovePermission: {},
|
||||
nip29.PermDeleteEvent: {},
|
||||
nip29.PermEditGroupStatus: {},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user