mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
ircd:Ⓜ️:dbs: Deduplicate m.in_reply_to extraction w/ a4ec2dd8ab.
This commit is contained in:
parent
35199dffb3
commit
71f0d15910
1 changed files with 8 additions and 49 deletions
|
@ -704,44 +704,19 @@ ircd::m::dbs::_index_event_refs_m_relates_m_reply(db::txn &txn,
|
|||
if(json::get<"type"_>(event) != "m.room.message")
|
||||
return;
|
||||
|
||||
const auto &content
|
||||
const m::room::message content
|
||||
{
|
||||
json::get<"content"_>(event)
|
||||
};
|
||||
|
||||
if(!content.has("m.relates_to", json::OBJECT))
|
||||
return;
|
||||
|
||||
const json::object &m_relates_to
|
||||
const m::event::id event_id
|
||||
{
|
||||
content["m.relates_to"]
|
||||
content.reply_to_event()
|
||||
};
|
||||
|
||||
if(!m_relates_to.has("m.in_reply_to", json::OBJECT))
|
||||
if(!event_id)
|
||||
return;
|
||||
|
||||
const json::object &m_in_reply_to
|
||||
{
|
||||
m_relates_to["m.in_reply_to"]
|
||||
};
|
||||
|
||||
const json::string &event_id
|
||||
{
|
||||
m_in_reply_to["event_id"]
|
||||
};
|
||||
|
||||
if(unlikely(!valid(m::id::EVENT, event_id)))
|
||||
{
|
||||
log::derror
|
||||
{
|
||||
log, "Cannot index m.in_reply_to in %s; '%s' is not an event_id.",
|
||||
string_view{event.event_id},
|
||||
string_view{event_id}
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const event::idx &event_idx
|
||||
{
|
||||
find_event_idx(event_id, opts)
|
||||
|
@ -791,33 +766,17 @@ ircd::m::dbs::_prefetch_event_refs_m_relates_m_reply(const event &event,
|
|||
if(json::get<"type"_>(event) != "m.room.message")
|
||||
return false;
|
||||
|
||||
const auto &content
|
||||
const m::room::message content
|
||||
{
|
||||
json::get<"content"_>(event)
|
||||
};
|
||||
|
||||
if(!content.has("m.relates_to", json::OBJECT))
|
||||
return false;
|
||||
|
||||
const json::object &m_relates_to
|
||||
const m::event::id event_id
|
||||
{
|
||||
content["m.relates_to"]
|
||||
content.reply_to_event()
|
||||
};
|
||||
|
||||
if(!m_relates_to.has("m.in_reply_to", json::OBJECT))
|
||||
return false;
|
||||
|
||||
const json::object &m_in_reply_to
|
||||
{
|
||||
m_relates_to["m.in_reply_to"]
|
||||
};
|
||||
|
||||
const json::string &event_id
|
||||
{
|
||||
m_in_reply_to["event_id"]
|
||||
};
|
||||
|
||||
if(unlikely(!valid(m::id::EVENT, event_id)))
|
||||
if(!event_id)
|
||||
return false;
|
||||
|
||||
return prefetch_event_idx(event_id, opts);
|
||||
|
|
Loading…
Reference in a new issue