mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 11:18:51 +02:00
ircd:Ⓜ️ Add preliminary skeleton linkage for room/event visibilty related.
This commit is contained in:
parent
34d1abb062
commit
eb5f2475a3
4 changed files with 85 additions and 0 deletions
|
@ -27,6 +27,10 @@ namespace ircd::m
|
||||||
bool exists(const id::event &);
|
bool exists(const id::event &);
|
||||||
bool bad(const id::event &, uint64_t &);
|
bool bad(const id::event &, uint64_t &);
|
||||||
bool bad(const id::event &);
|
bool bad(const id::event &);
|
||||||
|
bool visible(const event &, const id::user &);
|
||||||
|
bool visible(const event &, const id::node &);
|
||||||
|
bool visible(const id::event &, const id::user &);
|
||||||
|
bool visible(const id::event &, const id::node &);
|
||||||
|
|
||||||
// Depth comparison; expect unstable sorting.
|
// Depth comparison; expect unstable sorting.
|
||||||
bool operator<(const event &, const event &);
|
bool operator<(const event &, const event &);
|
||||||
|
|
|
@ -144,6 +144,8 @@ struct ircd::m::room
|
||||||
// misc
|
// misc
|
||||||
bool membership(const m::id::user &, const string_view &membership = "join") const;
|
bool membership(const m::id::user &, const string_view &membership = "join") const;
|
||||||
string_view membership(const mutable_buffer &out, const m::id::user &) const;
|
string_view membership(const mutable_buffer &out, const m::id::user &) const;
|
||||||
|
bool visible(const id::user &) const;
|
||||||
|
bool visible(const id::node &) const;
|
||||||
|
|
||||||
room(const id &room_id, const string_view &event_id, const vm::copts *const &opts = nullptr)
|
room(const id &room_id, const string_view &event_id, const vm::copts *const &opts = nullptr)
|
||||||
:room_id{room_id}
|
:room_id{room_id}
|
||||||
|
|
65
ircd/m/m.cc
65
ircd/m/m.cc
|
@ -2731,6 +2731,71 @@ ircd::m::exists(const id::room_alias &room_alias,
|
||||||
return function(room_alias, remote_query);
|
return function(room_alias, remote_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// m/event.h
|
||||||
|
//
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::visible(const event::id &event_id,
|
||||||
|
const node::id &origin)
|
||||||
|
{
|
||||||
|
m::room::id::buf room_id
|
||||||
|
{
|
||||||
|
get(event_id, "room_id", room_id)
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::event event
|
||||||
|
{
|
||||||
|
{ "event_id", event_id },
|
||||||
|
{ "room_id", room_id }
|
||||||
|
};
|
||||||
|
|
||||||
|
return visible(event, origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::visible(const event::id &event_id,
|
||||||
|
const user::id &user_id)
|
||||||
|
{
|
||||||
|
m::room::id::buf room_id
|
||||||
|
{
|
||||||
|
get(event_id, "room_id", room_id)
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::event event
|
||||||
|
{
|
||||||
|
{ "event_id", event_id },
|
||||||
|
{ "room_id", room_id }
|
||||||
|
};
|
||||||
|
|
||||||
|
return visible(event, user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::visible(const event &event,
|
||||||
|
const node::id &origin)
|
||||||
|
{
|
||||||
|
const m::room room
|
||||||
|
{
|
||||||
|
at<"room_id"_>(event), at<"event_id"_>(event)
|
||||||
|
};
|
||||||
|
|
||||||
|
return room.visible(origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::visible(const event &event,
|
||||||
|
const user::id &user_id)
|
||||||
|
{
|
||||||
|
const m::room room
|
||||||
|
{
|
||||||
|
at<"room_id"_>(event), at<"event_id"_>(event)
|
||||||
|
};
|
||||||
|
|
||||||
|
return room.visible(user_id);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// m/txn.h
|
// m/txn.h
|
||||||
|
|
|
@ -161,6 +161,20 @@ ircd::m::my(const room &room)
|
||||||
// room
|
// room
|
||||||
//
|
//
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::room::visible(const m::user::id &user_id)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::room::visible(const m::node::id &origin)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::m::room::membership(const m::id::user &user_id,
|
ircd::m::room::membership(const m::id::user &user_id,
|
||||||
const string_view &membership)
|
const string_view &membership)
|
||||||
|
|
Loading…
Reference in a new issue