atagen

macltok

public
Star0
Watch0

Commit 5c749146259c

tarball

atagen <boss@atagen.co>2026-10-25 13:25 UTC

1 file changed+15-2
packs: reply a threaded sticker's fallback to the thread's newest event

Clients without thread support showed every threaded sticker as a reply to the root. The sdk's threaded timeline points the fallback at the latest event in the thread, so stickers now do the same from the root's bundled thread summary.
Modified file: src/engine/packs.rs+15 additions−2 deletions
@@ -389,13 +389,26 @@ async fn send_sticker(
389389 "url": url,
390390 "info": image.get("info").cloned().unwrap_or_else(|| json!({})),
391391 });
392- // the same fallback the send queue gives a threaded attachment with no reply
392+ // clients without threads see a reply to the newest event in the thread, the way the
393+ // sdk's threaded timeline falls back, and the root when that isn't known
393394 if let Some(root) = timeline_id.thread_root() {
395+ let latest = room
396+ .load_or_fetch_event(root, None)
397+ .await
398+ .ok()
399+ .and_then(|event| event.raw().get_field::<JsonValue>("unsigned").ok().flatten())
400+ .and_then(|unsigned| {
401+ unsigned
402+ .pointer("/m.relations/m.thread/latest_event/event_id")
403+ .and_then(JsonValue::as_str)
404+ .map(str::to_owned)
405+ })
406+ .unwrap_or_else(|| root.to_string());
394407 content["m.relates_to"] = json!({
395408 "rel_type": "m.thread",
396409 "event_id": root,
397410 "is_falling_back": true,
398- "m.in_reply_to": { "event_id": root },
411+ "m.in_reply_to": { "event_id": latest },
399412 });
400413 }
401414 room.send_queue()