mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
modules/client/sync/rooms: Support ignoring invites based on m.ignored_user_list.
This commit is contained in:
parent
47a5486258
commit
11afd2e590
1 changed files with 43 additions and 0 deletions
|
@ -16,6 +16,8 @@ IRCD_MODULE
|
|||
|
||||
namespace ircd::m::sync
|
||||
{
|
||||
static bool should_ignore(const data &);
|
||||
|
||||
static bool _rooms_polylog_room(data &, const m::room &);
|
||||
static bool _rooms_polylog(data &, const string_view &membership);
|
||||
static bool rooms_polylog(data &);
|
||||
|
@ -63,6 +65,9 @@ ircd::m::sync::rooms_linear(data &data)
|
|||
data.membership, membership
|
||||
};
|
||||
|
||||
if(should_ignore(data))
|
||||
return false;
|
||||
|
||||
return !m::sync::for_each("rooms", [&data]
|
||||
(item &item)
|
||||
{
|
||||
|
@ -146,6 +151,9 @@ ircd::m::sync::_rooms_polylog_room(data &data,
|
|||
data.room, &room
|
||||
};
|
||||
|
||||
if(should_ignore(data))
|
||||
return false;
|
||||
|
||||
json::stack::checkpoint checkpoint
|
||||
{
|
||||
*data.out
|
||||
|
@ -193,3 +201,38 @@ ircd::m::sync::_rooms_polylog_room(data &data,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::sync::should_ignore(const data &data)
|
||||
{
|
||||
if(data.membership != "invite")
|
||||
return false;
|
||||
|
||||
if(!m::user::ignores::enforce("invites"))
|
||||
return false;
|
||||
|
||||
assert(data.room);
|
||||
const m::room::state state
|
||||
{
|
||||
*data.room
|
||||
};
|
||||
|
||||
const m::event::idx &event_idx
|
||||
{
|
||||
state.get(std::nothrow, "m.room.member", data.user.user_id)
|
||||
};
|
||||
|
||||
const m::user::ignores ignores
|
||||
{
|
||||
data.user.user_id
|
||||
};
|
||||
|
||||
bool ret{false};
|
||||
m::get(std::nothrow, event_idx, "sender", [&ignores, &ret]
|
||||
(const m::user::id &sender)
|
||||
{
|
||||
ret = ignores.has(sender);
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue