mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 16:33:53 +01:00
modules/client/rooms/receipt: Add feature to not send read receipts to certain users.
This commit is contained in:
parent
05147794c8
commit
9a697783a9
2 changed files with 66 additions and 0 deletions
|
@ -80,6 +80,27 @@ commit__m_receipt_m_read(const m::room::id &room_id,
|
|||
user_id
|
||||
};
|
||||
|
||||
bool ignored{false};
|
||||
m::get(std::nothrow, event_id, "sender", [&ignored, &user_room]
|
||||
(const string_view &sender)
|
||||
{
|
||||
ignored = user_room.has("ircd.read.ignore", sender);
|
||||
});
|
||||
|
||||
if(ignored)
|
||||
{
|
||||
log::debug
|
||||
{
|
||||
"no receipt for %s by %s in %s @ %zd (ircd.read.ignore)",
|
||||
string_view{event_id},
|
||||
string_view{user_id},
|
||||
string_view{room_id},
|
||||
ms
|
||||
};
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto evid
|
||||
{
|
||||
send(user_room, user_id, "ircd.read", room_id,
|
||||
|
|
|
@ -4647,6 +4647,51 @@ console_cmd__user__read(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__user__read__ignore(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"my_user_id", "target_user_id"
|
||||
}};
|
||||
|
||||
const m::user my_user
|
||||
{
|
||||
param.at(0)
|
||||
};
|
||||
|
||||
const m::user::id target_user
|
||||
{
|
||||
param.at(1)
|
||||
};
|
||||
|
||||
const m::user::room user_room
|
||||
{
|
||||
my_user
|
||||
};
|
||||
|
||||
if(user_room.has("ircd.read.ignore", target_user))
|
||||
{
|
||||
out << "User " << my_user.user_id << " is already not sending"
|
||||
<< " receipts for messages from user " << target_user
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto eid
|
||||
{
|
||||
send(user_room, m::me.user_id, "ircd.read.ignore", target_user, json::object{})
|
||||
};
|
||||
|
||||
out << "User " << my_user.user_id << " will not send receipts for"
|
||||
<< " messages from user " << target_user
|
||||
<< " (" << eid << ")"
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__user__filter(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue