From cbc4852e164032f94c71376df5bdb8e086b36ac8 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 28 Mar 2018 19:47:41 -0700 Subject: [PATCH] modules/m_receipt: Move m.receipt committer into client/ --- ircd/m/m.cc | 2 +- modules/client/rooms/receipt.cc | 51 +++++++++++++++++++++++++++++++++ modules/m_receipt.cc | 46 ----------------------------- 3 files changed, 52 insertions(+), 47 deletions(-) diff --git a/ircd/m/m.cc b/ircd/m/m.cc index 3c1ba5b04..21cadc8b8 100644 --- a/ircd/m/m.cc +++ b/ircd/m/m.cc @@ -699,7 +699,7 @@ ircd::m::receipt::read(const id::room &room_id, static import function { - "m_receipt", "receipt_m_read" + "client_rooms", "commit__m_receipt_m_read" }; return function(room_id, user_id, event_id, ms); diff --git a/modules/client/rooms/receipt.cc b/modules/client/rooms/receipt.cc index cd1ff0bbc..3df6e256f 100644 --- a/modules/client/rooms/receipt.cc +++ b/modules/client/rooms/receipt.cc @@ -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); +} diff --git a/modules/m_receipt.cc b/modules/m_receipt.cc index ad67a8d7e..d21b03656 100644 --- a/modules/m_receipt.cc +++ b/modules/m_receipt.cc @@ -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