0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 19:28:52 +02:00

ircd:Ⓜ️ Move typing commitment to modules/m_typing; central interface/linkage.

This commit is contained in:
Jason Volk 2018-03-14 16:24:58 -07:00
parent 56b23af467
commit bda7836ebe
4 changed files with 58 additions and 17 deletions

View file

@ -13,7 +13,7 @@
namespace ircd::m
{
struct typing;
}
#pragma GCC diagnostic push
@ -30,3 +30,11 @@ struct ircd::m::edu::m_typing
using super_type::operator=;
};
#pragma GCC diagnostic pop
struct ircd::m::typing
:m::edu::m_typing
{
static event::id::buf set(const typing &);
using edu::m_typing::m_typing;
};

View file

@ -525,6 +525,25 @@ ircd::m::keys::init::signing()
self::public_key_b64);
}
///////////////////////////////////////////////////////////////////////////////
//
// m/typing.h
//
ircd::m::event::id::buf
ircd::m::typing::set(const m::typing &object)
{
using prototype = event::id::buf (const m::typing &);
static import<prototype> function
{
"m_typing", "typing_set"
};
return function(object);
}
///////////////////////////////////////////////////////////////////////////////
//
// m/presence.h

View file

@ -43,25 +43,14 @@ put__typing(client &client,
request.at<bool>("typing")
};
json::iov event, content;
const json::iov::push push[]
const m::edu::m_typing event
{
{ event, { "type", "m.typing" } },
{ event, { "room_id", room_id } },
{ content, { "user_id", request.user_id } },
{ content, { "room_id", room_id } },
{ content, { "typing", typing } },
{ "user_id", request.user_id },
{ "room_id", room_id },
{ "typing", typing },
};
m::vm::opts opts;
opts.hash = false;
opts.sign = false;
opts.event_id = false;
opts.origin = true;
opts.origin_server_ts = false;
opts.conforming = false;
m::vm::commit(event, content, opts);
m::typing::set(event);
log::debug
{

View file

@ -18,6 +18,31 @@ IRCD_MODULE
static void _handle_edu_m_typing(const m::event &, const m::edu::m_typing &edu);
static void handle_edu_m_typing(const m::event &);
extern "C" m::event::id::buf typing_set(const m::typing &);
m::event::id::buf
typing_set(const m::typing &edu)
{
json::iov event, content;
const json::iov::push push[]
{
{ event, { "type", "m.typing" } },
{ event, { "room_id", at<"room_id"_>(edu) } },
{ content, { "user_id", at<"user_id"_>(edu) } },
{ content, { "room_id", at<"room_id"_>(edu) } },
{ content, { "typing", json::get<"typing"_>(edu) } },
};
m::vm::opts opts;
opts.hash = false;
opts.sign = false;
opts.event_id = false;
opts.origin = true;
opts.origin_server_ts = false;
opts.conforming = false;
return m::vm::commit(event, content, opts);
}
const m::hook
_m_typing_eval