Skip to content

Commit

Permalink
fix: Fix behaviour issues with CRs and mutual update events
Browse files Browse the repository at this point in the history
Close #11121
  • Loading branch information
MishkaRogachev committed Jul 11, 2023
1 parent 9629a14 commit 56b6634
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/app_service/common/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ type
ContactIdentityVerification = 13
# Local only
SystemMessagePinnedMessage = 14
SystemMessageMutualStateUpdate = 15
SystemMessageMutualEventSent = 15
SystemMessageMutualEventAccepted = 16
SystemMessageMutualEventRemoved = 17

proc toContentType*(value: int): ContentType =
try:
Expand Down
7 changes: 2 additions & 5 deletions src/app_service/service/message/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,8 @@ QtObject:
error "error: received `chats` array for handling messages update is empty"
return

# Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
# blocking contact deletes the chat on the `status-go` side, after unblocking it, `active` prop is still false
# that's the reason why the following check is commented out here.
# if (not chats[0].active):
# return
if (not chats[0].active):
return

self.bulkReplacePubKeysWithDisplayNames(messages)

Expand Down
8 changes: 6 additions & 2 deletions ui/StatusQ/src/StatusQ/Components/StatusMessage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Control {
Invitation = 7,
DiscordMessage = 8,
SystemMessagePinnedMessage = 14,
SystemMessageMutualStateUpdate = 15
SystemMessageMutualEventSent = 15,
SystemMessageMutualEventAccepted = 16,
SystemMessageMutualEventRemoved = 17
}

property list<Item> quickActions
Expand Down Expand Up @@ -191,7 +193,9 @@ Control {
Layout.fillWidth: true
active: isAReply &&
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessagePinnedMessage &&
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessageMutualStateUpdate
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessageMutualEventSent &&
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessageMutualEventAccepted &&
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessageMutualEventRemoved

visible: active
sourceComponent: StatusMessageReply {
Expand Down
53 changes: 47 additions & 6 deletions ui/imports/shared/views/chat/MessageView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,11 @@ Loader {
case Constants.messageContentType.fetchMoreMessagesButton:
return fetchMoreMessagesButtonComponent
case Constants.messageContentType.systemMessagePrivateGroupType: // no break
case Constants.messageContentType.systemMessageMutualStateUpdate:
return systemMessageComponent
return systemMessageGroupComponent
case Constants.messageContentType.systemMessageMutualEventSent:
case Constants.messageContentType.systemMessageMutualEventAccepted:
case Constants.messageContentType.systemMessageMutualEventRemoved:
return systemMessageMutualEventComponent
case Constants.messageContentType.systemMessagePinnedMessage:
return systemMessagePinnedMessageComponent
case Constants.messageContentType.gapType:
Expand Down Expand Up @@ -271,8 +274,12 @@ Loader {
return StatusMessage.ContentType.DiscordMessage;
case Constants.messageContentType.systemMessagePinnedMessage:
return StatusMessage.ContentType.SystemMessagePinnedMessage;
case Constants.messageContentType.systemMessageMutualStateUpdate:
return StatusMessage.ContentType.SystemMessageMutualStateUpdate;
case Constants.messageContentType.systemMessageMutualEventSent:
return StatusMessage.ContentType.SystemMessageMutualEventSent;
case Constants.messageContentType.systemMessageMutualEventAccepted:
return StatusMessage.ContentType.SystemMessageMutualEventAccepted;
case Constants.messageContentType.systemMessageMutualEventRemoved:
return StatusMessage.ContentType.SystemMessageMutualEventRemoved;
case Constants.messageContentType.fetchMoreMessagesButton:
case Constants.messageContentType.chatIdentifier:
case Constants.messageContentType.unknownContentType:
Expand Down Expand Up @@ -348,7 +355,7 @@ Loader {
}

Component {
id: systemMessageComponent
id: systemMessageGroupComponent

StyledText {
wrapMode: Text.Wrap
Expand Down Expand Up @@ -379,6 +386,38 @@ Loader {
}
}

Component{
id: systemMessageMutualEventComponent

StyledText {
text: {
switch (root.messageContentType) {
case Constants.messageContentType.systemMessageMutualEventSent:
return root.amISender ?
qsTr("You sent a contact request to %1").arg(root.senderDisplayName) :
qsTr("%1 sent you a contact request").arg(root.senderDisplayName)
case Constants.messageContentType.systemMessageMutualEventAccepted:
return root.amISender ?
qsTr("You accepted %1's contact request").arg(root.senderDisplayName) :
qsTr("%1 accepted your contact request").arg(root.senderDisplayName)
case Constants.messageContentType.systemMessageMutualEventRemoved:
return root.amISender ?
qsTr("You removed %1 as a contact").arg(root.senderDisplayName) :
qsTr("%1 removed you as a contact").arg(root.senderDisplayName)
default:
return root.messageText
}
}
font.pixelSize: 14
color: Style.current.secondaryText
width: parent.width - 120
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
textFormat: Text.RichText
topPadding: root.prevMessageIndex === 1 ? Style.current.bigPadding : 0
}
}

Component {
id: systemMessagePinnedMessageComponent

Expand Down Expand Up @@ -481,7 +520,9 @@ Loader {
showHeader: root.shouldRepeatHeader || dateGroupLabel.visible || isAReply ||
root.prevMessageContentType === Constants.messageContentType.systemMessagePrivateGroupType ||
root.prevMessageContentType === Constants.messageContentType.systemMessagePinnedMessage ||
root.prevMessageContentType === Constants.messageContentType.systemMessageMutualStateUpdate ||
root.prevMessageContentType === Constants.messageContentType.systemMessageMutualEventSent ||
root.prevMessageContentType === Constants.messageContentType.systemMessageMutualEventAccepted ||
root.prevMessageContentType === Constants.messageContentType.systemMessageMutualEventRemoved ||
root.senderId !== root.prevMessageSenderId
isActiveMessage: d.isMessageActive
topPadding: showHeader ? Style.current.halfPadding : 0
Expand Down
4 changes: 3 additions & 1 deletion ui/imports/utils/Constants.qml
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ QtObject {
readonly property int contactRequestType: 11
readonly property int discordMessageType: 12
readonly property int systemMessagePinnedMessage: 14
readonly property int systemMessageMutualStateUpdate: 15
readonly property int systemMessageMutualEventSent: 15
readonly property int systemMessageMutualEventAccepted: 16
readonly property int systemMessageMutualEventRemoved: 17
}

readonly property QtObject messageModelRoles: QtObject {
Expand Down
2 changes: 1 addition & 1 deletion vendor/status-go
Submodule status-go updated 62 files
+1 −1 VERSION
+4 −0 api/defaults.go
+45 −9 api/geth_backend.go
+8 −8 appdatabase/database.go
+2 −2 go.mod
+4 −4 go.sum
+2 −1 node/status_node_services.go
+1 −1 protocol/anonmetrics/client.go
+9 −11 protocol/common/message_sender.go
+3 −3 protocol/common/message_sender_test.go
+1 −1 protocol/common/raw_message.go
+2 −2 protocol/common/raw_messages_persistence.go
+13 −0 protocol/communities_messenger_test.go
+0 −124 protocol/encryption/encryption_test.go
+4 −2 protocol/message_validator.go
+3 −3 protocol/messenger.go
+1 −1 protocol/messenger_backup.go
+43 −26 protocol/messenger_communities.go
+23 −38 protocol/messenger_contact_requests_test.go
+45 −90 protocol/messenger_contacts.go
+36 −39 protocol/messenger_handler.go
+105 −95 protocol/protobuf/chat_message.pb.go
+6 −1 protocol/protobuf/chat_message.proto
+5 −5 protocol/pushnotificationclient/client.go
+3 −3 protocol/pushnotificationserver/server.go
+2 −1 protocol/requests/create_account.go
+16 −10 services/wallet/activity/activity.go
+1 −1 services/wallet/api.go
+28 −0 services/wallet/decoder.go
+3 −4 services/wallet/service.go
+103 −0 services/wallet/thirdparty/fourbytegithub/client.go
+34 −0 services/wallet/thirdparty/fourbytegithub/client_test.go
+52 −3 services/wallet/transfer/transaction.go
+2 −1 services/wallet/transfer/transaction_test.go
+10 −3 signal/events_node.go
+3 −1 signal/events_wakuv2.go
+21 −13 sqlite/sqlite.go
+0 −36 vendor/github.com/waku-org/go-waku/waku/try/try.go
+48 −8 vendor/github.com/waku-org/go-waku/waku/v2/discovery_connector.go
+26 −14 vendor/github.com/waku-org/go-waku/waku/v2/discv5/discover.go
+0 −1 vendor/github.com/waku-org/go-waku/waku/v2/node/keepalive.go
+61 −0 vendor/github.com/waku-org/go-waku/waku/v2/node/localnode.go
+0 −6 vendor/github.com/waku-org/go-waku/waku/v2/node/service.go
+6 −70 vendor/github.com/waku-org/go-waku/waku/v2/node/wakunode2.go
+2 −15 vendor/github.com/waku-org/go-waku/waku/v2/node/wakuoptions.go
+0 −1 vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/localnode.go
+13 −3 vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/shards.go
+9 −10 vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/client.go
+5 −1 vendor/github.com/waku-org/go-waku/waku/v2/protocol/peer_exchange/client.go
+5 −4 vendor/github.com/waku-org/go-waku/waku/v2/protocol/peer_exchange/protocol.go
+48 −2 vendor/github.com/waku-org/go-waku/waku/v2/protocol/relay/waku_relay.go
+2 −2 vendor/github.com/waku-org/go-waku/waku/v2/protocol/shard.go
+0 −1 vendor/github.com/waku-org/go-waku/waku/v2/protocol/topic.go
+8 −8 vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/rendezvous.go
+8 −0 vendor/golang.org/x/crypto/cryptobyte/asn1.go
+6 −93 vendor/golang.org/x/crypto/curve25519/curve25519.go
+105 −0 vendor/golang.org/x/crypto/curve25519/curve25519_compat.go
+46 −0 vendor/golang.org/x/crypto/curve25519/curve25519_go120.go
+2 −3 vendor/modules.txt
+1 −1 wakuv2/api_test.go
+74 −40 wakuv2/waku.go
+4 −4 wakuv2/waku_test.go

0 comments on commit 56b6634

Please sign in to comment.