mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd:Ⓜ️ Add membership prefetch suite.
This commit is contained in:
parent
9abc78a121
commit
df6d463623
1 changed files with 26 additions and 0 deletions
|
@ -41,12 +41,38 @@ namespace ircd::m
|
|||
bool membership(const event::idx &, const vector_view<const string_view> &);
|
||||
bool membership(const room &, const id::user &, const vector_view<const string_view> &);
|
||||
|
||||
// Prefetch suite
|
||||
bool membership_prefetch(const event::idx &);
|
||||
bool membership_prefetch(const room::state &, const id::user &);
|
||||
|
||||
// Convenience definitions of membership states for atomic queries.
|
||||
extern const std::initializer_list<const string_view>
|
||||
membership_positive, // join, invite
|
||||
membership_negative; // leave, ban, knock, [non-membership]
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::m::membership_prefetch(const room::state &state,
|
||||
const user::id &user_id)
|
||||
{
|
||||
if(state.prefetch("m.room.member", user_id))
|
||||
return true;
|
||||
|
||||
// The above prefetch didn't launch; this query is cached.
|
||||
const auto event_idx
|
||||
{
|
||||
state.get(std::nothrow, "m.room.member", user_id)
|
||||
};
|
||||
|
||||
return membership_prefetch(event_idx);
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::m::membership_prefetch(const event::idx &event_idx)
|
||||
{
|
||||
return m::prefetch(event_idx, "content");
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::m::membership(const room &room,
|
||||
const id::user &user_id,
|
||||
|
|
Loading…
Reference in a new issue