0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd:Ⓜ️🧾 Implement matrix-org/matrix-doc#2285 Hidden read receipts.

This commit is contained in:
Jason Volk 2019-09-06 11:51:45 -07:00
parent 6a59036f4e
commit e842f6c383
2 changed files with 10 additions and 8 deletions

View file

@ -502,7 +502,8 @@ command__read(const mutable_buffer &buf,
// Commit the receipt.
m::receipt::read(room_id, user, event_id, json::strung{json::members
{
{ "ts", ms },
{ "ts", ms },
{ "m.hidden", true },
}});
put(room_id, event_id);

View file

@ -253,17 +253,13 @@ ircd::m::receipt::read(const m::room::id &room_id,
user_id
};
const time_t &ms
{
options.get("ts", ircd::time<milliseconds>())
};
const auto evid
{
send(user_room, user_id, "ircd.read", room_id,
{
{ "event_id", event_id },
{ "ts", ms }
{ "event_id", event_id },
{ "ts", options.get("ts", ircd::time<milliseconds>()) },
{ "m.hidden", options.get("m.hidden", false) },
})
};
@ -547,6 +543,11 @@ try
at<"content"_>(event).at("event_id")
};
// MSC2285; if m.hidden is set here we don't broadcast this receipt
// to the federation; nothing further to do here then.
if(at<"content"_>(event).get("m.hidden", false))
return;
// Lastly, we elide broadcasts of receipts for a user's own message.
m::user::id::buf sender_buf;
if(m::get(std::nothrow, event_id, "sender", sender_buf) == user.user_id)