Skip to content

feat: pinned messages - #8546

Merged
r10s merged 5 commits into
mainfrom
r10s/pinned-messages
Aug 7, 2026
Merged

feat: pinned messages#8546
r10s merged 5 commits into
mainfrom
r10s/pinned-messages

Conversation

@r10s

@r10s r10s commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

this PR adds a "pinned messages API", that will allow UIs to offer the typical things of pinned messages:

  • add a menu item to pin/unpin any message
  • show a banner with the pinned messages, taps cycle through them (if more than 1) and scroll to the original bubble
  • if more than 1 pinned message, UI should show a "scrolling indicator", see existing implementations to get the idea
  • show a little "pin icon" beside the date in the message bubbles
  • and more

implementation wise, this PR is comparable straight forward - it does not change much of existing flows, only adds, and around half of the added lines are tests and codes :)

  • a new set_pinned_state() api allows to pin/unpin a message. as several other API (chat names, member added etc.) it sends out an info-message, that carries Chat-Content: message-pinned resp. Chat-Content: message-unpinned header. the changed message is the parent message, similar as used for webxdc updates.

  • noteworthy: the info message is only in the chat if a message is pinned. if a message is unpinned, it is hidden. this is what most other implementations do as well, unpinning an outdated information is of few interest

  • when other members or devices receive that message, they change the pinned state accordingly. notifications are done as usual.

  • finally, there is a pinned API to show the little needle beside messages. this is the only API that also exist for cffi, as android/iOS/ubuntutouch work with cffi message objects

later, we also want to resend pinned messages in channels, this is comparable easy as well, but to keep discussion on point, i moved that to another PR that is about to discussed once this is merged.

android-PR started at deltachat/deltachat-android#4586

closes #7817

@r10s
r10s force-pushed the r10s/pinned-messages branch from f7077bc to 82f7780 Compare August 5, 2026 11:12
@r10s r10s added the enhancement New feature or request label Aug 5, 2026
@r10s
r10s force-pushed the r10s/pinned-messages branch 25 times, most recently from 7c79b2b to 3c35e65 Compare August 6, 2026 13:54
@r10s
r10s force-pushed the r10s/pinned-messages branch 2 times, most recently from dbe718a to 4c170ed Compare August 6, 2026 15:41
@r10s
r10s requested review from Hocuri, j-g00da and link2xt August 6, 2026 16:08
@r10s
r10s marked this pull request as ready for review August 6, 2026 16:09
@r10s
r10s force-pushed the r10s/pinned-messages branch from 4c170ed to fa24393 Compare August 6, 2026 16:19
Comment thread src/sql/migrations.rs Outdated
Comment thread src/pinned_messages.rs Outdated
Comment thread src/pinned_messages.rs Outdated
Comment thread src/pinned_messages.rs Outdated
Comment thread src/pinned_messages.rs Outdated
Comment thread src/receive_imf.rs
|| mime_parser.is_system_message == SystemMessage::MessageUnpinned)
&& let Some(msg_to_change) =
get_parent_message(context, None, mime_parser.get_header(HeaderDef::InReplyTo)).await?
{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For some protection, i think this should check is_from_in_chat (will need to be moved to the top level out of ephemeral timer section above) and ignore pinning/unpinning if the message comes from someone who is not a chat member. So someone cannot pin/unpin messages after being removed from the group, most important for channels so subscribers should not be able to pin the messages for the channel creator.

@r10s r10s Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

make sense, thanks a lot for the hint!

i added a commit. i did not move it out of "ephemeral branch", to avoid an additional, potentially expensive, database call on every single received message.

instead, i copied the two statements to the "pinned branch".

i think, that can be refactored at some point, there are already some more of these calculations. but that is out of scope of this PR.

@link2xt i am also wondering if the recently added receive_broadcast_reactions shouldn't have a similar check. but that is as well out of scope of this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

forgot to push these changes this night :) did push now :)

@r10s

r10s commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@link2xt thanks a lot for the detailed review <3

i targeted all comments, the unresolved one has an unrelated question open

@r10s
r10s merged commit 137ac9a into main Aug 7, 2026
30 checks passed
@r10s
r10s deleted the r10s/pinned-messages branch August 7, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add pin message api

2 participants