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

ircd:Ⓜ️:room: Remove old cruft.

This commit is contained in:
Jason Volk 2019-08-17 23:05:43 -07:00
parent 59a6d4f6b5
commit e3ced849ee
2 changed files with 0 additions and 182 deletions

View file

@ -4644,120 +4644,3 @@ ircd::m::room::stats::bytes_json_compressed(const m::room &room)
"Not yet implemented."
};
}
//TODO: temp
namespace ircd::m
{
extern "C" void room_herd(const m::room &, const m::user &, const milliseconds &);
extern "C" size_t dagree_histogram(const m::room &, std::vector<size_t> &);
}
void
ircd::m::room_herd(const m::room &room,
const m::user &user,
const milliseconds &timeout)
{
using closure_prototype = bool (const string_view &,
std::exception_ptr,
const json::object &);
using prototype = void (const m::room::id &,
const m::user::id &,
const milliseconds &,
const std::function<closure_prototype> &);
static mods::import<prototype> feds__head
{
"federation_federation", "feds__head"
};
std::set<std::string> event_ids;
feds__head(room.room_id, user.user_id, timeout, [&event_ids]
(const string_view &origin, std::exception_ptr eptr, const json::object &event)
{
if(eptr)
return true;
const json::array prev_events
{
event.at("prev_events")
};
for(const json::array prev_event : prev_events)
{
const auto &prev_event_id
{
unquote(prev_event.at(0))
};
event_ids.emplace(prev_event_id);
};
return true;
});
size_t i(0);
for(const m::event::id &event_id : event_ids)
if(exists(event_id))
{
m::room::head::modify(event_id, db::op::SET, false);
++i;
}
const m::room::head head
{
room
};
for(; i + 1 >= 1 && head.count() > 1; --i)
{
const auto eid
{
send(room, user, "ircd.room.revelation", json::object{})
};
ctx::sleep(seconds(2));
}
}
size_t
ircd::m::dagree_histogram(const m::room &room,
std::vector<size_t> &vec)
{
static const m::event::fetch::opts fopts
{
{ db::get::NO_CACHE },
m::event::keys::include
{
"event_id",
"prev_events",
}
};
m::room::messages it
{
room, &fopts
};
size_t ret{0};
for(; it; --it)
{
const m::event event{*it};
const size_t num{degree(event)};
if(unlikely(num >= vec.size()))
{
log::warning
{
m::log, "Event '%s' had %zu prev events (ignored)",
string_view{event.event_id},
};
continue;
}
++vec[num];
++ret;
}
return ret;
}

View file

@ -7906,35 +7906,6 @@ console_cmd__room__head__del(opt &out, const string_view &line)
return true;
}
bool
console_cmd__room__herd(opt &out, const string_view &line)
{
const params param{line, " ",
{
"room_id", "user_id"
}};
const auto &room_id
{
m::room_id(param.at(0))
};
const m::user::id &user_id
{
param.at(1)
};
using prototype = void (const m::room &, const m::user &, const milliseconds &);
static mods::import<prototype> room_herd
{
"m_room", "room_herd"
};
room_herd(room_id, user_id, out.timeout);
out << "done" << std::endl;
return true;
}
bool
console_cmd__room__head__reset(opt &out, const string_view &line)
{
@ -9982,42 +9953,6 @@ console_cmd__room__purge(opt &out, const string_view &line)
return true;
}
bool
console_cmd__room__dagree(opt &out, const string_view &line)
{
const params param{line, " ",
{
"room_id",
}};
const auto &room_id
{
m::room_id(param.at(0))
};
const m::room room
{
room_id
};
using prototype = size_t (const m::room &, std::vector<size_t> &);
static mods::import<prototype> dagree_histogram
{
"m_room", "dagree_histogram"
};
std::vector<size_t> v(32, 0);
const size_t count
{
dagree_histogram(room, v)
};
for(size_t i(0); i < v.size(); ++i)
out << std::setw(2) << std::right << i << ": " << v.at(i) << std::endl;
return true;
}
bool
console_cmd__room__auth(opt &out, const string_view &line)
{