mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 18:38:52 +02:00
ircd:Ⓜ️:room: Rename room::messages to room::events.
This commit is contained in:
parent
284bb7653a
commit
a52ad73e87
23 changed files with 72 additions and 73 deletions
|
@ -10,7 +10,7 @@ tables as the database for room in addition to the raw event data itself.
|
|||
- room_events
|
||||
This is the timeline for room events. We sort the keys of this table by
|
||||
an event's `depth`. This table allows us to scan the room's events as
|
||||
a collection. See: `m::room::messages`.
|
||||
a collection. See: `m::room::events`.
|
||||
|
||||
- room_state
|
||||
This is the present state table for a room. We sort the keys of this table
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
// 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
|
||||
|
@ -9,7 +9,7 @@
|
|||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_M_ROOM_MESSAGES_H
|
||||
#define HAVE_IRCD_M_ROOM_EVENTS_H
|
||||
|
||||
namespace ircd::m
|
||||
{
|
||||
|
@ -35,15 +35,15 @@ namespace ircd::m
|
|||
std::pair<int64_t, event::idx> twain(const room &);
|
||||
}
|
||||
|
||||
/// Interface to room messages
|
||||
/// Interface to room events
|
||||
///
|
||||
/// This interface has the form of an STL-style iterator over room messages
|
||||
/// This interface has the form of an STL-style iterator over room events
|
||||
/// which are state and non-state events from all integrated timelines.
|
||||
/// Moving the iterator is cheap, but the dereference operators fetch a
|
||||
/// full event. One can iterate just event_idx's by using event_idx() instead
|
||||
/// of the dereference operators.
|
||||
///
|
||||
struct ircd::m::room::messages
|
||||
struct ircd::m::room::events
|
||||
{
|
||||
m::room room;
|
||||
db::domain::const_iterator it;
|
||||
|
@ -73,18 +73,18 @@ struct ircd::m::room::messages
|
|||
const m::event &operator*();
|
||||
const m::event *operator->() { return &operator*(); }
|
||||
|
||||
messages(const m::room &room,
|
||||
const uint64_t &depth,
|
||||
const event::fetch::opts *const & = nullptr);
|
||||
events(const m::room &,
|
||||
const uint64_t &depth,
|
||||
const event::fetch::opts *const & = nullptr);
|
||||
|
||||
messages(const m::room &room,
|
||||
const event::id &,
|
||||
const event::fetch::opts *const & = nullptr);
|
||||
events(const m::room &,
|
||||
const event::id &,
|
||||
const event::fetch::opts *const & = nullptr);
|
||||
|
||||
messages(const m::room &room,
|
||||
const event::fetch::opts *const & = nullptr);
|
||||
events(const m::room &,
|
||||
const event::fetch::opts *const & = nullptr);
|
||||
|
||||
messages() = default;
|
||||
messages(const messages &) = delete;
|
||||
messages &operator=(const messages &) = delete;
|
||||
events() = default;
|
||||
events(const events &) = delete;
|
||||
events &operator=(const events &) = delete;
|
||||
};
|
|
@ -102,7 +102,7 @@ namespace ircd::m
|
|||
///
|
||||
struct ircd::m::room
|
||||
{
|
||||
struct messages;
|
||||
struct events;
|
||||
struct timeline;
|
||||
struct state;
|
||||
struct members;
|
||||
|
@ -188,7 +188,7 @@ struct ircd::m::room
|
|||
static size_t purge(const room &); // cuidado!
|
||||
};
|
||||
|
||||
#include "messages.h"
|
||||
#include "events.h"
|
||||
#include "timeline.h"
|
||||
#include "state.h"
|
||||
#include "state_space.h"
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
///
|
||||
/// This interface focuses specifically on the details of room state. Most of
|
||||
/// the queries to this interface respond in logarithmic time. If an event with
|
||||
/// a state_key is present in room::messages but it is not present in
|
||||
/// room::state (state tree) it was accepted into the room but we will not
|
||||
/// apply it to our machine, though other parties may (this is a
|
||||
/// state-conflict).
|
||||
/// a state_key is present in room::events but it is not present in room::state
|
||||
/// or room::state::space it was accepted into the room but we will not apply
|
||||
/// it to our machine, though other parties may (this is a state-conflict).
|
||||
///
|
||||
struct ircd::m::room::state
|
||||
{
|
||||
|
|
|
@ -171,7 +171,7 @@ ircd::m::room::state::purge_replaced(const room::id &room_id)
|
|||
};
|
||||
|
||||
size_t ret(0);
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room_id, uint64_t(0)
|
||||
};
|
||||
|
@ -710,7 +710,7 @@ bool
|
|||
ircd::m::rfor_each_depth_gap(const room &room,
|
||||
const depth_range_closure &closure)
|
||||
{
|
||||
room::messages it
|
||||
room::events it
|
||||
{
|
||||
room
|
||||
};
|
||||
|
@ -748,7 +748,7 @@ bool
|
|||
ircd::m::for_each_depth_gap(const room &room,
|
||||
const depth_range_closure &closure)
|
||||
{
|
||||
room::messages it
|
||||
room::events it
|
||||
{
|
||||
room, int64_t(0L)
|
||||
};
|
||||
|
@ -806,7 +806,7 @@ ircd::m::count_since(const m::room &room,
|
|||
const m::event::idx &a,
|
||||
const m::event::idx &b)
|
||||
{
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room
|
||||
};
|
||||
|
@ -1429,7 +1429,7 @@ ircd::m::room::index(const room::id &room_id,
|
|||
std::nothrow_t)
|
||||
{
|
||||
uint64_t depth{0};
|
||||
room::messages it
|
||||
room::events it
|
||||
{
|
||||
room_id, depth
|
||||
};
|
||||
|
@ -1751,7 +1751,7 @@ const
|
|||
dbs::event_column.at(idx)
|
||||
};
|
||||
|
||||
messages it{*this};
|
||||
events it{*this};
|
||||
for(; it; --it)
|
||||
{
|
||||
const auto &event_idx
|
||||
|
@ -1780,11 +1780,11 @@ const
|
|||
}
|
||||
|
||||
//
|
||||
// room::messages
|
||||
// room::events
|
||||
//
|
||||
|
||||
ircd::m::room::messages::messages(const m::room &room,
|
||||
const event::fetch::opts *const &fopts)
|
||||
ircd::m::room::events::events(const m::room &room,
|
||||
const event::fetch::opts *const &fopts)
|
||||
:room{room}
|
||||
,_event
|
||||
{
|
||||
|
@ -1803,9 +1803,9 @@ ircd::m::room::messages::messages(const m::room &room,
|
|||
seek();
|
||||
}
|
||||
|
||||
ircd::m::room::messages::messages(const m::room &room,
|
||||
const event::id &event_id,
|
||||
const event::fetch::opts *const &fopts)
|
||||
ircd::m::room::events::events(const m::room &room,
|
||||
const event::id &event_id,
|
||||
const event::fetch::opts *const &fopts)
|
||||
:room{room}
|
||||
,_event
|
||||
{
|
||||
|
@ -1821,9 +1821,9 @@ ircd::m::room::messages::messages(const m::room &room,
|
|||
seek(event_id);
|
||||
}
|
||||
|
||||
ircd::m::room::messages::messages(const m::room &room,
|
||||
const uint64_t &depth,
|
||||
const event::fetch::opts *const &fopts)
|
||||
ircd::m::room::events::events(const m::room &room,
|
||||
const uint64_t &depth,
|
||||
const event::fetch::opts *const &fopts)
|
||||
:room{room}
|
||||
,_event
|
||||
{
|
||||
|
@ -1844,13 +1844,13 @@ ircd::m::room::messages::messages(const m::room &room,
|
|||
}
|
||||
|
||||
const ircd::m::event &
|
||||
ircd::m::room::messages::operator*()
|
||||
ircd::m::room::events::operator*()
|
||||
{
|
||||
return fetch(std::nothrow);
|
||||
};
|
||||
|
||||
bool
|
||||
ircd::m::room::messages::seek(const event::id &event_id)
|
||||
ircd::m::room::events::seek(const event::id &event_id)
|
||||
{
|
||||
const event::idx &event_idx
|
||||
{
|
||||
|
@ -1863,7 +1863,7 @@ ircd::m::room::messages::seek(const event::id &event_id)
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::messages::seek(const uint64_t &depth)
|
||||
ircd::m::room::events::seek(const uint64_t &depth)
|
||||
{
|
||||
char buf[dbs::ROOM_EVENTS_KEY_MAX_SIZE];
|
||||
const string_view seek_key
|
||||
|
@ -1878,7 +1878,7 @@ ircd::m::room::messages::seek(const uint64_t &depth)
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::messages::seek_idx(const event::idx &event_idx)
|
||||
ircd::m::room::events::seek_idx(const event::idx &event_idx)
|
||||
try
|
||||
{
|
||||
uint64_t depth(0);
|
||||
|
@ -1909,7 +1909,7 @@ catch(const db::not_found &e)
|
|||
return false;
|
||||
}
|
||||
|
||||
ircd::m::room::messages::operator
|
||||
ircd::m::room::events::operator
|
||||
ircd::m::event::idx()
|
||||
const
|
||||
{
|
||||
|
@ -1917,14 +1917,14 @@ const
|
|||
}
|
||||
|
||||
ircd::m::event::id::buf
|
||||
ircd::m::room::messages::event_id()
|
||||
ircd::m::room::events::event_id()
|
||||
const
|
||||
{
|
||||
return m::event_id(this->event_idx(), std::nothrow);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
ircd::m::room::messages::depth()
|
||||
ircd::m::room::events::depth()
|
||||
const
|
||||
{
|
||||
assert(bool(*this));
|
||||
|
@ -1937,7 +1937,7 @@ const
|
|||
}
|
||||
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::messages::event_idx()
|
||||
ircd::m::room::events::event_idx()
|
||||
const
|
||||
{
|
||||
assert(bool(*this));
|
||||
|
@ -1950,14 +1950,14 @@ const
|
|||
}
|
||||
|
||||
const ircd::m::event &
|
||||
ircd::m::room::messages::fetch()
|
||||
ircd::m::room::events::fetch()
|
||||
{
|
||||
m::seek(_event, event_idx());
|
||||
return _event;
|
||||
}
|
||||
|
||||
const ircd::m::event &
|
||||
ircd::m::room::messages::fetch(std::nothrow_t)
|
||||
ircd::m::room::events::fetch(std::nothrow_t)
|
||||
{
|
||||
m::seek(_event, event_idx(), std::nothrow);
|
||||
return _event;
|
||||
|
@ -3005,7 +3005,7 @@ ircd::m::room::state::space::rebuild::rebuild(const room::id &room_id)
|
|||
*m::dbs::events
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room_id, uint64_t(0)
|
||||
};
|
||||
|
@ -4378,7 +4378,7 @@ size_t
|
|||
ircd::m::room::stats::bytes_json(const m::room &room)
|
||||
{
|
||||
size_t ret(0);
|
||||
for(m::room::messages it(room); it; --it)
|
||||
for(m::room::events it(room); it; --it)
|
||||
{
|
||||
const m::event::idx &event_idx
|
||||
{
|
||||
|
|
|
@ -328,7 +328,7 @@ get_events_from(client &client,
|
|||
request.user_id
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room_id, event_id
|
||||
};
|
||||
|
|
|
@ -554,7 +554,7 @@ initialsync_room_timeline_events(client &client,
|
|||
// way back. This is not a big deal but rocksdb should fix their shit.
|
||||
ssize_t i(0);
|
||||
m::event::id::buf event_id;
|
||||
m::room::messages it{room};
|
||||
m::room::events it{room};
|
||||
for(; it && i < 10; --it, ++i)
|
||||
event_id = it.event_id();
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ get__context(client &client,
|
|||
ret, "events_before"
|
||||
};
|
||||
|
||||
m::room::messages before
|
||||
m::room::events before
|
||||
{
|
||||
room, event_id
|
||||
};
|
||||
|
@ -201,7 +201,7 @@ get__context(client &client,
|
|||
ret, "events_after"
|
||||
};
|
||||
|
||||
m::room::messages after
|
||||
m::room::events after
|
||||
{
|
||||
room, event_id
|
||||
};
|
||||
|
|
|
@ -214,7 +214,7 @@ get__initialsync_local(client &client,
|
|||
}});
|
||||
state.~array();
|
||||
|
||||
m::room::messages it{room};
|
||||
m::room::events it{room};
|
||||
json::stack::object messages
|
||||
{
|
||||
out, "messages"
|
||||
|
|
|
@ -90,7 +90,7 @@ get__messages(client &client,
|
|||
request.user_id
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room, page.from
|
||||
};
|
||||
|
|
|
@ -98,7 +98,7 @@ ircd::m::sync::room_ephemeral_m_receipt_m_read_polylog(data &data)
|
|||
if(data.phased && int64_t(data.range.first) == 0L)
|
||||
return false;
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
*data.room
|
||||
};
|
||||
|
|
|
@ -407,7 +407,7 @@ ircd::m::sync::room_state_phased_member_events(data &data,
|
|||
}
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
*data.room
|
||||
};
|
||||
|
|
|
@ -101,7 +101,7 @@ ircd::m::sync::room_summary_append_heroes(data &data)
|
|||
std::array<char[bufsz], count> buf;
|
||||
std::array<string_view, count> last;
|
||||
size_t ret(0), i(0);
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
*data.room
|
||||
};
|
||||
|
|
|
@ -236,7 +236,7 @@ ircd::m::sync::_room_timeline_polylog_events(data &data,
|
|||
// way back. This is not a big deal but rocksdb should fix their shit.
|
||||
m::event::id::buf event_id;
|
||||
m::event::idx event_idx {0};
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ ircd::m::sync::to_device_polylog(data &data)
|
|||
*data.out, "events"
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
data.user_room
|
||||
};
|
||||
|
|
|
@ -9492,7 +9492,7 @@ console_cmd__room__count(opt &out, const string_view &line)
|
|||
if(param[1])
|
||||
{
|
||||
size_t count{0};
|
||||
m::room::messages it{room};
|
||||
m::room::events it{room};
|
||||
for(; it && limit; --it, --limit)
|
||||
{
|
||||
const m::event &event{*it};
|
||||
|
@ -9547,7 +9547,7 @@ console_cmd__room__events(opt &out, const string_view &line)
|
|||
room_id
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room, uint64_t(depth >= 0? depth : -1)
|
||||
};
|
||||
|
@ -9595,7 +9595,7 @@ console_cmd__room__messages(opt &out, const string_view &line)
|
|||
room_id
|
||||
};
|
||||
|
||||
m::room::messages it{room};
|
||||
m::room::events it{room};
|
||||
if(depth >= 0 && depth < std::numeric_limits<int64_t>::max())
|
||||
it.seek(depth);
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ get__backfill(client &client,
|
|||
calc_limit(request)
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room_id, event_id
|
||||
};
|
||||
|
|
|
@ -103,7 +103,7 @@ get__backfill_ids(client &client,
|
|||
calc_limit(request)
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room
|
||||
};
|
||||
|
|
|
@ -183,7 +183,7 @@ ircd::m::room::head::reset(const head &head)
|
|||
{
|
||||
size_t ret{0};
|
||||
const auto &room{head.room};
|
||||
m::room::messages it{room};
|
||||
m::room::events it{room};
|
||||
if(!it)
|
||||
return ret;
|
||||
|
||||
|
@ -250,7 +250,7 @@ ircd::m::room::head::rebuild(const head &head)
|
|||
{ db::get::NO_CACHE }
|
||||
};
|
||||
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
head.room, 0UL, &fopts
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ ircd::m::room::timeline::for_each(coord &coord,
|
|||
const closure &closure)
|
||||
const
|
||||
{
|
||||
messages it
|
||||
events it
|
||||
{
|
||||
this->room, uint64_t(coord.y)
|
||||
};
|
||||
|
@ -99,7 +99,7 @@ const
|
|||
void
|
||||
ircd::m::room::timeline::rebuild(const m::room &room)
|
||||
{
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room, 0UL
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ const
|
|||
return rooms.for_each(rooms::closure_bool{[this, &closure]
|
||||
(const m::room &room, const string_view &membership)
|
||||
{
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room
|
||||
};
|
||||
|
|
|
@ -135,7 +135,7 @@ ircd::m::user::highlight::for_each(const m::room &room,
|
|||
const event::closure_idx_bool &closure)
|
||||
const
|
||||
{
|
||||
m::room::messages it
|
||||
m::room::events it
|
||||
{
|
||||
room
|
||||
};
|
||||
|
|
|
@ -453,7 +453,7 @@ ircd::m::media::file::read(const m::room &room,
|
|||
};
|
||||
|
||||
size_t ret{0};
|
||||
room::messages it
|
||||
room::events it
|
||||
{
|
||||
room, 1, &fopts
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue