Skip to content

Commit

Permalink
feat(admin): enable admins to delete messages from other users
Browse files Browse the repository at this point in the history
Fixes #8869
  • Loading branch information
jrainville committed Jan 4, 2023
1 parent fe87cba commit 29450d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ui/app/AppLayouts/Chat/views/ChatMessagesView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Item {
return
}

if (chatDetails.active && chatDetails.hasUnreadMessages && !messageStore.messageSearchOngoing) {
if (chatDetails && chatDetails.active && chatDetails.hasUnreadMessages && !messageStore.messageSearchOngoing) {
chatContentModule.markAllMessagesRead()
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/imports/shared/views/chat/MessageContextMenuView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ StatusMenu {

StatusAction {
id: deleteMessageAction
enabled: root.isMyMessage &&
enabled: (root.isMyMessage || root.amIChatAdmin) &&
!root.isProfile &&
!root.isEmoji &&
!root.pinnedPopup &&
Expand Down
13 changes: 6 additions & 7 deletions ui/imports/shared/views/chat/MessageView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Loader {
property bool senderIsEnsVerified: false
property string senderIcon: ""
property bool amISender: false
property bool amIChatAdmin: messageStore && messageStore.amIChatAdmin()
property bool senderIsAdded: false
property int senderTrustStatus: Constants.trustStatus.unknown
property string messageText: ""
Expand Down Expand Up @@ -133,7 +134,7 @@ Loader {
}

messageContextMenu.myPublicKey = userProfile.pubKey
messageContextMenu.amIChatAdmin = messageStore.amIChatAdmin()
messageContextMenu.amIChatAdmin = root.amIChatAdmin
messageContextMenu.pinMessageAllowedForMembers = messageStore.pinMessageAllowedForMembers()
messageContextMenu.chatType = messageStore.getChatType()

Expand Down Expand Up @@ -333,7 +334,7 @@ Loader {
chatType: root.messageStore.getChatType()
chatColor: root.messageStore.getChatColor()
chatEmoji: root.channelEmoji
amIChatAdmin: root.messageStore.amIChatAdmin()
amIChatAdmin: root.amIChatAdmin
chatIcon: {
if ((root.messageStore.getChatType() === Constants.chatType.privateGroupChat) &&
root.messageStore.getChatIcon() !== "") {
Expand Down Expand Up @@ -838,12 +839,11 @@ Loader {
return false

const chatType = root.messageStore.getChatType();
const amIChatAdmin = root.messageStore.amIChatAdmin();
const pinMessageAllowedForMembers = root.messageStore.pinMessageAllowedForMembers()

return chatType === Constants.chatType.oneToOne ||
chatType === Constants.chatType.privateGroupChat && amIChatAdmin ||
chatType === Constants.chatType.communityChat && (amIChatAdmin || pinMessageAllowedForMembers);
chatType === Constants.chatType.privateGroupChat && root.amIChatAdmin ||
chatType === Constants.chatType.communityChat && (root.amIChatAdmin || pinMessageAllowedForMembers);

}
sourceComponent: StatusFlatRoundButton {
Expand Down Expand Up @@ -884,9 +884,8 @@ Loader {
return false;
if (!root.messageStore)
return false;
const isMyMessage = senderId !== "" && senderId === userProfile.pubKey;
const chatType = root.messageStore.getChatType();
return isMyMessage &&
return (root.amISender || root.amIChatAdmin) &&
(messageContentType === Constants.messageContentType.messageType ||
messageContentType === Constants.messageContentType.stickerType ||
messageContentType === Constants.messageContentType.emojiType ||
Expand Down

0 comments on commit 29450d3

Please sign in to comment.