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)
|
self, "onMyRequestToJoinCommunityRejected(QString, QString, QString)", 2)
|
||||||
signalConnect(singletonInstance.globalEvents, "meMentionedIconBadgeNotification(int)",
|
signalConnect(singletonInstance.globalEvents, "meMentionedIconBadgeNotification(int)",
|
||||||
self, "onMeMentionedIconBadgeNotification(int)", 2)
|
self, "onMeMentionedIconBadgeNotification(int)", 2)
|
||||||
|
signalConnect(singletonInstance.globalEvents, "showAcceptedContactRequest(QString, QString, QString)",
|
||||||
|
self, "onShowAcceptedContactRequest(QString, QString, QString)", 2)
|
||||||
|
|
||||||
self.notificationSetUp = true
|
self.notificationSetUp = true
|
||||||
|
|
||||||
|
@ -143,6 +145,11 @@ QtObject:
|
||||||
let details = NotificationDetails(notificationType: NotificationType.NewContactRequest, sectionId: sectionId)
|
let details = NotificationDetails(notificationType: NotificationType.NewContactRequest, sectionId: sectionId)
|
||||||
self.processNotification(title, message, details)
|
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,
|
proc onNewCommunityMembershipRequestNotification*(self: NotificationsManager, title: string, message: string,
|
||||||
sectionId: string) {.slot.} =
|
sectionId: string) {.slot.} =
|
||||||
let details = NotificationDetails(notificationType: NotificationType.JoinCommunityRequest, sectionId: sectionId)
|
let details = NotificationDetails(notificationType: NotificationType.JoinCommunityRequest, sectionId: sectionId)
|
||||||
|
@ -202,6 +209,7 @@ QtObject:
|
||||||
data.message = "You have a new message"
|
data.message = "You have a new message"
|
||||||
elif(self.settingsService.getNotificationMessagePreview() == PREVIEW_NAME_ONLY):
|
elif(self.settingsService.getNotificationMessagePreview() == PREVIEW_NAME_ONLY):
|
||||||
data.message = "You have a new message"
|
data.message = "You have a new message"
|
||||||
|
|
||||||
let identifier = $(details.toJsonNode())
|
let identifier = $(details.toJsonNode())
|
||||||
debug "Add OS notification", title=data.title, message=data.message, identifier=identifier
|
debug "Add OS notification", title=data.title, message=data.message, identifier=identifier
|
||||||
self.showOSNotification(data.title, data.message, identifier)
|
self.showOSNotification(data.title, data.message, identifier)
|
||||||
|
|
|
@ -31,4 +31,7 @@ QtObject:
|
||||||
proc myRequestToJoinCommunityRejected*(self: GlobalEvents, title: string, message: string,
|
proc myRequestToJoinCommunityRejected*(self: GlobalEvents, title: string, message: string,
|
||||||
sectionId: string) {.signal.}
|
sectionId: string) {.signal.}
|
||||||
|
|
||||||
|
proc showAcceptedContactRequest*(self: GlobalEvents, title: string, message: string,
|
||||||
|
sectionId: string) {.signal.}
|
||||||
|
|
||||||
proc meMentionedIconBadgeNotification*(self: GlobalEvents, allMentions: int) {.signal.}
|
proc meMentionedIconBadgeNotification*(self: GlobalEvents, allMentions: int) {.signal.}
|
|
@ -720,6 +720,12 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
|
||||||
message: MessageDto) =
|
message: MessageDto) =
|
||||||
self.updateLastMessageTimestamp(chatIdMsgBelongsTo, lastMessageTimestamp)
|
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)
|
let chatDetails = self.controller.getChatDetails(chatIdMsgBelongsTo)
|
||||||
|
|
||||||
# Badge notification
|
# Badge notification
|
||||||
|
@ -735,12 +741,12 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
|
||||||
return
|
return
|
||||||
|
|
||||||
# Prepare notification
|
# Prepare notification
|
||||||
let myPK = singletonInstance.userProfile.getPubKey()
|
|
||||||
var notificationType = notification_details.NotificationType.NewMessage
|
var notificationType = notification_details.NotificationType.NewMessage
|
||||||
if(message.isPersonalMention(myPK)):
|
if(message.isPersonalMention(myPK)):
|
||||||
notificationType = notification_details.NotificationType.NewMessageWithPersonalMention
|
notificationType = notification_details.NotificationType.NewMessageWithPersonalMention
|
||||||
elif(message.isGlobalMention()):
|
elif(message.isGlobalMention()):
|
||||||
notificationType = notification_details.NotificationType.NewMessageWithGlobalMention
|
notificationType = notification_details.NotificationType.NewMessageWithGlobalMention
|
||||||
|
|
||||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
||||||
let plainText = singletonInstance.utils.plainText(renderedMessageText)
|
let plainText = singletonInstance.utils.plainText(renderedMessageText)
|
||||||
|
@ -752,7 +758,6 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
|
||||||
of ChatType.PrivateGroupChat:
|
of ChatType.PrivateGroupChat:
|
||||||
notificationTitle.add(fmt" ({chatDetails.name})")
|
notificationTitle.add(fmt" ({chatDetails.name})")
|
||||||
of ChatType.CommunityChat:
|
of ChatType.CommunityChat:
|
||||||
let communityDetails = self.controller.getCommunityDetails(chatDetails.communityId)
|
|
||||||
if (chatDetails.categoryId.len == 0):
|
if (chatDetails.categoryId.len == 0):
|
||||||
notificationTitle.add(fmt" (#{chatDetails.name})")
|
notificationTitle.add(fmt" (#{chatDetails.name})")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -168,9 +168,17 @@ QtObject:
|
||||||
for c in receivedData.contacts:
|
for c in receivedData.contacts:
|
||||||
let localContact = self.getContactById(c.id)
|
let localContact = self.getContactById(c.id)
|
||||||
var receivedContact = c
|
var receivedContact = c
|
||||||
|
|
||||||
receivedContact.localNickname = localContact.localNickname
|
receivedContact.localNickname = localContact.localNickname
|
||||||
self.saveContact(receivedContact)
|
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)
|
let data = ContactArgs(contactId: c.id)
|
||||||
self.events.emit(SIGNAL_CONTACT_UPDATED, data)
|
self.events.emit(SIGNAL_CONTACT_UPDATED, data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue