feat: pinned messages - #8546
Conversation
f7077bc to
82f7780
Compare
7c79b2b to
3c35e65
Compare
dbe718a to
4c170ed
Compare
4c170ed to
fa24393
Compare
| || mime_parser.is_system_message == SystemMessage::MessageUnpinned) | ||
| && let Some(msg_to_change) = | ||
| get_parent_message(context, None, mime_parser.get_header(HeaderDef::InReplyTo)).await? | ||
| { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
forgot to push these changes this night :) did push now :)
Co-authored-by: l <link2xt@testrun.org>
…e_pinned_state_from_wire()
|
@link2xt thanks a lot for the detailed review <3 i targeted all comments, the unresolved one has an unrelated question open |
this PR adds a "pinned messages API", that will allow UIs to offer the typical things of pinned messages:
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 carriesChat-Content: message-pinnedresp.Chat-Content: message-unpinnedheader. 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
pinnedAPI 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 objectslater, 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