Skip to content

Commit

Permalink
ircd::m::receipt: Implement matrix-org/matrix-spec-proposals#2285 Hid…
Browse files Browse the repository at this point in the history
…den read receipts.
  • Loading branch information
jevolk committed Sep 6, 2019
1 parent 6a59036 commit 5bf200b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion modules/m_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 8 additions & 3 deletions modules/m_receipt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ ircd::m::receipt::read(const m::room::id &room_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) },
})
};

Expand Down Expand Up @@ -547,6 +547,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)
Expand Down

0 comments on commit 5bf200b

Please sign in to comment.