mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
ircd:Ⓜ️:rooms: Expose fetcher in interface; internal cleanup.
This commit is contained in:
parent
f24c7c2e82
commit
75c125e8aa
3 changed files with 12 additions and 29 deletions
|
@ -30,6 +30,7 @@ namespace ircd::m::rooms
|
||||||
event::id::buf summary_set(const m::room::id &, const json::object &summary);
|
event::id::buf summary_set(const m::room::id &, const json::object &summary);
|
||||||
event::id::buf summary_set(const m::room &);
|
event::id::buf summary_set(const m::room &);
|
||||||
event::id::buf summary_del(const m::room &);
|
event::id::buf summary_del(const m::room &);
|
||||||
|
std::pair<size_t, std::string> fetch_update(const net::hostport &, const string_view &since = {}, const size_t &limit = 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Arguments structure to rooms::for_each(). This reduces the API surface to
|
/// Arguments structure to rooms::for_each(). This reduces the API surface to
|
||||||
|
|
|
@ -7363,13 +7363,6 @@ console_cmd__rooms__public(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__rooms__fetch(opt &out, const string_view &line)
|
console_cmd__rooms__fetch(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
using prototype = std::pair<size_t, std::string> (const net::hostport &, const string_view &);
|
|
||||||
|
|
||||||
static mods::import<prototype> fetch_update
|
|
||||||
{
|
|
||||||
"m_rooms", "ircd::m::rooms::fetch_update"
|
|
||||||
};
|
|
||||||
|
|
||||||
const params param{line, " ",
|
const params param{line, " ",
|
||||||
{
|
{
|
||||||
"server", "since"
|
"server", "since"
|
||||||
|
@ -7387,7 +7380,7 @@ console_cmd__rooms__fetch(opt &out, const string_view &line)
|
||||||
|
|
||||||
const auto pair
|
const auto pair
|
||||||
{
|
{
|
||||||
fetch_update(server, since)
|
m::rooms::fetch_update(server, since)
|
||||||
};
|
};
|
||||||
|
|
||||||
out << "done" << std::endl
|
out << "done" << std::endl
|
||||||
|
|
|
@ -13,15 +13,12 @@ namespace ircd::m::rooms
|
||||||
static string_view make_state_key(const mutable_buffer &out, const m::room::id &);
|
static string_view make_state_key(const mutable_buffer &out, const m::room::id &);
|
||||||
static m::room::id::buf unmake_state_key(const string_view &);
|
static m::room::id::buf unmake_state_key(const string_view &);
|
||||||
|
|
||||||
extern conf::item<size_t> fetch_limit;
|
|
||||||
extern conf::item<seconds> fetch_timeout;
|
|
||||||
std::pair<size_t, std::string> fetch_update(const net::hostport &, const string_view &since, const size_t &limit, const seconds &timeout);
|
|
||||||
std::pair<size_t, std::string> fetch_update(const net::hostport &, const string_view &since = {});
|
|
||||||
|
|
||||||
static void remote_summary_chunk(const m::room &room, json::stack::object &obj);
|
static void remote_summary_chunk(const m::room &room, json::stack::object &obj);
|
||||||
static void local_summary_chunk(const m::room &room, json::stack::object &obj);
|
static void local_summary_chunk(const m::room &room, json::stack::object &obj);
|
||||||
extern "C" bool _for_each_public(const string_view &room_id_lb, const room::id::closure_bool &);
|
static bool for_each_public(const string_view &room_id_lb, const room::id::closure_bool &);
|
||||||
|
|
||||||
|
extern conf::item<size_t> fetch_limit;
|
||||||
|
extern conf::item<seconds> fetch_timeout;
|
||||||
extern m::hookfn<vm::eval &> create_public_room;
|
extern m::hookfn<vm::eval &> create_public_room;
|
||||||
extern const room::id::buf public_room_id;
|
extern const room::id::buf public_room_id;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +58,7 @@ IRCD_MODULE_EXPORT
|
||||||
ircd::m::rooms::for_each(const each_opts &opts)
|
ircd::m::rooms::for_each(const each_opts &opts)
|
||||||
{
|
{
|
||||||
if(opts.public_rooms)
|
if(opts.public_rooms)
|
||||||
return _for_each_public(opts.key, opts.closure);
|
return for_each_public(opts.key, opts.closure);
|
||||||
|
|
||||||
const room::state state
|
const room::state state
|
||||||
{
|
{
|
||||||
|
@ -98,13 +95,13 @@ ircd::m::rooms::count_public(const string_view &server)
|
||||||
return true;
|
return true;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
_for_each_public(server, count);
|
for_each_public(server, count);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::m::rooms::_for_each_public(const string_view &key,
|
ircd::m::rooms::for_each_public(const string_view &key,
|
||||||
const room::id::closure_bool &closure)
|
const room::id::closure_bool &closure)
|
||||||
{
|
{
|
||||||
const room::state state
|
const room::state state
|
||||||
{
|
{
|
||||||
|
@ -332,20 +329,11 @@ ircd::m::rooms::fetch_limit
|
||||||
{ "default", 64L },
|
{ "default", 64L },
|
||||||
};
|
};
|
||||||
|
|
||||||
std::pair<size_t, std::string>
|
|
||||||
IRCD_MODULE_EXPORT
|
|
||||||
ircd::m::rooms::fetch_update(const net::hostport &hp,
|
|
||||||
const string_view &since)
|
|
||||||
{
|
|
||||||
return fetch_update(hp, since, size_t(fetch_limit), seconds(fetch_timeout));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<size_t, std::string>
|
std::pair<size_t, std::string>
|
||||||
IRCD_MODULE_EXPORT
|
IRCD_MODULE_EXPORT
|
||||||
ircd::m::rooms::fetch_update(const net::hostport &hp,
|
ircd::m::rooms::fetch_update(const net::hostport &hp,
|
||||||
const string_view &since,
|
const string_view &since,
|
||||||
const size_t &limit,
|
const size_t &limit)
|
||||||
const seconds &timeout)
|
|
||||||
{
|
{
|
||||||
m::v1::public_rooms::opts opts;
|
m::v1::public_rooms::opts opts;
|
||||||
opts.limit = limit;
|
opts.limit = limit;
|
||||||
|
@ -364,7 +352,8 @@ ircd::m::rooms::fetch_update(const net::hostport &hp,
|
||||||
hp, buf, std::move(opts)
|
hp, buf, std::move(opts)
|
||||||
};
|
};
|
||||||
|
|
||||||
request.wait(timeout);
|
request.wait(seconds(fetch_timeout));
|
||||||
|
|
||||||
const auto code
|
const auto code
|
||||||
{
|
{
|
||||||
request.get()
|
request.get()
|
||||||
|
|
Loading…
Reference in a new issue