Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14044 handle edit messages in bridge #4983

Closed

Conversation

endulab
Copy link
Contributor

@endulab endulab commented Mar 25, 2024

Adjust EditMessage() to handle bridge messages (will be used by the bridge).
Adjust applyEditMessage() to handle bridge messages.

Closes #14044

@endulab endulab self-assigned this Mar 25, 2024
@endulab endulab changed the base branch from develop to release/0.177.x March 25, 2024 16:25
@status-im-auto
Copy link
Member

status-im-auto commented Mar 25, 2024

Jenkins Builds

Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ 222089a #1 2024-03-25 16:28:16 ~2 min tests 📄log
✔️ 222089a #1 2024-03-25 16:29:07 ~3 min linux 📦zip
✖️ 222089a #2 2024-03-25 16:29:22 ~1 min tests 📄log
✔️ 222089a #2 2024-03-25 16:30:42 ~1 min linux 📦zip
✔️ 222089a #1 2024-03-25 16:31:23 ~5 min android 📦aar
✔️ 222089a #1 2024-03-25 16:31:46 ~6 min ios 📦zip
✔️ 222089a #2 2024-03-25 16:32:47 ~1 min android 📦aar
✔️ 222089a #2 2024-03-25 16:36:29 ~4 min ios 📦zip
✔️ 1d8099e #3 2024-03-26 14:51:15 ~1 min android 📦aar
✖️ 1d8099e #3 2024-03-26 14:52:05 ~2 min tests 📄log
✔️ 1d8099e #3 2024-03-26 14:52:39 ~3 min ios 📦zip
✔️ 1d8099e #3 2024-03-26 14:53:06 ~3 min linux 📦zip

Comment on lines 154 to 177
editMessage := EditMessage{
EditMessage: &protobuf.EditMessage{
Clock: messageToEdit.Clock + 1,
Text: editedText,
MessageType: protobuf.MessageType_ONE_TO_ONE,
MessageId: messageToEdit.ID,
ChatId: theirChat.ID,
ContentType: protobuf.ChatMessage_BRIDGE_MESSAGE,
},
From: common.PubkeyToHex(&theirMessenger.identity.PublicKey),
}
state := &ReceivedMessageState{
Response: &MessengerResponse{},
}

// Handle edit first
err = s.m.handleEditMessage(state, editMessage)
s.Require().NoError(err)

// It save the edit
s.Require().Len(state.Response.Messages(), 1)
s.Require().Len(state.Response.Chats(), 1)
s.Require().NotEmpty(state.Response.Chats()[0].LastMessage.EditedAt)
s.Require().Equal(state.Response.Messages()[0].GetBridgeMessage().Content, "edited text")
Copy link
Contributor

@mprakhov mprakhov Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you call WaitOnMessengerResponse instead of a direct call of s.m.handleEditMessage(state, editMessage) in order to check that s.m received the edited message?

Copy link
Contributor

@mprakhov mprakhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a comment related the test

var hasMessage bool
hasMessage, err = db.bridgeMessageExists(tx, msg.GetBridgeMessage().MessageID)
if err != nil {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of err, maybe we should just ignore and save the message as before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, if it returned the error, it would mean that there is something wrong with db connection and another db operation would fail also. Am I right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mean return the error. I mean just not return. Because since you return, you will miss that message

// Finds status messages id which are replies for bridgeMessageID
func (db sqlitePersistence) findStatusMessageIdsRepliedTo(tx *sql.Tx, parentMessageID string) (string, error) {
rows, err := tx.Query(`SELECT user_messages_id FROM bridge_messages WHERE message_id = ?`, parentMessageID)
func (db sqlitePersistence) FindStatusMessageIdForBridgeMessageId(messageID string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean it could get slower over time? Excuse my ignorance, are the messages split per chats or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we query from bridge messages.
Bridge messages have a separated table. They are joined with messages via a messageId.
I did not investigate how much time does it take.

Copy link
Contributor

@kounkou kounkou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, quite clear changes.

@endulab endulab force-pushed the 14044-handle-edit-messages-in-bridge branch from 222089a to 1d8099e Compare March 26, 2024 14:49
@endulab endulab closed this Apr 8, 2024
@endulab
Copy link
Contributor Author

endulab commented Apr 8, 2024

Cherry-picked to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bridged message edits in Status do not work
5 participants