fix(@desktop/profile): Contact requests should support a message
Close #5846
This commit is contained in:
parent
c754cf1aaa
commit
7a14cf5640
|
@ -277,11 +277,11 @@ proc getContacts*(self: Controller, group: ContactsGroup): seq[ContactsDto] =
|
|||
proc getContactDetails*(self: Controller, id: string): ContactDetails =
|
||||
return self.contactService.getContactDetails(id)
|
||||
|
||||
proc addContact*(self: Controller, publicKey: string) =
|
||||
self.contactService.addContact(publicKey)
|
||||
proc acceptContactRequest*(self: Controller, publicKey: string) =
|
||||
self.contactService.acceptContactRequest(publicKey)
|
||||
|
||||
proc rejectContactRequest*(self: Controller, publicKey: string) =
|
||||
self.contactService.rejectContactRequest(publicKey)
|
||||
proc dismissContactRequest*(self: Controller, publicKey: string) =
|
||||
self.contactService.dismissContactRequest(publicKey)
|
||||
|
||||
proc blockContact*(self: Controller, publicKey: string) =
|
||||
self.contactService.blockContact(publicKey)
|
||||
|
|
|
@ -190,10 +190,10 @@ method acceptContactRequest*(self: AccessInterface, publicKey: string) {.base.}
|
|||
method acceptAllContactRequests*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method rejectContactRequest*(self: AccessInterface, publicKey: string) {.base.} =
|
||||
method dismissContactRequest*(self: AccessInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method rejectAllContactRequests*(self: AccessInterface) {.base.} =
|
||||
method dismissAllContactRequests*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method blockContact*(self: AccessInterface, publicKey: string) {.base.} =
|
||||
|
|
|
@ -595,7 +595,7 @@ method getCurrentFleet*(self: Module): string =
|
|||
return self.controller.getCurrentFleet()
|
||||
|
||||
method acceptContactRequest*(self: Module, publicKey: string) =
|
||||
self.controller.addContact(publicKey)
|
||||
self.controller.acceptContactRequest(publicKey)
|
||||
|
||||
method onContactAccepted*(self: Module, publicKey: string) =
|
||||
self.view.contactRequestsModel().removeItemById(publicKey)
|
||||
|
@ -606,17 +606,17 @@ method acceptAllContactRequests*(self: Module) =
|
|||
for pk in pubKeys:
|
||||
self.acceptContactRequest(pk)
|
||||
|
||||
method rejectContactRequest*(self: Module, publicKey: string) =
|
||||
self.controller.rejectContactRequest(publicKey)
|
||||
method dismissContactRequest*(self: Module, publicKey: string) =
|
||||
self.controller.dismissContactRequest(publicKey)
|
||||
|
||||
method onContactRejected*(self: Module, publicKey: string) =
|
||||
self.view.contactRequestsModel().removeItemById(publicKey)
|
||||
self.updateParentBadgeNotifications()
|
||||
|
||||
method rejectAllContactRequests*(self: Module) =
|
||||
method dismissAllContactRequests*(self: Module) =
|
||||
let pubKeys = self.view.contactRequestsModel().getItemIds()
|
||||
for pk in pubKeys:
|
||||
self.rejectContactRequest(pk)
|
||||
self.dismissContactRequest(pk)
|
||||
|
||||
method blockContact*(self: Module, publicKey: string) =
|
||||
self.controller.blockContact(publicKey)
|
||||
|
|
|
@ -169,11 +169,11 @@ QtObject:
|
|||
proc acceptAllContactRequests*(self: View) {.slot.} =
|
||||
self.delegate.acceptAllContactRequests()
|
||||
|
||||
proc rejectContactRequest*(self: View, publicKey: string) {.slot.} =
|
||||
self.delegate.rejectContactRequest(publicKey)
|
||||
proc dismissContactRequest*(self: View, publicKey: string) {.slot.} =
|
||||
self.delegate.dismissContactRequest(publicKey)
|
||||
|
||||
proc rejectAllContactRequests*(self: View) {.slot.} =
|
||||
self.delegate.rejectAllContactRequests()
|
||||
proc dismissAllContactRequests*(self: View) {.slot.} =
|
||||
self.delegate.dismissAllContactRequests()
|
||||
|
||||
proc blockContact*(self: View, publicKey: string) {.slot.} =
|
||||
self.delegate.blockContact(publicKey)
|
||||
|
|
|
@ -63,9 +63,6 @@ proc getContactNameAndImage*(self: Controller, contactId: string):
|
|||
tuple[name: string, image: string] =
|
||||
return self.contactsService.getContactNameAndImage(contactId)
|
||||
|
||||
proc addContact*(self: Controller, publicKey: string) =
|
||||
self.contactsService.addContact(publicKey)
|
||||
|
||||
proc unblockContact*(self: Controller, publicKey: string) =
|
||||
self.contactsService.unblockContact(publicKey)
|
||||
|
||||
|
@ -78,8 +75,14 @@ proc removeContact*(self: Controller, publicKey: string) =
|
|||
proc changeContactNickname*(self: Controller, publicKey: string, nickname: string) =
|
||||
self.contactsService.changeContactNickname(publicKey, nickname)
|
||||
|
||||
proc rejectContactRequest*(self: Controller, publicKey: string) =
|
||||
self.contactsService.rejectContactRequest(publicKey)
|
||||
proc sendContactRequest*(self: Controller, publicKey: string, message: string) =
|
||||
self.contactsService.sendContactRequest(publicKey, message)
|
||||
|
||||
proc acceptContactRequest*(self: Controller, publicKey: string) =
|
||||
self.contactsService.acceptContactRequest(publicKey)
|
||||
|
||||
proc dismissContactRequest*(self: Controller, publicKey: string) =
|
||||
self.contactsService.dismissContactRequest(publicKey)
|
||||
|
||||
proc removeContactRequestRejection*(self: Controller, publicKey: string) =
|
||||
self.contactsService.removeContactRequestRejection(publicKey)
|
||||
|
|
|
@ -22,19 +22,19 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
|||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method addContact*(self: AccessInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method switchToOrCreateOneToOneChat*(self: AccessInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method acceptContactRequests*(self: AccessInterface, publicKeysJSON: string) {.base.} =
|
||||
method sendContactRequest*(self: AccessInterface, publicKey: string, message: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method rejectContactRequest*(self: AccessInterface, publicKey: string) {.base.} =
|
||||
method acceptContactRequest*(self: AccessInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method rejectContactRequests*(self: AccessInterface, publicKeysJSON: string) {.base.} =
|
||||
method dismissContactRequest*(self: AccessInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method dismissContactRequests*(self: AccessInterface, publicKeysJSON: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method changeContactNickname*(self: AccessInterface, publicKey: string, nickname: string) {.base.} =
|
||||
|
|
|
@ -83,15 +83,18 @@ method viewDidLoad*(self: Module) =
|
|||
method getModuleAsVariant*(self: Module): QVariant =
|
||||
return self.viewVariant
|
||||
|
||||
method addContact*(self: Module, publicKey: string) =
|
||||
self.controller.addContact(publicKey)
|
||||
method sendContactRequest*(self: Module, publicKey: string, message: string) =
|
||||
self.controller.sendContactRequest(publicKey, message)
|
||||
|
||||
method acceptContactRequest*(self: Module, publicKey: string) =
|
||||
self.controller.acceptContactRequest(publicKey)
|
||||
|
||||
method dismissContactRequest*(self: Module, publicKey: string) =
|
||||
self.controller.dismissContactRequest(publicKey)
|
||||
|
||||
method switchToOrCreateOneToOneChat*(self: Module, publicKey: string) =
|
||||
self.controller.switchToOrCreateOneToOneChat(publicKey)
|
||||
|
||||
method rejectContactRequest*(self: Module, publicKey: string) =
|
||||
self.controller.rejectContactRequest(publicKey)
|
||||
|
||||
method unblockContact*(self: Module, publicKey: string) =
|
||||
self.controller.unblockContact(publicKey)
|
||||
|
||||
|
|
|
@ -123,14 +123,14 @@ QtObject:
|
|||
proc isMyMutualContact*(self: View, publicKey: string): bool {.slot.} =
|
||||
return self.myMutualContactsModel.isContactWithIdAdded(publicKey)
|
||||
|
||||
proc addContact*(self: View, publicKey: string) {.slot.} =
|
||||
self.delegate.addContact(publicKey)
|
||||
proc sendContactRequest*(self: View, publicKey: string, message: string) {.slot.} =
|
||||
self.delegate.sendContactRequest(publicKey, message)
|
||||
|
||||
proc switchToOrCreateOneToOneChat*(self: View, publicKey: string) {.slot.} =
|
||||
self.delegate.switchToOrCreateOneToOneChat(publicKey)
|
||||
|
||||
proc rejectContactRequest*(self: View, publicKey: string) {.slot.} =
|
||||
self.delegate.rejectContactRequest(publicKey)
|
||||
proc dismissContactRequest*(self: View, publicKey: string) {.slot.} =
|
||||
self.delegate.dismissContactRequest(publicKey)
|
||||
|
||||
proc changeContactNickname*(self: View, publicKey: string, nickname: string) {.slot.} =
|
||||
self.delegate.changeContactNickname(publicKey, nickname)
|
||||
|
|
|
@ -10,8 +10,9 @@ type ActivityCenterNotificationType* {.pure.}= enum
|
|||
Unknown = 0,
|
||||
NewOneToOne = 1,
|
||||
NewPrivateGroupChat = 2,
|
||||
Mention = 3
|
||||
Reply = 4
|
||||
Mention = 3,
|
||||
Reply = 4,
|
||||
ContactRequest = 5
|
||||
|
||||
type ActivityCenterNotificationDto* = ref object of RootObj
|
||||
id*: string # ID is the id of the chat, for public chats it is the name e.g. status, for one-to-one is the hex encoded public key and for group chats is a random uuid appended with the hex encoded pk of the creator of the chat
|
||||
|
|
|
@ -288,34 +288,53 @@ QtObject:
|
|||
# we must keep local contacts updated
|
||||
self.contacts[contact.id] = contact
|
||||
|
||||
proc addContact*(self: Service, chatKey: string) =
|
||||
proc sendContactRequest*(self: Service, chatKey: string, message: string) =
|
||||
try:
|
||||
let publicKey = status_accounts.decompressPk(chatKey).result
|
||||
|
||||
let response = status_contacts.sendContactRequest(publicKey, message)
|
||||
if(not response.error.isNil):
|
||||
let msg = response.error.message
|
||||
error "error sending contact request", msg
|
||||
return
|
||||
|
||||
var contact = self.getContactById(publicKey)
|
||||
if not contact.added:
|
||||
contact.added = true
|
||||
else:
|
||||
contact.blocked = false
|
||||
|
||||
let response = status_contacts.addContact(contact.id, contact.name)
|
||||
if(not response.error.isNil):
|
||||
let msg = response.error.message
|
||||
error "error adding contact ", msg
|
||||
return
|
||||
self.saveContact(contact)
|
||||
self.events.emit(SIGNAL_CONTACT_ADDED, ContactArgs(contactId: contact.id))
|
||||
except Exception as e:
|
||||
error "an error occurred while edding contact ", msg=e.msg
|
||||
error "an error occurred while sending contact request", msg=e.msg
|
||||
|
||||
proc rejectContactRequest*(self: Service, publicKey: string) =
|
||||
var contact = self.getContactById(publicKey)
|
||||
contact.removed = true
|
||||
|
||||
let response = status_contacts.rejectContactRequest(contact.id)
|
||||
proc acceptContactRequest*(self: Service, publicKey: string) =
|
||||
try:
|
||||
# NOTE: publicKey used for accepting last request
|
||||
let response = status_contacts.acceptLatestContactRequestForContact(publicKey)
|
||||
if(not response.error.isNil):
|
||||
let msg = response.error.message
|
||||
error "error rejecting contact ", msg
|
||||
error "error accepting contact request", msg
|
||||
return
|
||||
|
||||
var contact = self.getContactById(publicKey)
|
||||
contact.added = true
|
||||
self.saveContact(contact)
|
||||
self.events.emit(SIGNAL_CONTACT_ADDED, ContactArgs(contactId: contact.id))
|
||||
|
||||
except Exception as e:
|
||||
error "an error occurred while accepting contact request", msg=e.msg
|
||||
|
||||
proc dismissContactRequest*(self: Service, publicKey: string) =
|
||||
# NOTE: publicKey used for dismissing last request
|
||||
let response = status_contacts.dismissLatestContactRequestForContact(publicKey)
|
||||
if(not response.error.isNil):
|
||||
let msg = response.error.message
|
||||
error "error dismissing contact ", msg
|
||||
return
|
||||
|
||||
var contact = self.getContactById(publicKey)
|
||||
contact.removed = true
|
||||
self.saveContact(contact)
|
||||
self.events.emit(SIGNAL_CONTACT_REMOVED, ContactArgs(contactId: contact.id))
|
||||
|
||||
|
|
|
@ -21,12 +21,6 @@ proc unblockContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].}
|
|||
proc removeContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("removeContact".prefix, %* [id])
|
||||
|
||||
proc rejectContactRequest*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %*[{
|
||||
"id": id
|
||||
}]
|
||||
result = callPrivateRPC("rejectContactRequest".prefix, payload)
|
||||
|
||||
proc setContactLocalNickname*(id: string, name: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [{
|
||||
"id": id,
|
||||
|
@ -34,12 +28,24 @@ proc setContactLocalNickname*(id: string, name: string): RpcResponse[JsonNode] {
|
|||
}]
|
||||
result = callPrivateRPC("setContactLocalNickname".prefix, payload)
|
||||
|
||||
proc addContact*(id: string, ensName: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
proc sendContactRequest*(id: string, message: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [{
|
||||
"id": id,
|
||||
"ensName": ensName
|
||||
"message": message
|
||||
}]
|
||||
result = callPrivateRPC("addContact".prefix, payload)
|
||||
result = callPrivateRPC("sendContactRequest".prefix, payload)
|
||||
|
||||
proc acceptLatestContactRequestForContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [{
|
||||
"id": id
|
||||
}]
|
||||
result = callPrivateRPC("acceptLatestContactRequestForContact".prefix, payload)
|
||||
|
||||
proc dismissLatestContactRequestForContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %*[{
|
||||
"id": id
|
||||
}]
|
||||
result = callPrivateRPC("dismissLatestContactRequestForContact".prefix, payload)
|
||||
|
||||
proc sendContactUpdate*(publicKey, ensName, thumbnail: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [publicKey, ensName, thumbnail]
|
||||
|
|
|
@ -47,7 +47,7 @@ ModalPopup {
|
|||
popup.store.acceptContactRequest(model.pubKey)
|
||||
}
|
||||
onDeclineClicked: {
|
||||
popup.store.rejectContactRequest(model.pubKey)
|
||||
popup.store.dismissContactRequest(model.pubKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ ModalPopup {
|
|||
//% "Are you sure you want to decline all these contact requests"
|
||||
confirmationText: qsTrId("are-you-sure-you-want-to-decline-all-these-contact-requests")
|
||||
onConfirmButtonClicked: {
|
||||
popup.store.rejectAllContactRequests()
|
||||
popup.store.dismissAllContactRequests()
|
||||
declineAllDialog.close()
|
||||
popup.close()
|
||||
}
|
||||
|
|
|
@ -62,12 +62,12 @@ QtObject {
|
|||
chatCommunitySectionModule.acceptAllContactRequests()
|
||||
}
|
||||
|
||||
function rejectContactRequest(pubKey) {
|
||||
chatCommunitySectionModule.rejectContactRequest(pubKey)
|
||||
function dismissContactRequest(pubKey) {
|
||||
chatCommunitySectionModule.dismissContactRequest(pubKey)
|
||||
}
|
||||
|
||||
function rejectAllContactRequests() {
|
||||
chatCommunitySectionModule.rejectAllContactRequests()
|
||||
function dismissAllContactRequests() {
|
||||
chatCommunitySectionModule.dismissAllContactRequests()
|
||||
}
|
||||
|
||||
function blockContact(pubKey) {
|
||||
|
|
|
@ -19,10 +19,12 @@ StatusModal {
|
|||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
readonly property int maxMsgLength: 280
|
||||
readonly property int minMsgLength: 0 //TODO: update this to 1 later, when we introduce "say who you are" feature
|
||||
readonly property int minMsgLength: 1
|
||||
readonly property int msgHeight: 152
|
||||
readonly property int contentSpacing: 0
|
||||
readonly property int contentSpacing: 5
|
||||
readonly property int contentMargins: 16
|
||||
|
||||
property int minChatKeyLength: 4 // ens or chat key
|
||||
property string realChatKey: ""
|
||||
|
@ -83,7 +85,9 @@ StatusModal {
|
|||
contentItem: Item {
|
||||
Column {
|
||||
id: content
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: d.contentMargins
|
||||
spacing: d.contentSpacing
|
||||
|
||||
StatusInput {
|
||||
|
@ -143,7 +147,7 @@ StatusModal {
|
|||
enabled: d.validChatKey && messageInput.valid
|
||||
text: qsTr("Send Contact Request")
|
||||
onClicked: {
|
||||
root.contactsStore.addContact(d.realChatKey)
|
||||
root.contactsStore.sendContactRequest(d.realChatKey, messageInput.text)
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,10 +41,6 @@ QtObject {
|
|||
root.contactsModule.switchToOrCreateOneToOneChat(pubKey)
|
||||
}
|
||||
|
||||
function addContact(pubKey) {
|
||||
root.contactsModule.addContact(pubKey)
|
||||
}
|
||||
|
||||
function unblockContact(pubKey) {
|
||||
root.contactsModule.unblockContact(pubKey)
|
||||
}
|
||||
|
@ -61,12 +57,16 @@ QtObject {
|
|||
root.contactsModule.changeContactNickname(pubKey, nickname)
|
||||
}
|
||||
|
||||
function acceptContactRequest(pubKey) {
|
||||
root.contactsModule.addContact(pubKey)
|
||||
function sendContactRequest(pubKey, message) {
|
||||
root.contactsModule.sendContactRequest(pubKey, message)
|
||||
}
|
||||
|
||||
function rejectContactRequest(pubKey) {
|
||||
root.contactsModule.rejectContactRequest(pubKey)
|
||||
function acceptContactRequest(pubKey) {
|
||||
root.contactsModule.acceptContactRequest(pubKey)
|
||||
}
|
||||
|
||||
function dismissContactRequest(pubKey) {
|
||||
root.contactsModule.dismissContactRequest(pubKey)
|
||||
}
|
||||
|
||||
function removeContactRequestRejection(pubKey) {
|
||||
|
|
|
@ -192,7 +192,7 @@ SettingsContentBase {
|
|||
}
|
||||
|
||||
onContactRequestRejected: {
|
||||
root.contactsStore.rejectContactRequest(publicKey)
|
||||
root.contactsStore.dismissContactRequest(publicKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ StatusModal {
|
|||
text: qsTr("Add to contacts")
|
||||
visible: !userIsBlocked && !isAddedContact
|
||||
onClicked: {
|
||||
popup.contactsStore.addContact(userPublicKey);
|
||||
popup.contactsStore.sendContactRequest(userPublicKey);
|
||||
popup.contactAdded(userPublicKey);
|
||||
popup.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue