fix(communities): Correct handling 'hide channel from certain members' (#14977)

Close #14915
This commit is contained in:
Mikhail Rogachev 2024-05-31 12:28:09 +02:00 committed by GitHub
parent 2830f01932
commit f62b6eb348
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 7 deletions

View File

@ -700,12 +700,19 @@ proc getChatItemFromChatDto(
var viewersCanPostReactions = true
if self.controller.isCommunity:
let communityChat = community.getCommunityChat(chatDto.id)
# Some properties are only available on CommunityChat (they are useless for normal chats)
canPost = communityChat.canPost
canView = communityChat.canView
canPostReactions = communityChat.canPostReactions
hideIfPermissionsNotMet = communityChat.hideIfPermissionsNotMet
viewersCanPostReactions = communityChat.viewersCanPostReactions
# NOTE: workaround for new community chat, which is delivered in chatDto before the community will know about that
if community.hasCommunityChat(chatDto.id):
let communityChat = community.getCommunityChat(chatDto.id)
# Some properties are only available on CommunityChat (they are useless for normal chats)
canPost = communityChat.canPost
canView = communityChat.canView
canPostReactions = communityChat.canPostReactions
hideIfPermissionsNotMet = communityChat.hideIfPermissionsNotMet
viewersCanPostReactions = communityChat.viewersCanPostReactions
else:
canPostReactions = chatDto.canPostReactions
hideIfPermissionsNotMet = chatDto.hideIfPermissionsNotMet
viewersCanPostReactions = chatDto.viewersCanPostReactions
result = chat_item.initItem(
chatDto.id,

View File

@ -612,6 +612,12 @@ proc getCommunityChat*(self: CommunityDto, chatId: string): ChatDto =
if chats.len > 0:
return chats[0]
proc hasCommunityChat*(self: CommunityDto, chatId: string): bool =
for communityChat in self.chats:
if chatId == communityChat.id:
return true
return false
proc isOwner*(self: CommunityDto): bool =
return self.memberRole == MemberRole.Owner

View File

@ -1312,6 +1312,7 @@ QtObject:
self.communities[communityId].chats.add(chatDto)
let data = CommunityChatArgs(chat: chatDto)
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_CREATED, data)
except Exception as e:
error "Error creating community channel", msg = e.msg, communityId, name, description, procName="createCommunityChannel"

View File

@ -553,7 +553,7 @@ Item {
property var deleteChatConfirmationDialog
onCreateCommunityChannel: function (chName, chDescription, chEmoji, chColor,
chCategoryId, hideIfPermissionsNotMet) {
chCategoryId, viewOnlyCanAddReaction, hideIfPermissionsNotMet) {
root.store.createCommunityChannel(chName, chDescription, chEmoji, chColor,
chCategoryId, viewOnlyCanAddReaction, hideIfPermissionsNotMet)
chatId = root.store.currentChatContentModule().chatDetails.id