0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

modules/m_receipt: Move m.receipt committer into client/

This commit is contained in:
Jason Volk 2018-03-28 19:47:41 -07:00
parent 53d7e79c41
commit cbc4852e16
3 changed files with 52 additions and 47 deletions

View file

@ -699,7 +699,7 @@ ircd::m::receipt::read(const id::room &room_id,
static import<prototype> function
{
"m_receipt", "receipt_m_read"
"client_rooms", "commit__m_receipt_m_read"
};
return function(room_id, user_id, event_id, ms);

View file

@ -12,6 +12,12 @@
using namespace ircd;
extern "C" m::event::id::buf
commit__m_receipt_m_read(const m::room::id &,
const m::user::id &,
const m::event::id &,
const time_t &);
resource::response
post__receipt(client &client,
const resource::request &request,
@ -44,3 +50,48 @@ post__receipt(client &client,
client, http::OK
};
}
m::event::id::buf
commit__m_receipt_m_read(const m::room::id &room_id,
const m::user::id &user_id,
const m::event::id &event_id,
const time_t &ms)
{
const json::value event_ids[]
{
{ event_id }
};
const json::members m_read
{
{ "data",
{
{ "ts", ms }
}},
{ "event_ids", { event_ids, 1 } },
};
json::iov event, content;
const json::iov::push push[]
{
{ event, { "type", "m.receipt" } },
{ event, { "room_id", room_id } },
{ content, { room_id,
{
{ "m.read",
{
{ user_id, m_read }
}}
}}}
};
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);
}

View file

@ -21,52 +21,6 @@ static void handle_m_receipt_m_read(const m::room::id &, const m::user::id &, co
static void handle_m_receipt_m_read(const m::room::id &, const json::object &);
static void handle_m_receipt(const m::room::id &, const json::object &);
static void handle_edu_m_receipt(const m::event &);
extern "C" m::event::id::buf receipt_m_read(const m::room::id &, const m::user::id &, const m::event::id &, const time_t &);
m::event::id::buf
receipt_m_read(const m::room::id &room_id,
const m::user::id &user_id,
const m::event::id &event_id,
const time_t &ms)
{
const json::value event_ids[]
{
{ event_id }
};
const json::members m_read
{
{ "data",
{
{ "ts", ms }
}},
{ "event_ids", { event_ids, 1 } },
};
json::iov event, content;
const json::iov::push push[]
{
{ event, { "type", "m.receipt" } },
{ event, { "room_id", room_id } },
{ content, { room_id,
{
{ "m.read",
{
{ user_id, m_read }
}}
}}}
};
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_receipt_eval