mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 23:40:57 +01:00
modules/m_receipt: Minor cleanup / structured bindings.
This commit is contained in:
parent
8a99d6d44f
commit
38a530391c
1 changed files with 12 additions and 24 deletions
|
@ -91,18 +91,13 @@ handle_edu_m_receipt(const m::event &event,
|
||||||
void
|
void
|
||||||
handle_m_receipt(const m::event &event,
|
handle_m_receipt(const m::event &event,
|
||||||
const m::room::id &room_id,
|
const m::room::id &room_id,
|
||||||
const json::object &content)
|
const json::object &content_)
|
||||||
{
|
{
|
||||||
for(const auto &member : content)
|
for(const auto &[type, content] : content_)
|
||||||
{
|
{
|
||||||
const string_view &type
|
|
||||||
{
|
|
||||||
unquote(member.first)
|
|
||||||
};
|
|
||||||
|
|
||||||
if(type == "m.read")
|
if(type == "m.read")
|
||||||
{
|
{
|
||||||
handle_m_receipt_m_read(event, room_id, member.second);
|
handle_m_receipt_m_read(event, room_id, content);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,20 +113,16 @@ handle_m_receipt(const m::event &event,
|
||||||
void
|
void
|
||||||
handle_m_receipt_m_read(const m::event &event,
|
handle_m_receipt_m_read(const m::event &event,
|
||||||
const m::room::id &room_id,
|
const m::room::id &room_id,
|
||||||
const json::object &content)
|
const json::object &content_)
|
||||||
{
|
{
|
||||||
for(const auto &member : content)
|
for(const auto &[user_id_, content] : content_)
|
||||||
{
|
{
|
||||||
const m::user::id user_id
|
const m::user::id user_id{user_id_};
|
||||||
{
|
|
||||||
unquote(member.first)
|
|
||||||
};
|
|
||||||
|
|
||||||
if(user_id.host() != json::get<"origin"_>(event))
|
if(user_id.host() != json::get<"origin"_>(event))
|
||||||
{
|
{
|
||||||
log::dwarning
|
log::dwarning
|
||||||
{
|
{
|
||||||
receipt_log, "ignoring m.receipt m.read from '%s' in %s for alien %s.",
|
receipt_log, "Ignoring m.receipt m.read from '%s' in %s for alien %s.",
|
||||||
json::get<"origin"_>(event),
|
json::get<"origin"_>(event),
|
||||||
string_view{room_id},
|
string_view{room_id},
|
||||||
string_view{user_id},
|
string_view{user_id},
|
||||||
|
@ -140,12 +131,7 @@ handle_m_receipt_m_read(const m::event &event,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const json::object &content
|
handle_m_receipt_m_read(room_id, user_id, json::object{content});
|
||||||
{
|
|
||||||
member.second
|
|
||||||
};
|
|
||||||
|
|
||||||
handle_m_receipt_m_read(room_id, user_id, content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,11 +175,13 @@ try
|
||||||
if(my(user))
|
if(my(user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// If the user isn't known to us yet we drop that here; in the future
|
||||||
|
// we might be able to use this to trigger a resynchronization of the room.
|
||||||
if(!exists(user))
|
if(!exists(user))
|
||||||
{
|
{
|
||||||
log::dwarning
|
log::dwarning
|
||||||
{
|
{
|
||||||
receipt_log, "ignoring m.receipt m.read for unknown %s in %s for %s",
|
receipt_log, "Ignoring m.receipt m.read for unknown %s in %s for %s",
|
||||||
string_view{user_id},
|
string_view{user_id},
|
||||||
string_view{room_id},
|
string_view{room_id},
|
||||||
string_view{event_id}
|
string_view{event_id}
|
||||||
|
@ -211,7 +199,7 @@ catch(const std::exception &e)
|
||||||
{
|
{
|
||||||
log::derror
|
log::derror
|
||||||
{
|
{
|
||||||
receipt_log, "failed to save m.receipt m.read for %s in %s for %s :%s",
|
receipt_log, "Failed to save m.receipt m.read for %s in %s for %s :%s",
|
||||||
string_view{user_id},
|
string_view{user_id},
|
||||||
string_view{room_id},
|
string_view{room_id},
|
||||||
string_view{event_id},
|
string_view{event_id},
|
||||||
|
|
Loading…
Reference in a new issue