diff --git a/src/app/core/notifications/notifications_manager.nim b/src/app/core/notifications/notifications_manager.nim index c958907bf4..b1b44d2daa 100644 --- a/src/app/core/notifications/notifications_manager.nim +++ b/src/app/core/notifications/notifications_manager.nim @@ -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) diff --git a/src/app/global/global_events.nim b/src/app/global/global_events.nim index e156f9780d..1a3bcc8333 100644 --- a/src/app/global/global_events.nim +++ b/src/app/global/global_events.nim @@ -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.} \ No newline at end of file diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 100bcb82de..190e224866 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -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: diff --git a/src/app_service/service/contacts/service.nim b/src/app_service/service/contacts/service.nim index ec18d10551..533562729b 100644 --- a/src/app_service/service/contacts/service.nim +++ b/src/app_service/service/contacts/service.nim @@ -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)