mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
ircd:Ⓜ️🧾 Start central interface to get receipt information.
This commit is contained in:
parent
f4831c863a
commit
5c879bd380
3 changed files with 67 additions and 0 deletions
|
@ -13,6 +13,11 @@
|
|||
|
||||
namespace ircd::m::receipt
|
||||
{
|
||||
// [GET]
|
||||
bool read(const id::room &, const id::user &, const event::id::closure &);
|
||||
id::event read(id::event::buf &out, const id::room &, const id::user &);
|
||||
|
||||
// [SET]
|
||||
id::event::buf read(const id::room &, const id::user &, const id::event &, const time_t &);
|
||||
id::event::buf read(const id::room &, const id::user &, const id::event &); // now
|
||||
};
|
||||
|
|
31
ircd/m/m.cc
31
ircd/m/m.cc
|
@ -853,6 +853,37 @@ ircd::m::receipt::read(const id::room &room_id,
|
|||
return function(room_id, user_id, event_id, ms);
|
||||
}
|
||||
|
||||
ircd::m::event::id
|
||||
ircd::m::receipt::read(id::event::buf &out,
|
||||
const id::room &room_id,
|
||||
const id::user &user_id)
|
||||
{
|
||||
const event::id::closure copy{[&out]
|
||||
(const event::id &event_id)
|
||||
{
|
||||
out = event_id;
|
||||
}};
|
||||
|
||||
return read(room_id, user_id, copy)?
|
||||
event::id{out}:
|
||||
event::id{};
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::receipt::read(const id::room &room_id,
|
||||
const id::user &user_id,
|
||||
const event::id::closure &closure)
|
||||
{
|
||||
using prototype = bool (const id::room &, const id::user &, const id::event::closure &);
|
||||
|
||||
static import<prototype> function
|
||||
{
|
||||
"m_receipt", "last_receipt__event_id"
|
||||
};
|
||||
|
||||
return function(room_id, user_id, closure);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// m/typing.h
|
||||
|
|
|
@ -16,6 +16,7 @@ IRCD_MODULE
|
|||
"Matrix Receipts"
|
||||
};
|
||||
|
||||
extern "C" bool last_receipt__event_id(const m::room::id &, const m::user::id &, const m::event::id::closure &);
|
||||
static void handle_m_receipt_m_read(const m::room::id &, const m::user::id &, const m::event::id &, const time_t &);
|
||||
static void handle_m_receipt_m_read(const m::room::id &, const m::user::id &, const m::edu::m_receipt::m_read &);
|
||||
static void handle_m_receipt_m_read(const m::room::id &, const json::object &);
|
||||
|
@ -212,3 +213,33 @@ catch(const std::exception &e)
|
|||
e.what()
|
||||
};
|
||||
}
|
||||
|
||||
bool
|
||||
last_receipt__event_id(const m::room::id &room_id,
|
||||
const m::user::id &user_id,
|
||||
const m::event::id::closure &closure)
|
||||
{
|
||||
static const m::event::fetch::opts fopts
|
||||
{
|
||||
m::event::keys::include
|
||||
{
|
||||
"content"
|
||||
}
|
||||
};
|
||||
|
||||
const m::user::room user_room
|
||||
{
|
||||
user_id, nullptr, &fopts
|
||||
};
|
||||
|
||||
return user_room.get(std::nothrow, "ircd.read", room_id, [&closure]
|
||||
(const m::event &event)
|
||||
{
|
||||
const m::event::id &event_id
|
||||
{
|
||||
unquote(at<"content"_>(event).get("event_id"))
|
||||
};
|
||||
|
||||
closure(event_id);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue