feat: Resend the last 10 messages to new broadcast member (#7678)#7854
feat: Resend the last 10 messages to new broadcast member (#7678)#7854
Conversation
324b160 to
d7b3549
Compare
src/message.rs
Outdated
| /// 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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
124e431 to
3f93c9e
Compare
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.
3f93c9e to
e25a1e3
Compare
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