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

ircd:Ⓜ️ Add m.in_reply_to to m::relates tuple and reuse in m::room::message.

This commit is contained in:
Jason Volk 2022-08-04 18:25:49 -07:00
parent b75f0ea1ef
commit 14eb419045
6 changed files with 22 additions and 12 deletions

View file

@ -63,6 +63,7 @@ namespace ircd::m
#include "push.h" #include "push.h"
#include "createroom.h" #include "createroom.h"
#include "txn.h" #include "txn.h"
#include "relates.h"
#include "room/room.h" #include "room/room.h"
#include "user/user.h" #include "user/user.h"
#include "users.h" #include "users.h"
@ -82,7 +83,6 @@ namespace ircd::m
#include "typing.h" #include "typing.h"
#include "receipt.h" #include "receipt.h"
#include "direct_to_device.h" #include "direct_to_device.h"
#include "relates.h"
#include "visible.h" #include "visible.h"
#include "redacted.h" #include "redacted.h"
#include "feds.h" #include "feds.h"

View file

@ -181,8 +181,6 @@ struct ircd::m::name
static constexpr const char *const groupings {"groupings"}; static constexpr const char *const groupings {"groupings"};
static constexpr const char *const filter {"filter"}; static constexpr const char *const filter {"filter"};
static constexpr const char *const rel_type {"rel_type"};
static constexpr const char *const kind {"kind"}; static constexpr const char *const kind {"kind"};
static constexpr const char *const key {"key"}; static constexpr const char *const key {"key"};
static constexpr const char *const pattern {"pattern"}; static constexpr const char *const pattern {"pattern"};
@ -211,6 +209,9 @@ struct ircd::m::name
static constexpr const char *const formatted_body {"formatted_body"}; static constexpr const char *const formatted_body {"formatted_body"};
static constexpr const char *const m_relates_to {"m.relates_to"}; static constexpr const char *const m_relates_to {"m.relates_to"};
static constexpr const char *const m_in_reply_to {"m.in_reply_to"};
static constexpr const char *const rel_type {"rel_type"};
static constexpr const char *const usage {"usage"}; static constexpr const char *const usage {"usage"};
static constexpr const char *const master_key {"master_key"}; static constexpr const char *const master_key {"master_key"};
static constexpr const char *const self_signing_key {"self_signing_key"}; static constexpr const char *const self_signing_key {"self_signing_key"};

View file

@ -20,7 +20,8 @@ struct ircd::m::relates_to
:json::tuple :json::tuple
< <
json::property<name::event_id, json::string>, json::property<name::event_id, json::string>,
json::property<name::rel_type, json::string> json::property<name::rel_type, json::string>,
json::property<name::m_in_reply_to, json::object>
> >
{ {
using super_type::tuple; using super_type::tuple;

View file

@ -24,7 +24,7 @@ struct ircd::m::room::message
json::property<name::body, json::string>, json::property<name::body, json::string>,
/// m.relates_to /// m.relates_to
json::property<name::m_relates_to, json::object>, json::property<name::m_relates_to, m::relates_to>,
/// Required. enum. /// Required. enum.
json::property<name::msgtype, json::string>, json::property<name::msgtype, json::string>,

View file

@ -160,8 +160,6 @@ constexpr const char *const ircd::m::name::include_state;
constexpr const char *const ircd::m::name::groupings; constexpr const char *const ircd::m::name::groupings;
constexpr const char *const ircd::m::name::filter; constexpr const char *const ircd::m::name::filter;
constexpr const char *const ircd::m::name::rel_type;
constexpr const char *const ircd::m::name::kind; constexpr const char *const ircd::m::name::kind;
constexpr const char *const ircd::m::name::key; constexpr const char *const ircd::m::name::key;
constexpr const char *const ircd::m::name::pattern; constexpr const char *const ircd::m::name::pattern;
@ -190,6 +188,9 @@ constexpr const char *const ircd::m::name::format;
constexpr const char *const ircd::m::name::formatted_body; constexpr const char *const ircd::m::name::formatted_body;
constexpr const char *const ircd::m::name::m_relates_to; constexpr const char *const ircd::m::name::m_relates_to;
constexpr const char *const ircd::m::name::rel_type;
constexpr const char *const ircd::m::name::m_in_reply_to;
constexpr const char *const ircd::m::name::usage; constexpr const char *const ircd::m::name::usage;
constexpr const char *const ircd::m::name::master_key; constexpr const char *const ircd::m::name::master_key;
constexpr const char *const ircd::m::name::self_signing_key; constexpr const char *const ircd::m::name::self_signing_key;

View file

@ -112,17 +112,14 @@ ircd::m::event::id
ircd::m::room::message::reply_to_event() ircd::m::room::message::reply_to_event()
const noexcept try const noexcept try
{ {
const json::object &m_relates_to const m::relates_to &m_relates_to
{ {
json::get<"m.relates_to"_>(*this) json::get<"m.relates_to"_>(*this)
}; };
if(!m_relates_to || !json::type(m_relates_to, json::OBJECT))
return {};
const json::object &m_in_reply_to const json::object &m_in_reply_to
{ {
m_relates_to["m.in_reply_to"] json::get<"m.in_reply_to"_>(m_relates_to)
}; };
const auto &event_id const auto &event_id
@ -137,6 +134,16 @@ const noexcept try
return event_id; return event_id;
} }
catch(const json::error &e)
{
log::derror
{
log, "Failed to extract m.relates_to m.in_reply_to event_id :%s",
e.what(),
};
return {};
}
catch(const std::exception &e) catch(const std::exception &e)
{ {
log::error log::error