Commit 5c749146259c
tarball1 file changed+15-2
@@ -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 reply392
+ // clients without threads see a reply to the newest event in the thread, the way the393
+ // sdk's threaded timeline falls back, and the root when that isn't known393394
if let Some(root) = timeline_id.thread_root() {395
+ let latest = room396
+ .load_or_fetch_event(root, None)397
+ .await398
+ .ok()399
+ .and_then(|event| event.raw().get_field::<JsonValue>("unsigned").ok().flatten())400
+ .and_then(|unsigned| {401
+ unsigned402
+ .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()