fix: consider TM when evaluating permissions to join

seems like this check had gone missing
This commit is contained in:
Lukáš Tinkl 2024-03-27 13:46:18 +01:00 committed by Lukáš Tinkl
parent 5af2f28aa2
commit 255f318627
2 changed files with 11 additions and 14 deletions

View File

@ -367,7 +367,7 @@ proc createItemFromPublicKey(self: Module, publicKey: string): UserItem =
proc initContactRequestsModel(self: Module) = proc initContactRequestsModel(self: Module) =
var contactsWhoAddedMe: seq[UserItem] var contactsWhoAddedMe: seq[UserItem]
let contacts = self.controller.getContacts(ContactsGroup.IncomingPendingContactRequests) let contacts = self.controller.getContacts(ContactsGroup.IncomingPendingContactRequests)
for c in contacts: for c in contacts:
let item = self.createItemFromPublicKey(c.id) let item = self.createItemFromPublicKey(c.id)
contactsWhoAddedMe.add(item) contactsWhoAddedMe.add(item)
@ -378,7 +378,7 @@ proc rebuildCommunityTokenPermissionsModel(self: Module) =
let community = self.controller.getMyCommunity() let community = self.controller.getMyCommunity()
var tokenPermissionsItems: seq[TokenPermissionItem] = @[] var tokenPermissionsItems: seq[TokenPermissionItem] = @[]
for id, tokenPermission in community.tokenPermissions: for _, tokenPermission in community.tokenPermissions:
let chats = community.getCommunityChats(tokenPermission.chatIds) let chats = community.getCommunityChats(tokenPermission.chatIds)
let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats) let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats)
tokenPermissionsItems.add(tokenPermissionItem) tokenPermissionsItems.add(tokenPermissionItem)
@ -388,12 +388,12 @@ proc rebuildCommunityTokenPermissionsModel(self: Module) =
proc reevaluateRequiresTokenPermissionToJoin(self: Module) = proc reevaluateRequiresTokenPermissionToJoin(self: Module) =
let community = self.controller.getMyCommunity() let community = self.controller.getMyCommunity()
var hasBecomeMemberOrBecomeAdminPermissions = false var joinPermissionsChanged = false
for id, tokenPermission in community.tokenPermissions: for _, tokenPermission in community.tokenPermissions:
if tokenPermission.`type` == TokenPermissionType.BecomeMember or tokenPermission.`type` == TokenPermissionType.BecomeAdmin: if tokenPermission.`type` == TokenPermissionType.BecomeMember or tokenPermission.`type` == TokenPermissionType.BecomeAdmin or tokenPermission.`type` == TokenPermissionType.BecomeTokenMaster:
hasBecomeMemberOrBecomeAdminPermissions = true joinPermissionsChanged = true
break
self.view.setRequiresTokenPermissionToJoin(hasBecomeMemberOrBecomeAdminPermissions) self.view.setRequiresTokenPermissionToJoin(joinPermissionsChanged)
proc initCommunityTokenPermissionsModel(self: Module, channelGroup: ChannelGroupDto) = proc initCommunityTokenPermissionsModel(self: Module, channelGroup: ChannelGroupDto) =
self.rebuildCommunityTokenPermissionsModel() self.rebuildCommunityTokenPermissionsModel()

View File

@ -42,11 +42,8 @@ proc initTokenPermissionItem*(
result.tokenCriteriaMet = tokenCriteriaMet result.tokenCriteriaMet = tokenCriteriaMet
result.state = state result.state = state
for tcItem in tokenCriteria: result.tokenCriteria.setItems(tokenCriteria)
result.tokenCriteria.addItem(tcItem) result.chatList.setItems(chatList)
for clItem in chatList:
result.chatList.addItem(clItem)
proc addTokenCriteria*(self: TokenPermissionItem, tokenCriteria: TokenCriteriaItem) = proc addTokenCriteria*(self: TokenPermissionItem, tokenCriteria: TokenCriteriaItem) =
self.tokenCriteria.addItem(tokenCriteria) self.tokenCriteria.addItem(tokenCriteria)