fix: expose token permission from events

Ensure token permission from events is returned by `tokenPermissions`.
This commit is contained in:
Patryk Osmaczko 2023-08-23 16:23:53 +02:00 committed by osmaczko
parent 2131bd3881
commit 8764170149
1 changed files with 5 additions and 6 deletions

View File

@ -1336,14 +1336,13 @@ func (o *Community) tokenPermissions() map[string]*CommunityTokenPermission {
switch event.Type { switch event.Type {
case protobuf.CommunityEvent_COMMUNITY_MEMBER_TOKEN_PERMISSION_CHANGE: case protobuf.CommunityEvent_COMMUNITY_MEMBER_TOKEN_PERMISSION_CHANGE:
tokenPermission := result[event.TokenPermission.Id] eventsTokenPermission := NewCommunityTokenPermission(event.TokenPermission)
if tokenPermission != nil { if result[event.TokenPermission.Id] != nil {
tokenPermission.State = TokenPermissionUpdatePending eventsTokenPermission.State = TokenPermissionUpdatePending
} else { } else {
tokenPermission := NewCommunityTokenPermission(event.TokenPermission) eventsTokenPermission.State = TokenPermissionAdditionPending
tokenPermission.State = TokenPermissionAdditionPending
result[event.TokenPermission.Id] = tokenPermission
} }
result[eventsTokenPermission.Id] = eventsTokenPermission
case protobuf.CommunityEvent_COMMUNITY_MEMBER_TOKEN_PERMISSION_DELETE: case protobuf.CommunityEvent_COMMUNITY_MEMBER_TOKEN_PERMISSION_DELETE:
tokenPermission := result[event.TokenPermission.Id] tokenPermission := result[event.TokenPermission.Id]