Skip to content

feat: Resend the last 10 messages to new broadcast member (#7678)#7854

Open
iequidoo wants to merge 1 commit intomainfrom
iequidoo/resend-last-broadcast-msgs
Open

feat: Resend the last 10 messages to new broadcast member (#7678)#7854
iequidoo wants to merge 1 commit intomainfrom
iequidoo/resend-last-broadcast-msgs

Conversation

@iequidoo
Copy link
Collaborator

Messages are sent and encrypted only to the new member. This way we at least postpone spreading the information that the new member joined: even if the server operator is a broadcast member, they can't know that immediately.

Close #7678

@iequidoo iequidoo force-pushed the iequidoo/resend-last-broadcast-msgs branch from 324b160 to d7b3549 Compare February 12, 2026 07:25
src/message.rs Outdated
Comment on lines +411 to +413
/// Actual Message ID, if set. This is to avoid updating the `msgs` row, in which case `id` is
/// fake (`u32::MAX`);
pub(crate) row_id: MsgId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to avoid updating the msgs row when resending? And, can we just add a parameter to create_send_msg_jobs() for this, rather than a new field on an often-used struct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think if messages are re-sent automatically, the owner doesn't want to see spinners on messages being re-sent (which means that for big channels the owner will see spinners most of the time). Also the message sending logic is complicated, it can update message params such as GuaranteeE2ee, i just don't even want to think which columns may be changed by resending, whether resending works for messages already being re-sent at the moment, etc.

This row_id is used only for auto-resending. For manual resending nothing changes. Adding a parameter to create_send_msg_jobs() won't simplify the code, and it may be forgotten to be checked where necessary.

Copy link
Collaborator Author

@iequidoo iequidoo Feb 26, 2026

Choose a reason for hiding this comment

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

However, we still can make Message.id fake to avoid updating the message and add row_id as a function parameter, i'll try... DONE

src/chat.rs Outdated
/// Chat message list request options.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct MessageListOptions {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be worth it to use a specific SQL query that gets the last 10 non-info messages in a chat, rather than using get_chat_msgs_ex(). But I didn't try out how this would actually look in the code - it would probably be more changed lines and a small bit of code repetition, but the added complexity would be more self-contained. So, just an idea, idk if it would be worth it.

Copy link
Collaborator Author

@iequidoo iequidoo Feb 26, 2026

Choose a reason for hiding this comment

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

The function grew by 10 lines, most of the logic is reused for the new case and the message filter already was here, just the 3rd variant appeared. I think the worst thing is this construction needed on the caller side now:

                filter: match info_only {
                    true => ChatMsgsFilter::Info,
                    false => ChatMsgsFilter::All,
                },

Maybe this should be improved somehow, but having only one function is fine i think. EDIT: Added ChatMsgsFilter::info_only() for this.

) {
Some(Err(format_err!("Missing removed/added member")))
} else {
None
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do think we should check whether this is a SystemMessage::MemberRemovedFromGroup | SystemMessage::MemberAddedToGroup, and only then return Param::Arg4. Otherwise, this code may silently become incorrect if someone adds another meaning to Arg4 (not that the multiple meanings of Arg* params are great, but we can solve that at another time)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed this because i now also use Arg4 when resending messages in broadcasts to encrypt them only to the new member. There's still the chat.typ != Chattype::OutBroadcast check that protects from using Arg4 for other chat types

@adbenitez

This comment was marked as resolved.

@iequidoo

This comment was marked as resolved.

@iequidoo iequidoo force-pushed the iequidoo/resend-last-broadcast-msgs branch 2 times, most recently from 124e431 to 3f93c9e Compare February 26, 2026 15:42
Messages are sent and encrypted only to the new member. This way we at least postpone spreading the
information that the new member joined: even if the server operator is a broadcast member, they
can't know that immediately.
@iequidoo iequidoo force-pushed the iequidoo/resend-last-broadcast-msgs branch from 3f93c9e to e25a1e3 Compare February 26, 2026 17:13
@iequidoo iequidoo requested a review from Hocuri February 26, 2026 17:14
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.

channels: resend the last 10 messages on joining

3 participants