mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
ircd:Ⓜ️ Rework visibility interface for empty mxid's as part of a public test.
This commit is contained in:
parent
5d471b51b8
commit
6671122997
5 changed files with 17 additions and 73 deletions
|
@ -145,8 +145,7 @@ struct ircd::m::room
|
|||
// misc
|
||||
bool membership(const m::id::user &, const string_view &membership = "join") const;
|
||||
string_view membership(const mutable_buffer &out, const m::id::user &) const;
|
||||
bool visible(const id::user &, const m::event *const & = nullptr) const;
|
||||
bool visible(const id::node &, const m::event *const & = nullptr) const;
|
||||
bool visible(const string_view &mxid, const m::event *const & = nullptr) const;
|
||||
|
||||
room(const id &room_id,
|
||||
const string_view &event_id,
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
|
||||
namespace ircd::m
|
||||
{
|
||||
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 &);
|
||||
// The mxid argument is a string_view because it may be empty when no
|
||||
// authentication is supplied (m::id cannot be empty because that's
|
||||
// considered an invalid mxid). In that case the test is for public vis.
|
||||
bool visible(const event &, const string_view &mxid);
|
||||
bool visible(const id::event &, const string_view &mxid);
|
||||
}
|
||||
|
|
44
ircd/m/m.cc
44
ircd/m/m.cc
|
@ -931,7 +931,7 @@ ircd::m::keys::init::signing()
|
|||
|
||||
bool
|
||||
ircd::m::visible(const event::id &event_id,
|
||||
const node::id &origin)
|
||||
const string_view &mxid)
|
||||
{
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
|
@ -944,53 +944,21 @@ ircd::m::visible(const 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);
|
||||
return visible(event, mxid);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::visible(const event &event,
|
||||
const node::id &origin)
|
||||
const string_view &mxid)
|
||||
{
|
||||
using prototype = bool (const m::event &, const node &);
|
||||
using prototype = bool (const m::event &, const string_view &);
|
||||
|
||||
static import<prototype> function
|
||||
{
|
||||
"m_room_history_visibility", "visible__node"
|
||||
"m_room_history_visibility", "visible"
|
||||
};
|
||||
|
||||
return function(event, origin);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::visible(const event &event,
|
||||
const user::id &user_id)
|
||||
{
|
||||
using prototype = bool (const m::event &, const user &);
|
||||
|
||||
static import<prototype> function
|
||||
{
|
||||
"m_room_history_visibility", "visible__user"
|
||||
};
|
||||
|
||||
return function(event, user_id);
|
||||
return function(event, mxid);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -162,12 +162,12 @@ ircd::m::my(const room &room)
|
|||
//
|
||||
|
||||
bool
|
||||
ircd::m::room::visible(const user::id &user_id,
|
||||
ircd::m::room::visible(const string_view &mxid,
|
||||
const event *const &event)
|
||||
const
|
||||
{
|
||||
if(event)
|
||||
return m::visible(*event, user_id);
|
||||
return m::visible(*event, mxid);
|
||||
|
||||
const m::event event_
|
||||
{
|
||||
|
@ -175,24 +175,7 @@ const
|
|||
{ "room_id", room_id },
|
||||
};
|
||||
|
||||
return m::visible(event_, user_id);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::visible(const node::id &node_id,
|
||||
const event *const &event)
|
||||
const
|
||||
{
|
||||
if(event)
|
||||
return m::visible(*event, node_id);
|
||||
|
||||
const m::event event_
|
||||
{
|
||||
{ "event_id", event_id },
|
||||
{ "room_id", room_id },
|
||||
};
|
||||
|
||||
return m::visible(event_, node_id);
|
||||
return m::visible(event_, mxid);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -28,15 +28,8 @@ ircd::m::visible_hook
|
|||
};
|
||||
|
||||
extern "C" bool
|
||||
visible__user(const m::event &event,
|
||||
const m::user &user)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
visible__node(const m::event &event,
|
||||
const m::node &node)
|
||||
visible(const m::event &event,
|
||||
const string_view &mxid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue