mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd:Ⓜ️ Make append() return and propagate boolean.
This commit is contained in:
parent
ef1f6f2642
commit
e0e9e09e67
7 changed files with 39 additions and 56 deletions
|
@ -24,6 +24,6 @@ namespace ircd::m
|
|||
bool query_txnid {true};
|
||||
};
|
||||
|
||||
void append(json::stack::object &, const event &, const event_append_opts & = {});
|
||||
void append(json::stack::array &, const event &, const event_append_opts & = {});
|
||||
bool append(json::stack::object &, const event &, const event_append_opts & = {});
|
||||
bool append(json::stack::array &, const event &, const event_append_opts & = {});
|
||||
}
|
||||
|
|
|
@ -356,10 +356,10 @@ ircd::m::pretty_oneline(std::ostream &s,
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// event/append.h
|
||||
// m/append.h
|
||||
//
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::append(json::stack::array &array,
|
||||
const event &event_,
|
||||
const event_append_opts &opts)
|
||||
|
@ -369,10 +369,10 @@ ircd::m::append(json::stack::array &array,
|
|||
array
|
||||
};
|
||||
|
||||
append(object, event_, opts);
|
||||
return append(object, event_, opts);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::append(json::stack::object &object,
|
||||
const event &event,
|
||||
const event_append_opts &opts)
|
||||
|
@ -415,19 +415,7 @@ ircd::m::append(json::stack::object &object,
|
|||
};
|
||||
#endif
|
||||
|
||||
if(opts.user_id && !visible(event, *opts.user_id))
|
||||
{
|
||||
log::debug
|
||||
{
|
||||
log, "Not sending event '%s' because not visible by '%s'",
|
||||
string_view{event.event_id},
|
||||
string_view{*opts.user_id}
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(!json::get<"state_key"_>(event) && has_event_idx && m::redacted(*opts.event_idx))
|
||||
if(has_event_idx && !defined(json::get<"state_key"_>(event)) && m::redacted(*opts.event_idx))
|
||||
{
|
||||
log::debug
|
||||
{
|
||||
|
@ -435,7 +423,7 @@ ircd::m::append(json::stack::object &object,
|
|||
string_view{event.event_id},
|
||||
};
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!json::get<"state_key"_>(event) && has_user)
|
||||
|
@ -451,7 +439,7 @@ ircd::m::append(json::stack::object &object,
|
|||
string_view{*opts.user_id}
|
||||
};
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,6 +516,8 @@ ircd::m::append(json::stack::object &object,
|
|||
unsigned_, "transaction_id", unquote(content.get("transaction_id"))
|
||||
};
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -16,7 +16,7 @@ IRCD_MODULE
|
|||
"Client 14.17.1.1 :Room Previews"
|
||||
};
|
||||
|
||||
static void
|
||||
static bool
|
||||
append_event(json::stack::array &out,
|
||||
const m::event &event,
|
||||
const m::event::idx &event_idx,
|
||||
|
@ -336,8 +336,7 @@ get_events_from(client &client,
|
|||
if(!visible(it.event_id(), request.user_id))
|
||||
continue;
|
||||
|
||||
append_event(chunk, *it, it.event_idx(), room_depth, user_room);
|
||||
++j;
|
||||
j += append_event(chunk, *it, it.event_idx(), room_depth, user_room);
|
||||
}
|
||||
|
||||
if(!j)
|
||||
|
@ -352,7 +351,7 @@ get_events_from(client &client,
|
|||
return j;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
append_event(json::stack::array &out,
|
||||
const m::event &event,
|
||||
const m::event::idx &event_idx,
|
||||
|
@ -364,5 +363,5 @@ append_event(json::stack::array &out,
|
|||
opts.room_depth = &room_depth;
|
||||
opts.user_room = &user_room;
|
||||
opts.user_id = &user_room.user.user_id;
|
||||
m::append(out, event, opts);
|
||||
return m::append(out, event, opts);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ context_log
|
|||
"matrix.context"
|
||||
};
|
||||
|
||||
static void
|
||||
static bool
|
||||
_append(json::stack::array &,
|
||||
const m::event &,
|
||||
const m::event::idx &,
|
||||
|
@ -193,8 +193,7 @@ get__context(client &client,
|
|||
if(!visible(event, request.user_id))
|
||||
continue;
|
||||
|
||||
_append(array, event, before.event_idx(), user_room, room_depth);
|
||||
++counts.before;
|
||||
counts.before += _append(array, event, before.event_idx(), user_room, room_depth);
|
||||
}
|
||||
|
||||
if(before && limit > 0)
|
||||
|
@ -234,8 +233,7 @@ get__context(client &client,
|
|||
if(!visible(event, request.user_id))
|
||||
continue;
|
||||
|
||||
_append(array, event, after.event_idx(), user_room, room_depth);
|
||||
++counts.after;
|
||||
counts.after += _append(array, event, after.event_idx(), user_room, room_depth);
|
||||
}
|
||||
|
||||
if(after && limit > 0)
|
||||
|
@ -293,8 +291,7 @@ get__context(client &client,
|
|||
if(!visible(event, request.user_id))
|
||||
return true;
|
||||
|
||||
_append(array, event, event_idx, user_room, room_depth, false);
|
||||
++counts.state;
|
||||
counts.state += _append(array, event, event_idx, user_room, room_depth, false);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -315,7 +312,7 @@ get__context(client &client,
|
|||
return std::move(response);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
_append(json::stack::array &chunk,
|
||||
const m::event &event,
|
||||
const m::event::idx &event_idx,
|
||||
|
@ -328,5 +325,5 @@ _append(json::stack::array &chunk,
|
|||
opts.user_id = &user_room.user.user_id;
|
||||
opts.user_room = &user_room;
|
||||
opts.room_depth = &room_depth;
|
||||
m::append(chunk, event, opts);
|
||||
return m::append(chunk, event, opts);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ struct pagination_tokens
|
|||
pagination_tokens(const resource::request &);
|
||||
};
|
||||
|
||||
static void
|
||||
static bool
|
||||
_append(json::stack::array &chunk,
|
||||
const m::event &,
|
||||
const m::event::idx &,
|
||||
|
@ -168,8 +168,10 @@ get__messages(client &client,
|
|||
continue;
|
||||
}
|
||||
|
||||
_append(chunk, event, it.event_idx(), user_room, room_depth);
|
||||
++hit;
|
||||
if(_append(chunk, event, it.event_idx(), user_room, room_depth))
|
||||
++hit;
|
||||
else
|
||||
++miss;
|
||||
}
|
||||
chunk.~array();
|
||||
|
||||
|
@ -203,7 +205,7 @@ get__messages(client &client,
|
|||
return {};
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
_append(json::stack::array &chunk,
|
||||
const m::event &event,
|
||||
const m::event::idx &event_idx,
|
||||
|
@ -215,7 +217,7 @@ _append(json::stack::array &chunk,
|
|||
opts.user_id = &user_room.user.user_id;
|
||||
opts.user_room = &user_room;
|
||||
opts.room_depth = &room_depth;
|
||||
m::append(chunk, event, opts);
|
||||
return m::append(chunk, event, opts);
|
||||
}
|
||||
|
||||
// Client-Server 6.3.6 query parameters
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace ircd::m::sync
|
||||
{
|
||||
static void room_state_append(data &, json::stack::array &, const m::event &, const m::event::idx &);
|
||||
static bool room_state_append(data &, json::stack::array &, const m::event &, const m::event::idx &);
|
||||
|
||||
static bool room_state_phased_member_events(data &, json::stack::array &);
|
||||
static bool room_state_phased_events(data &);
|
||||
|
@ -253,8 +253,7 @@ ircd::m::sync::room_state_polylog_events(data &data)
|
|||
}
|
||||
|
||||
const std::lock_guard lock{mutex};
|
||||
room_state_append(data, array, event, event_idx);
|
||||
ret |= true;
|
||||
ret |= room_state_append(data, array, event, event_idx);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -296,10 +295,9 @@ ircd::m::sync::room_state_phased_events(data &data)
|
|||
{
|
||||
[&data, &array, &ret, &mutex](const m::event &event)
|
||||
{
|
||||
ret |= true;
|
||||
const auto event_idx(m::index(event));
|
||||
const std::lock_guard lock{mutex};
|
||||
room_state_append(data, array, event, event_idx);
|
||||
ret |= room_state_append(data, array, event, event_idx);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -362,7 +360,7 @@ ircd::m::sync::room_state_phased_member_events(data &data,
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::sync::room_state_append(data &data,
|
||||
json::stack::array &events,
|
||||
const m::event &event,
|
||||
|
@ -374,5 +372,5 @@ ircd::m::sync::room_state_append(data &data,
|
|||
opts.user_room = &data.user_room;
|
||||
opts.query_txnid = false;
|
||||
opts.room_depth = &data.room_depth;
|
||||
m::append(events, event, opts);
|
||||
return m::append(events, event, opts);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ IRCD_MODULE
|
|||
|
||||
namespace ircd::m::sync
|
||||
{
|
||||
static void _room_timeline_append(data &, json::stack::array &, const m::event::idx &, const m::event &);
|
||||
static bool _room_timeline_append(data &, json::stack::array &, const m::event::idx &, const m::event &);
|
||||
static event::id::buf _room_timeline_polylog_events(data &, const m::room &, bool &, bool &);
|
||||
static bool room_timeline_polylog(data &);
|
||||
|
||||
|
@ -155,8 +155,7 @@ ircd::m::sync::room_timeline_linear(data &data)
|
|||
*data.out, "events"
|
||||
};
|
||||
|
||||
_room_timeline_append(data, array, data.event_idx, *data.event);
|
||||
return true;
|
||||
return _room_timeline_append(data, array, data.event_idx, *data.event);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -205,8 +204,7 @@ ircd::m::sync::_room_timeline_linear_command(data &data)
|
|||
data.event, &event
|
||||
};
|
||||
|
||||
_room_timeline_append(data, array, data.event_idx, event);
|
||||
return true;
|
||||
return _room_timeline_append(data, array, data.event_idx, event);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -295,14 +293,13 @@ ircd::m::sync::_room_timeline_polylog_events(data &data,
|
|||
{
|
||||
const m::event &event(*it);
|
||||
const m::event::idx &event_idx(it.event_idx());
|
||||
_room_timeline_append(data, array, event_idx, event);
|
||||
ret = true;
|
||||
ret |= _room_timeline_append(data, array, event_idx, event);
|
||||
}
|
||||
|
||||
return event_id;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::sync::_room_timeline_append(data &data,
|
||||
json::stack::array &events,
|
||||
const m::event::idx &event_idx,
|
||||
|
@ -314,5 +311,5 @@ ircd::m::sync::_room_timeline_append(data &data,
|
|||
opts.user_id = &data.user.user_id;
|
||||
opts.user_room = &data.user_room;
|
||||
opts.room_depth = &data.room_depth;
|
||||
m::append(events, event, opts);
|
||||
return m::append(events, event, opts);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue