0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-13 16:33:53 +01:00

modules/m_presence: Move some externs from client/presence; update linkages.

This commit is contained in:
Jason Volk 2018-05-28 01:31:45 -07:00
parent 54f08c0351
commit 2ba495eb8b
3 changed files with 50 additions and 40 deletions

View file

@ -1140,7 +1140,7 @@ ircd::m::presence::set(const presence &object)
static import<prototype> function
{
"client_presence", "commit__m_presence"
"m_presence", "commit__m_presence"
};
return function(object);
@ -1204,7 +1204,7 @@ ircd::m::presence::get(std::nothrow_t,
static import<prototype> function
{
"client_presence", "m_presence_get"
"m_presence", "get__m_presence"
};
return function(std::nothrow, user, closure);

View file

@ -140,23 +140,6 @@ get__presence_list(client &client,
};
}
extern "C" bool
m_presence_get(const std::nothrow_t,
const m::user &user,
const m::presence::event_closure &closure)
{
const m::user::room user_room
{
user
};
return user_room.get(std::nothrow, "ircd.presence", "", [&closure]
(const m::event &event)
{
closure(event, json::get<"content"_>(event));
});
}
//
// POST ?
//
@ -344,27 +327,6 @@ put__presence_status(client &client,
};
}
extern "C" m::event::id::buf
commit__m_presence(const m::presence &content)
{
const m::user user
{
at<"user_id"_>(content)
};
//TODO: ABA
if(!exists(user))
create(user.user_id);
const m::user::room user_room
{
user
};
//TODO: ABA
return send(user_room, user.user_id, "ircd.presence", "", json::strung{content});
}
static void
handle_my_presence_changed(const m::event &event)
{

View file

@ -155,3 +155,51 @@ catch(const m::error &e)
e.content
};
}
extern "C" bool
get__m_presence(const std::nothrow_t,
const m::user &user,
const m::presence::event_closure &closure)
{
static const m::event::fetch::opts fopts
{
m::event::keys::include
{
"event_id",
"content",
"origin_server_ts",
}
};
const m::user::room user_room
{
user, nullptr, &fopts
};
return user_room.get(std::nothrow, "ircd.presence", "", [&closure]
(const m::event &event)
{
closure(event, json::get<"content"_>(event));
});
}
extern "C" m::event::id::buf
commit__m_presence(const m::presence &content)
{
const m::user user
{
at<"user_id"_>(content)
};
//TODO: ABA
if(!exists(user))
create(user.user_id);
const m::user::room user_room
{
user
};
//TODO: ABA
return send(user_room, user.user_id, "ircd.presence", "", json::strung{content});
}