mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 22:41:12 +01:00
ircd:Ⓜ️ Elaborate presence interface to fetch full event from user's room.
This commit is contained in:
parent
8cf95a6ba0
commit
70f962de4e
3 changed files with 33 additions and 12 deletions
|
@ -37,9 +37,12 @@ struct ircd::m::presence
|
|||
:edu::m_presence
|
||||
{
|
||||
using closure = std::function<void (const json::object &)>;
|
||||
using event_closure = std::function<void (const m::event &, const json::object &)>;
|
||||
|
||||
static bool valid_state(const string_view &state);
|
||||
static void get(const user &, const event_closure &);
|
||||
static void get(const user &, const closure &);
|
||||
static bool get(std::nothrow_t, const user &, const event_closure &);
|
||||
static bool get(std::nothrow_t, const user &, const closure &);
|
||||
static json::object get(const user &, const mutable_buffer &);
|
||||
static event::id::buf set(const presence &);
|
||||
|
|
29
ircd/m/m.cc
29
ircd/m/m.cc
|
@ -812,6 +812,17 @@ ircd::m::presence::get(const user &user,
|
|||
void
|
||||
ircd::m::presence::get(const user &user,
|
||||
const closure &closure)
|
||||
{
|
||||
get(user, [&closure]
|
||||
(const m::event &event, const json::object &content)
|
||||
{
|
||||
closure(content);
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::presence::get(const user &user,
|
||||
const event_closure &closure)
|
||||
{
|
||||
if(!get(std::nothrow, user, closure))
|
||||
throw m::NOT_FOUND
|
||||
|
@ -823,16 +834,28 @@ ircd::m::presence::get(const user &user,
|
|||
bool
|
||||
ircd::m::presence::get(std::nothrow_t,
|
||||
const user &user,
|
||||
const closure &lambda)
|
||||
const closure &closure)
|
||||
{
|
||||
using prototype = bool (std::nothrow_t, const m::user &, const closure &);
|
||||
return get(std::nothrow, user, [&closure]
|
||||
(const m::event &event, const json::object &content)
|
||||
{
|
||||
closure(content);
|
||||
});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::presence::get(std::nothrow_t,
|
||||
const user &user,
|
||||
const event_closure &closure)
|
||||
{
|
||||
using prototype = bool (std::nothrow_t, const m::user &, const event_closure &);
|
||||
|
||||
static import<prototype> function
|
||||
{
|
||||
"client_presence", "m_presence_get"
|
||||
};
|
||||
|
||||
return function(std::nothrow, user, lambda);
|
||||
return function(std::nothrow, user, closure);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -143,22 +143,17 @@ get__presence_list(client &client,
|
|||
extern "C" bool
|
||||
m_presence_get(const std::nothrow_t,
|
||||
const m::user &user,
|
||||
const m::presence::closure &closure)
|
||||
const m::presence::event_closure &closure)
|
||||
{
|
||||
const m::user::room user_room
|
||||
{
|
||||
user
|
||||
};
|
||||
|
||||
return user_room.get(std::nothrow, "m.presence", "", [&closure]
|
||||
return user_room.get(std::nothrow, "ircd.presence", "", [&closure]
|
||||
(const m::event &event)
|
||||
{
|
||||
const auto &content
|
||||
{
|
||||
at<"content"_>(event)
|
||||
};
|
||||
|
||||
closure(content);
|
||||
closure(event, json::get<"content"_>(event));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -367,5 +362,5 @@ commit__m_presence(const m::presence &content)
|
|||
};
|
||||
|
||||
//TODO: ABA
|
||||
return send(user_room, user.user_id, "m.presence", "", json::strung{content});
|
||||
return send(user_room, user.user_id, "ircd.presence", "", json::strung{content});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue