fix(@desktop/notifications): sent contact request accepted notification fix
This commit is contained in:
parent
e38d8c8490
commit
27b8924c6d
|
@ -83,6 +83,8 @@ QtObject:
|
|||
self, "onMyRequestToJoinCommunityRejected(QString, QString, QString)", 2)
|
||||
signalConnect(singletonInstance.globalEvents, "meMentionedIconBadgeNotification(int)",
|
||||
self, "onMeMentionedIconBadgeNotification(int)", 2)
|
||||
signalConnect(singletonInstance.globalEvents, "showAcceptedContactRequest(QString, QString, QString)",
|
||||
self, "onShowAcceptedContactRequest(QString, QString, QString)", 2)
|
||||
|
||||
self.notificationSetUp = true
|
||||
|
||||
|
@ -143,6 +145,11 @@ QtObject:
|
|||
let details = NotificationDetails(notificationType: NotificationType.NewContactRequest, sectionId: sectionId)
|
||||
self.processNotification(title, message, details)
|
||||
|
||||
proc onShowAcceptedContactRequest*(self: NotificationsManager, title: string, message: string,
|
||||
sectionId: string) {.slot.} =
|
||||
let details = NotificationDetails(notificationType: NotificationType.AcceptedContactRequest, sectionId: sectionId)
|
||||
self.processNotification(title, message, details)
|
||||
|
||||
proc onNewCommunityMembershipRequestNotification*(self: NotificationsManager, title: string, message: string,
|
||||
sectionId: string) {.slot.} =
|
||||
let details = NotificationDetails(notificationType: NotificationType.JoinCommunityRequest, sectionId: sectionId)
|
||||
|
@ -202,6 +209,7 @@ QtObject:
|
|||
data.message = "You have a new message"
|
||||
elif(self.settingsService.getNotificationMessagePreview() == PREVIEW_NAME_ONLY):
|
||||
data.message = "You have a new message"
|
||||
|
||||
let identifier = $(details.toJsonNode())
|
||||
debug "Add OS notification", title=data.title, message=data.message, identifier=identifier
|
||||
self.showOSNotification(data.title, data.message, identifier)
|
||||
|
|
|
@ -31,4 +31,7 @@ QtObject:
|
|||
proc myRequestToJoinCommunityRejected*(self: GlobalEvents, title: string, message: string,
|
||||
sectionId: string) {.signal.}
|
||||
|
||||
proc showAcceptedContactRequest*(self: GlobalEvents, title: string, message: string,
|
||||
sectionId: string) {.signal.}
|
||||
|
||||
proc meMentionedIconBadgeNotification*(self: GlobalEvents, allMentions: int) {.signal.}
|
|
@ -720,6 +720,12 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
|
|||
message: MessageDto) =
|
||||
self.updateLastMessageTimestamp(chatIdMsgBelongsTo, lastMessageTimestamp)
|
||||
|
||||
# Any type of message coming from ourselves should never be shown as notification
|
||||
# and no need in badge notification update
|
||||
let myPK = singletonInstance.userProfile.getPubKey()
|
||||
if myPK == message.from:
|
||||
return
|
||||
|
||||
let chatDetails = self.controller.getChatDetails(chatIdMsgBelongsTo)
|
||||
|
||||
# Badge notification
|
||||
|
@ -735,12 +741,12 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
|
|||
return
|
||||
|
||||
# Prepare notification
|
||||
let myPK = singletonInstance.userProfile.getPubKey()
|
||||
var notificationType = notification_details.NotificationType.NewMessage
|
||||
if(message.isPersonalMention(myPK)):
|
||||
notificationType = notification_details.NotificationType.NewMessageWithPersonalMention
|
||||
elif(message.isGlobalMention()):
|
||||
notificationType = notification_details.NotificationType.NewMessageWithGlobalMention
|
||||
|
||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
||||
let plainText = singletonInstance.utils.plainText(renderedMessageText)
|
||||
|
@ -752,7 +758,6 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
|
|||
of ChatType.PrivateGroupChat:
|
||||
notificationTitle.add(fmt" ({chatDetails.name})")
|
||||
of ChatType.CommunityChat:
|
||||
let communityDetails = self.controller.getCommunityDetails(chatDetails.communityId)
|
||||
if (chatDetails.categoryId.len == 0):
|
||||
notificationTitle.add(fmt" (#{chatDetails.name})")
|
||||
else:
|
||||
|
|
|
@ -168,9 +168,17 @@ QtObject:
|
|||
for c in receivedData.contacts:
|
||||
let localContact = self.getContactById(c.id)
|
||||
var receivedContact = c
|
||||
|
||||
receivedContact.localNickname = localContact.localNickname
|
||||
self.saveContact(receivedContact)
|
||||
|
||||
# Check if the contact request was sent by us and if it was approved by the recipient
|
||||
if localContact.added and not localContact.hasAddedUs and receivedContact.hasAddedUs:
|
||||
singletonInstance.globalEvents.showAcceptedContactRequest(
|
||||
"Contact request accepted",
|
||||
fmt "{receivedContact.displayName} accepted your contact request",
|
||||
receivedContact.id)
|
||||
|
||||
let data = ContactArgs(contactId: c.id)
|
||||
self.events.emit(SIGNAL_CONTACT_UPDATED, data)
|
||||
|
||||
|
|
Loading…
Reference in New Issue