mirror of
https://github.com/matrix-construct/construct
synced 2024-09-28 19:58:53 +02:00
modules/m_receipt: Add committer w/ central linkage; read_markers.
This commit is contained in:
parent
f11c98db34
commit
be6a5b7767
4 changed files with 91 additions and 4 deletions
|
@ -11,10 +11,11 @@
|
|||
#pragma once
|
||||
#define HAVE_IRCD_M_RECEIPT_H
|
||||
|
||||
namespace ircd::m
|
||||
namespace ircd::m::receipt
|
||||
{
|
||||
|
||||
}
|
||||
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
|
||||
};
|
||||
|
||||
struct ircd::m::edu::m_receipt
|
||||
{
|
||||
|
|
30
ircd/m/m.cc
30
ircd/m/m.cc
|
@ -525,6 +525,35 @@ ircd::m::keys::init::signing()
|
|||
self::public_key_b64);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// m/receipt.h
|
||||
//
|
||||
|
||||
ircd::m::event::id::buf
|
||||
ircd::m::receipt::read(const id::room &room_id,
|
||||
const id::user &user_id,
|
||||
const id::event &event_id)
|
||||
{
|
||||
return read(room_id, user_id, event_id, ircd::time<milliseconds>());
|
||||
}
|
||||
|
||||
ircd::m::event::id::buf
|
||||
ircd::m::receipt::read(const id::room &room_id,
|
||||
const id::user &user_id,
|
||||
const id::event &event_id,
|
||||
const time_t &ms)
|
||||
{
|
||||
using prototype = event::id::buf (const id::room &, const id::user &, const id::event &, const time_t &);
|
||||
|
||||
static import<prototype> function
|
||||
{
|
||||
"m_receipt", "receipt_m_read"
|
||||
};
|
||||
|
||||
return function(room_id, user_id, event_id, ms);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// m/typing.h
|
||||
|
@ -543,7 +572,6 @@ ircd::m::typing::set(const m::typing &object)
|
|||
return function(object);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// m/presence.h
|
||||
|
|
|
@ -17,6 +17,18 @@ post__read_markers(client &client,
|
|||
const resource::request &request,
|
||||
const m::room::id &room_id)
|
||||
{
|
||||
const string_view m_fully_read
|
||||
{
|
||||
unquote(request["m.fully_read"])
|
||||
};
|
||||
|
||||
const string_view m_read
|
||||
{
|
||||
unquote(request["m.read"])
|
||||
};
|
||||
|
||||
m::receipt::read(room_id, request.user_id, m_read?: m_fully_read);
|
||||
|
||||
return resource::response
|
||||
{
|
||||
client, http::OK
|
||||
|
|
|
@ -20,6 +20,52 @@ 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
|
||||
|
|
Loading…
Reference in a new issue