fix(@desktop/chat): Push notification body contains only chat key when user is mentioned

fixes #3347
This commit is contained in:
Khushboo Mehta 2021-09-16 17:37:15 +02:00 committed by Iuri Matias
parent 53d1cf3afd
commit 2515f12c3b
1 changed files with 15 additions and 2 deletions

View File

@ -9,7 +9,7 @@ import ../../../app_service/[main]
import ../../../app_service/tasks/[qt, threadpool]
import ../../../app_service/tasks/marathon/mailserver/worker
import communities, chat_item, channels_list, communities, community_list, user_list, community_members_list, message_list, channel, message_item
import communities, chat_item, channels_list, communities, community_list, user_list, community_members_list, message_list, channel, message_item, message_format
logScope:
topics = "messages-view"
@ -113,6 +113,19 @@ QtObject:
return updatedMessage
proc replacePubKeysWithMentions(self: MessageView, message: string): string =
let pubKeyPattern = re(r"(@0[xX][0-9a-fA-F]+)", flags = {reStudy, reIgnoreCase})
let pubKeyMentions = findAll(message, pubKeyPattern)
var updatedMessage = message
for mention in pubKeyMentions:
let pubKey = mention.replace("@","")
let userNameAlias = mention(pubKey, self.status.chat.contacts)
if userNameAlias != "":
updatedMessage = updatedMessage.replace(mention, '@' & userNameAlias)
return updatedMessage
proc hideMessage(self: MessageView, mId: string) {.signal.}
proc sendOrEditMessage*(self: MessageView, message: string, replyTo: string, contentType: int = ContentType.Message.int, isStatusUpdate: bool = false, isEdit: bool = false, messageId: string = "") {.slot.} =
@ -233,7 +246,7 @@ QtObject:
let isEdit = msg.editedAt != "0" or msg.contentType == ContentType.Edit
if not channel.muted and not isEdit and not isGroupSelf and not isMyInvite:
let isAddedContact = channel.chatType.isOneToOne and self.isAddedContact(channel.id)
self.messageNotificationPushed(msg.id, channel.communityId, msg.chatId, escape_html(msg.text), msg.contentType.int, channel.chatType.int, msg.timestamp, msg.identicon, msg.userName, msg.hasMention, isAddedContact, channel.name)
self.messageNotificationPushed(msg.id, channel.communityId, msg.chatId, self.replacePubKeysWithMentions(msg.text), msg.contentType.int, channel.chatType.int, msg.timestamp, msg.identicon, msg.userName, msg.hasMention, isAddedContact, channel.name)
self.channelOpenTime[msg.chatId] = now().toTime.toUnix * 1000