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 e842f6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 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
15 changes: 8 additions & 7 deletions modules/m_receipt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
})
};

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e842f6c

Please sign in to comment.