0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd:Ⓜ️ Reorg event visibility interface; update linkages.

This commit is contained in:
Jason Volk 2018-05-27 22:34:54 -07:00
parent 84c57addba
commit 9714d1ee15
4 changed files with 107 additions and 81 deletions

20
include/ircd/m/visible.h Normal file
View file

@ -0,0 +1,20 @@
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_M_VISIBLE_H
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 &);
}

View file

@ -990,6 +990,75 @@ ircd::m::keys::init::signing()
self::public_key_b64);
}
///////////////////////////////////////////////////////////////////////////////
//
// m/visible.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)
{
using prototype = bool (const m::event &, const node &);
static import<prototype> function
{
"m_room_history_visibility", "visible__node"
};
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);
}
///////////////////////////////////////////////////////////////////////////////
//
// m/receipt.h
@ -2777,71 +2846,6 @@ ircd::m::exists(const id::room_alias &room_alias,
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, &event);
}
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, &event);
}
///////////////////////////////////////////////////////////////////////////////
//
// m/txn.h

View file

@ -163,32 +163,36 @@ ircd::m::my(const room &room)
bool
ircd::m::room::visible(const user::id &user_id,
const event *const &event_)
const event *const &event)
const
{
using prototype = bool (const room &, const user &, const event *const &);
if(event)
return m::visible(*event, user_id);
static import<prototype> function
const m::event event_
{
"m_room_history_visibility", "visible__user"
{ "event_id", event_id },
{ "room_id", room_id },
};
return function(*this, user_id, event_);
return m::visible(event_, user_id);
}
bool
ircd::m::room::visible(const node::id &node_id,
const event *const &event_)
const event *const &event)
const
{
using prototype = bool (const room &, const node &, const event *const &);
if(event)
return m::visible(*event, node_id);
static import<prototype> function
const m::event event_
{
"m_room_history_visibility", "visible__node"
{ "event_id", event_id },
{ "room_id", room_id },
};
return function(*this, node_id, event_);
return m::visible(event_, node_id);
}
bool

View file

@ -28,17 +28,15 @@ ircd::m::visible_hook
};
extern "C" bool
visible__user(const m::room &room,
const m::user &user,
const m::event *const &event)
visible__user(const m::event &event,
const m::user &user)
{
return true;
}
extern "C" bool
visible__node(const m::room &room,
const m::node &node,
const m::event *const &event)
visible__node(const m::event &event,
const m::node &node)
{
return true;
}