0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-14 16:46:50 +01:00

modules/m_receipt: Additional hook conditions; switch the hooksite; minor cleanup.

This commit is contained in:
Jason Volk 2019-03-28 14:31:24 -07:00
parent 31f1e28c24
commit a889122dcc

View file

@ -34,7 +34,7 @@ _m_receipt_eval
{ {
handle_edu_m_receipt, handle_edu_m_receipt,
{ {
{ "_site", "vm.eval" }, { "_site", "vm.effect" },
{ "type", "m.receipt" }, { "type", "m.receipt" },
} }
}; };
@ -46,6 +46,9 @@ handle_edu_m_receipt(const m::event &event,
if(json::get<"room_id"_>(event)) if(json::get<"room_id"_>(event))
return; return;
if(my_host(json::get<"origin"_>(event)))
return;
const json::object &content const json::object &content
{ {
at<"content"_>(event) at<"content"_>(event)
@ -144,6 +147,10 @@ try
user_id user_id
}; };
// This handler only cares about remote users.
if(my(user))
return;
if(!exists(user)) if(!exists(user))
{ {
log::dwarning log::dwarning
@ -157,7 +164,10 @@ try
return; return;
} }
m::receipt::read(room_id, user_id, event_id, ts); const auto evid
{
m::receipt::read(room_id, user_id, event_id, ts)
};
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
@ -198,8 +208,7 @@ ircd::m::receipt::read(const m::room::id &room_id,
string_view{event_id}, string_view{event_id},
string_view{user_id}, string_view{user_id},
string_view{room_id}, string_view{room_id},
ms, ms
string_view{evid}
}; };
return evid; return evid;
@ -371,6 +380,9 @@ handle_implicit_receipt(const m::event &event,
m::vm::eval &eval) m::vm::eval &eval)
try try
{ {
if(!json::get<"event_id"_>(event))
return;
const m::user::id &user_id const m::user::id &user_id
{ {
at<"sender"_>(event) at<"sender"_>(event)