feat: Resend the last 10 messages to new broadcast member#8151
Merged
Conversation
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.
Setting the msg_id to `u32::MAX` is hacky, and may just as well break things as it may fix things, because some code may use the msg.id to load information from the database, like `get_iroh_topic_for_msg()`. From reading the code, I couldn't find any problem with leaving the correct `msg_id`, and if there is one, then we should add a function parameter `is_resending` that is checked in the corresponding places.
Hocuri
commented
Apr 21, 2026
| info_only, | ||
| add_daymarker, | ||
| } = options; | ||
| // TODO: Remove `info_only` parameter; it's not used by anything |
Collaborator
Author
There was a problem hiding this comment.
Let's do this in a follow-up PR
adbenitez
approved these changes
Apr 21, 2026
r10s
approved these changes
Apr 21, 2026
Comment on lines
+4779
to
+4780
| // The event only matters if the message is last in the chat. | ||
| // But it's probably too expensive check, and UIs anyways need to debounce. |
Contributor
There was a problem hiding this comment.
in practise, resent messages always belong to the same chat, in a channel, but also when resend manually by selecting in the UI
we can also move the event out of the loop, and document that all messages shall belong to the same chat
but i am also fine to leave things as is
Collaborator
Author
There was a problem hiding this comment.
This could be fixed in this way:
diff --git a/src/chat.rs b/src/chat.rs
index 966a041ca..1b6440720 100644
--- a/src/chat.rs
+++ b/src/chat.rs
@@ -4747,6 +4747,9 @@ pub(crate) async fn resend_msgs_ex(
msgs.push(msg)
}
+ let mut chat_ids: Vec<ChatId> = msgs.iter().map(|m| m.chat_id).collect();
+ chat_ids.dedup();
+
for mut msg in msgs {
match msg.get_state() {
// `get_state()` may return an outdated `OutPending`, so update anyway.
@@ -4776,9 +4779,6 @@ pub(crate) async fn resend_msgs_ex(
chat_id: msg.chat_id,
msg_id: msg.id,
});
- // The event only matters if the message is last in the chat.
- // But it's probably too expensive check, and UIs anyways need to debounce.
- chatlist_events::emit_chatlist_item_changed(context, msg.chat_id);
if msg.viewtype == Viewtype::Webxdc {
let conn_fn = |conn: &mut rusqlite::Connection| {
@@ -4811,6 +4811,11 @@ pub(crate) async fn resend_msgs_ex(
}
context.scheduler.interrupt_smtp().await;
}
+ for chat_id in chat_ids {
+ // The event only matters if the message is last in the chat.
+ // But it's probably too expensive check, and UIs anyways need to debounce.
+ chatlist_events::emit_chatlist_item_changed(context, chat_id);
+ }
Ok(())
}but is unrelated to the PR here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #7854, with the following changes:
get_chat_msgs()functionmsg_idin resent messages e7d0687Setting the msg_id to
u32::MAXis hacky, and may just as well breakthings as it may fix things, because some code may use the msg.id to
load information from the database, like
get_iroh_topic_for_msg().From reading the code, I couldn't find any problem with leaving the
correct
msg_id, and if there is one, then we should add a functionparameter
is_resendingthat is checked in the corresponding places.Easiest to review file-by-file rather than individual commits, probably. I'll squash-merge this.