mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 07:23:53 +01:00
ircd:Ⓜ️:room: Remove cruft.
This commit is contained in:
parent
dcab8eb08e
commit
9c68d01d86
6 changed files with 0 additions and 303 deletions
|
@ -107,7 +107,6 @@ namespace ircd::m
|
|||
struct ircd::m::room
|
||||
{
|
||||
struct events;
|
||||
struct timeline;
|
||||
struct state;
|
||||
struct members;
|
||||
struct origins;
|
||||
|
@ -193,7 +192,6 @@ struct ircd::m::room
|
|||
};
|
||||
|
||||
#include "events.h"
|
||||
#include "timeline.h"
|
||||
#include "state.h"
|
||||
#include "state_space.h"
|
||||
#include "state_history.h"
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_M_ROOM_TIMELINE_H
|
||||
|
||||
namespace ircd::m
|
||||
{
|
||||
uint64_t latency(const room::timeline &, const room::timeline &);
|
||||
}
|
||||
|
||||
/// Interface to room timeline
|
||||
///
|
||||
struct ircd::m::room::timeline
|
||||
{
|
||||
struct coord;
|
||||
using closure = std::function<coord &(coord &, const event::idx &)>;
|
||||
|
||||
m::room room;
|
||||
|
||||
public:
|
||||
static event::idx next(const event::idx &, const int64_t &x = 0);
|
||||
|
||||
bool has_past(const event::id &) const;
|
||||
bool has_future(const event::id &) const;
|
||||
|
||||
bool for_each(coord &, const closure &) const;
|
||||
bool for_each(const closure &) const;
|
||||
|
||||
timeline(const m::room &);
|
||||
timeline() = default;
|
||||
timeline(const timeline &) = delete;
|
||||
timeline &operator=(const timeline &) = delete;
|
||||
|
||||
static void rebuild(const m::room &);
|
||||
};
|
||||
|
||||
struct ircd::m::room::timeline::coord
|
||||
{
|
||||
int64_t x {0};
|
||||
int64_t y {0};
|
||||
};
|
|
@ -213,7 +213,6 @@ ircd::m::module_names
|
|||
"m_room_events",
|
||||
"m_room_auth",
|
||||
"m_room_head",
|
||||
"m_room_timeline",
|
||||
"m_room_aliases",
|
||||
"m_room_canonical_alias",
|
||||
"m_room_create",
|
||||
|
|
|
@ -134,7 +134,6 @@ m_room_la_SOURCES = m_room.cc
|
|||
m_room_events_la_SOURCES = m_room_events.cc
|
||||
m_room_auth_la_SOURCES = m_room_auth.cc
|
||||
m_room_head_la_SOURCES = m_room_head.cc
|
||||
m_room_timeline_la_SOURCES = m_room_timeline.cc
|
||||
m_room_create_la_SOURCES = m_room_create.cc
|
||||
m_room_member_la_SOURCES = m_room_member.cc
|
||||
m_room_join_la_SOURCES = m_room_join.cc
|
||||
|
@ -194,7 +193,6 @@ m_module_LTLIBRARIES = \
|
|||
m_room_events.la \
|
||||
m_room_auth.la \
|
||||
m_room_head.la \
|
||||
m_room_timeline.la \
|
||||
m_room_create.la \
|
||||
m_room_member.la \
|
||||
m_room_join.la \
|
||||
|
|
|
@ -9857,103 +9857,6 @@ console_cmd__room__messages(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__timeline(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"room_id", "x", "y"
|
||||
}};
|
||||
|
||||
const auto &room_id
|
||||
{
|
||||
m::room_id(param.at("room_id"))
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
room_id
|
||||
};
|
||||
|
||||
const m::room::timeline timeline
|
||||
{
|
||||
room
|
||||
};
|
||||
|
||||
const auto closure{[&out, &room]
|
||||
(auto &coord, const auto &event_idx)
|
||||
-> m::room::timeline::coord &
|
||||
{
|
||||
if(coord.y > m::depth(std::nothrow, room))
|
||||
return coord;
|
||||
|
||||
if(!event_idx)
|
||||
{
|
||||
++coord.y;
|
||||
return coord;
|
||||
}
|
||||
|
||||
const m::event::fetch event
|
||||
{
|
||||
event_idx, std::nothrow
|
||||
};
|
||||
|
||||
if(!event.valid)
|
||||
{
|
||||
++coord.x;
|
||||
return coord;
|
||||
}
|
||||
|
||||
out << "("
|
||||
<< std::left
|
||||
<< std::setw(2) << coord.x
|
||||
<< " "
|
||||
<< std::right
|
||||
<< std::setw(3) << coord.y
|
||||
<< ") "
|
||||
<< std::left
|
||||
<< std::setw(11) << event_idx
|
||||
<< " "
|
||||
<< pretty_oneline(event, false)
|
||||
<< std::endl;
|
||||
|
||||
++coord.x;
|
||||
return coord;
|
||||
}};
|
||||
|
||||
m::room::timeline::coord coord
|
||||
{
|
||||
param.at<long>("x", 0L),
|
||||
param.at<long>("y", 0L),
|
||||
};
|
||||
|
||||
timeline.for_each(coord, closure);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__timeline__rebuild(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"room_id"
|
||||
}};
|
||||
|
||||
const auto &room_id
|
||||
{
|
||||
m::room_id(param.at("room_id"))
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
room_id
|
||||
};
|
||||
|
||||
m::room::timeline::rebuild(room);
|
||||
out << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__get(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
|
@ -1,152 +0,0 @@
|
|||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
ircd::mapi::header
|
||||
IRCD_MODULE
|
||||
{
|
||||
"Matrix room library; timeline modular components."
|
||||
};
|
||||
|
||||
uint64_t
|
||||
ircd::m::latency(const room::timeline &a,
|
||||
const room::timeline &b)
|
||||
{
|
||||
return 0UL;
|
||||
}
|
||||
|
||||
//
|
||||
// room::timeline::timeline
|
||||
//
|
||||
|
||||
ircd::m::room::timeline::timeline(const m::room &room)
|
||||
:room{room}
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::timeline::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
struct coord coord;
|
||||
return for_each(coord, closure);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::timeline::for_each(coord &coord,
|
||||
const closure &closure)
|
||||
const
|
||||
{
|
||||
events it
|
||||
{
|
||||
this->room, uint64_t(coord.y)
|
||||
};
|
||||
|
||||
if(!it)
|
||||
return true;
|
||||
|
||||
event::idx next(it.event_idx()); do
|
||||
{
|
||||
const auto last(coord);
|
||||
coord = closure(coord, next);
|
||||
if(coord.x == last.x && coord.y == last.y)
|
||||
return true;
|
||||
|
||||
if(coord.y != last.y)
|
||||
if(!it.seek(coord.y))
|
||||
return true;
|
||||
|
||||
next = timeline::next(it.event_idx(), coord.x);
|
||||
if(next == 0 && coord.x == 0)
|
||||
continue;
|
||||
|
||||
if(next == it.event_idx())
|
||||
return false;
|
||||
|
||||
if(next == 0)
|
||||
coord.x = 0;
|
||||
}
|
||||
while(1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::timeline::has_future(const event::id &event_id)
|
||||
const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::timeline::has_past(const event::id &event_id)
|
||||
const
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// static util
|
||||
//
|
||||
|
||||
void
|
||||
ircd::m::room::timeline::rebuild(const m::room &room)
|
||||
{
|
||||
m::room::events it
|
||||
{
|
||||
room, 0UL
|
||||
};
|
||||
|
||||
if(!it)
|
||||
return;
|
||||
|
||||
db::txn txn
|
||||
{
|
||||
*m::dbs::events
|
||||
};
|
||||
|
||||
for(; it; ++it)
|
||||
{
|
||||
const m::event &event{*it};
|
||||
m::dbs::write_opts opts;
|
||||
opts.event_idx = it.event_idx();
|
||||
opts.appendix.reset();
|
||||
opts.appendix.set(dbs::appendix::EVENT_REFS);
|
||||
opts.event_refs.reset();
|
||||
opts.event_refs.set(uint(dbs::ref::NEXT));
|
||||
m::dbs::write(txn, event, opts);
|
||||
}
|
||||
|
||||
txn();
|
||||
}
|
||||
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::timeline::next(const event::idx &event_idx,
|
||||
const int64_t &x)
|
||||
{
|
||||
const m::event::refs refs
|
||||
{
|
||||
event_idx
|
||||
};
|
||||
|
||||
int64_t _x(0);
|
||||
event::idx ret(0);
|
||||
refs.for_each(dbs::ref::NEXT, [&_x, &x, &ret]
|
||||
(const auto &event_idx, const auto &)
|
||||
{
|
||||
if(_x++ < x)
|
||||
return true;
|
||||
|
||||
ret = event_idx;
|
||||
return false;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
Loading…
Reference in a new issue