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

Fix some issues with pinned messages #3414

Merged
merged 1 commit into from
Apr 25, 2023
Merged

Conversation

cammellos
Copy link
Contributor

There were a couple of issues on how we handle pinned messages:

  1. Clock of the message was only checked when saving, meaning that the
    client would receive potentially updates that were not to be
    processed.
  2. We relied on the client to generate a notification for a pinned
    message by sending a normal message through the wire. This PR changes
    the behavior so that the notification is generated locally, either on
    response to a network event or client event.
  3. When deleting a message, we pull all the replies/pinned notifications
    and send them over to the client so they know that those messages
    needs updating.

There's a couple of tests I would like to add, but in the meantime I think it's ready for review.

@ghost
Copy link

ghost commented Apr 19, 2023

Pull Request Checklist

  • Have you updated the documentation, if impacted (e.g. docs.status.im)?
  • Have you tested changes with mobile?
  • Have you tested changes with desktop?

@status-im-auto
Copy link
Member

status-im-auto commented Apr 19, 2023

Jenkins Builds

Click to see older builds (36)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 2b29f40 #1 2023-04-19 20:20:58 ~2 min linux 📦zip
✔️ 2b29f40 #1 2023-04-19 20:22:20 ~4 min ios 📦zip
✔️ 2b29f40 #1 2023-04-19 20:22:40 ~4 min android 📦aar
✖️ 2b29f40 #1 2023-04-19 20:26:13 ~7 min tests 📄log
✔️ 51fd30b #2 2023-04-20 06:46:10 ~2 min ios 📦zip
✔️ 51fd30b #2 2023-04-20 06:46:22 ~2 min linux 📦zip
✔️ 51fd30b #2 2023-04-20 06:47:43 ~4 min android 📦aar
✖️ 51fd30b #2 2023-04-20 07:07:19 ~23 min tests 📄log
✔️ 2892ba4 #3 2023-04-20 08:46:08 ~2 min linux 📦zip
✔️ 2892ba4 #3 2023-04-20 08:46:32 ~2 min ios 📦zip
✔️ 2892ba4 #3 2023-04-20 08:49:08 ~5 min android 📦aar
✖️ 2892ba4 #3 2023-04-20 09:06:48 ~22 min tests 📄log
✔️ a85a144 #5 2023-04-20 14:09:48 ~8 min linux 📦zip
✔️ a85a144 #5 2023-04-20 14:14:00 ~12 min android 📦aar
✖️ a85a144 #5 2023-04-20 14:28:00 ~26 min tests 📄log
✔️ a85a144 #5 2023-04-20 14:41:23 ~16 min ios 📦zip
✖️ 4478fa4 #6 2023-04-20 15:13:37 ~2 min tests 📄log
✔️ 4478fa4 #6 2023-04-20 15:13:48 ~2 min linux 📦zip
✔️ 4478fa4 #6 2023-04-20 15:15:28 ~4 min ios 📦zip
✔️ 4478fa4 #6 2023-04-20 15:15:37 ~4 min android 📦aar
✔️ b412f87 #7 2023-04-20 16:12:23 ~1 min linux 📦zip
✔️ b412f87 #7 2023-04-20 16:12:57 ~2 min ios 📦zip
✔️ b412f87 #7 2023-04-20 16:14:02 ~3 min android 📦aar
✔️ b412f87 #7 2023-04-20 16:24:27 ~13 min tests 📄log
✔️ 4a3470f #8 2023-04-21 09:56:52 ~3 min linux 📦zip
✔️ 4a3470f #8 2023-04-21 09:57:31 ~3 min android 📦aar
✔️ 4a3470f #8 2023-04-21 09:57:33 ~3 min ios 📦zip
✖️ 4a3470f #8 2023-04-21 10:04:07 ~10 min tests 📄log
✔️ 1374e8d #9 2023-04-21 13:39:39 ~2 min linux 📦zip
✔️ 1374e8d #9 2023-04-21 13:39:59 ~2 min ios 📦zip
✔️ 1374e8d #9 2023-04-21 13:40:48 ~3 min android 📦aar
✖️ 1374e8d #9 2023-04-21 13:59:20 ~21 min tests 📄log
✔️ a0d23b6 #10 2023-04-21 16:06:15 ~2 min linux 📦zip
✔️ a0d23b6 #10 2023-04-21 16:06:33 ~2 min ios 📦zip
✔️ a0d23b6 #10 2023-04-21 16:07:24 ~3 min android 📦aar
✖️ a0d23b6 #10 2023-04-21 16:25:51 ~21 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 76cdd97 #11 2023-04-24 09:08:33 ~2 min linux 📦zip
✔️ 76cdd97 #11 2023-04-24 09:09:33 ~3 min ios 📦zip
✔️ 76cdd97 #11 2023-04-24 09:10:04 ~3 min android 📦aar
✔️ 76cdd97 #11 2023-04-24 09:16:24 ~10 min tests 📄log
✔️ 03ce01a #12 2023-04-24 10:27:29 ~2 min linux 📦zip
✔️ 03ce01a #12 2023-04-24 10:28:38 ~3 min ios 📦zip
✔️ 03ce01a #12 2023-04-24 10:28:50 ~3 min android 📦aar
✖️ 03ce01a #12 2023-04-24 10:47:06 ~21 min tests 📄log
✖️ 03ce01a #13 2023-04-24 12:00:36 ~5 min tests 📄log
✔️ 03ce01a #14 2023-04-24 13:26:57 ~9 min tests 📄log

@cammellos cammellos force-pushed the feature/pinned-messages branch from 2b29f40 to 51fd30b Compare April 20, 2023 06:43
@MishkaRogachev
Copy link
Contributor

As i remember @saledjenic and @osmaczko were working on pinned messages in desktop, so think it would be better to have a review from them

@cammellos cammellos force-pushed the feature/pinned-messages branch from 51fd30b to 2892ba4 Compare April 20, 2023 08:43
Comment on lines +34 to +35

Message *PinnedMessage `json:"pinnedMessage"`
Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +1435 to +1444
type insertPinMessagesQueries struct {
selectStmt string
insertStmt *sql.Stmt
updateStmt *sql.Stmt
transaction *sql.Tx
}
Copy link
Member

Choose a reason for hiding this comment

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

This is a nice approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

I remember I once talked to @cammellos about the usage of a query builder library (not ORMs :rage1:). For example http://doug-martin.github.io/goqu/ Nothing magical, just type safety, and a unified way to compose queries.

Right now, the problem I see is that concatenating strings is a suboptimal abstraction that leads to various ad-hoc solutions and certainly a lot of duplication (since it's hard to compose strings from different functions).

What are your thoughts @Samyoul? Would you like to see an experiment with such a library? Have you tried any library in this space?

Copy link
Member

Choose a reason for hiding this comment

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

Fundamentally @ilmotta I agree with you. One of the first things I wanted to do with this repo was overhaul the database interactions because there were/are so many persistence packages, mostly written with pure SQL. There are already a number of places in this repo where we've implemented various ad-hoc query builder solutions.

Settings is one stand out example, and may even be a good candidate for an experiment with a query building library.

I'd be interest in how well joining, grouping, having and more complex queries could be handled, looking over the docs of goqu it seems that it has robust support for quite complex queries.

So another candidate could be user identity, as there is a single row for user data and multiple rows for the user images.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @Samyoul, sorry I couldn't reply because I didn't work last Friday 🎉

It's great to hear you're interested in seeing where this experiment could go. There's enough quorum! I'll try to cook something after I finish the feature I'm working on.

I'd be interest in how well joining, grouping, having and more complex queries could be handled, looking over the docs of goqu it seems that it has robust support for quite complex queries.

I'm curious too to understand where goqu "breaks" so to speak, because that would help us understand where it can be useful and where we should avoid it (if there is any such scenario).

So another candidate could be user identity, as there is a single row for user data and multiple rows for the user images.

Sounds reasonable! And we can do the improvements piecemeal since we can always convert the query back to a string.

}

return
}

func (db sqlitePersistence) SavePinMessage(message *common.PinMessage) (inserted bool, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

I really appreciate the use of a named return parameter in this case.

Copy link
Member

@Samyoul Samyoul left a comment

Choose a reason for hiding this comment

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

Really nicely done.

@cammellos cammellos force-pushed the feature/pinned-messages branch 2 times, most recently from 5af3563 to a85a144 Compare April 20, 2023 14:00
Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

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

LGTM

@cammellos cammellos force-pushed the feature/pinned-messages branch 6 times, most recently from a0d23b6 to 76cdd97 Compare April 24, 2023 09:06
There were a couple of issues on how we handle pinned messages:

1) Clock of the message was only checked when saving, meaning that the
   client would receive potentially updates that were not to be
   processed.
2) We relied on the client to generate a notification for a pinned
   message by sending a normal message through the wire. This PR changes
   the behavior so that the notification is generated locally, either on
   response to a network event or client event.
3) When deleting a message, we pull all the replies/pinned notifications
   and send them over to the client so they know that those messages
   needs updating.
@cammellos cammellos force-pushed the feature/pinned-messages branch from 76cdd97 to 03ce01a Compare April 24, 2023 10:24
@cammellos cammellos merged commit 7650f30 into develop Apr 25, 2023
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.

6 participants