diff --git a/include/ircd/m/room/README.md b/include/ircd/m/room/README.md index 0228f522a..0069510bd 100644 --- a/include/ircd/m/room/README.md +++ b/include/ircd/m/room/README.md @@ -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 diff --git a/include/ircd/m/room/messages.h b/include/ircd/m/room/events.h similarity index 83% rename from include/ircd/m/room/messages.h rename to include/ircd/m/room/events.h index 427efb0e8..b00007766 100644 --- a/include/ircd/m/room/messages.h +++ b/include/ircd/m/room/events.h @@ -1,7 +1,7 @@ // Matrix Construct // // Copyright (C) Matrix Construct Developers, Authors & Contributors -// Copyright (C) 2016-2018 Jason Volk +// Copyright (C) 2016-2019 Jason Volk // // 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 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; }; diff --git a/include/ircd/m/room/room.h b/include/ircd/m/room/room.h index 55b91e7ca..d6accadfa 100644 --- a/include/ircd/m/room/room.h +++ b/include/ircd/m/room/room.h @@ -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" diff --git a/include/ircd/m/room/state.h b/include/ircd/m/room/state.h index 78d5c8651..755205f74 100644 --- a/include/ircd/m/room/state.h +++ b/include/ircd/m/room/state.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 { diff --git a/ircd/m_room.cc b/ircd/m_room.cc index 475c56eed..ba725b80e 100644 --- a/ircd/m_room.cc +++ b/ircd/m_room.cc @@ -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 { diff --git a/modules/client/events.cc b/modules/client/events.cc index da029fde3..b4115b5ae 100644 --- a/modules/client/events.cc +++ b/modules/client/events.cc @@ -328,7 +328,7 @@ get_events_from(client &client, request.user_id }; - m::room::messages it + m::room::events it { room_id, event_id }; diff --git a/modules/client/initialsync.cc b/modules/client/initialsync.cc index 98a43e8e3..2732e9a80 100644 --- a/modules/client/initialsync.cc +++ b/modules/client/initialsync.cc @@ -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(); diff --git a/modules/client/rooms/context.cc b/modules/client/rooms/context.cc index e8c1666f0..e2797fcc8 100644 --- a/modules/client/rooms/context.cc +++ b/modules/client/rooms/context.cc @@ -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 }; diff --git a/modules/client/rooms/initialsync.cc b/modules/client/rooms/initialsync.cc index ab9f6bab6..b7b3995d3 100644 --- a/modules/client/rooms/initialsync.cc +++ b/modules/client/rooms/initialsync.cc @@ -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" diff --git a/modules/client/rooms/messages.cc b/modules/client/rooms/messages.cc index 7854ce19b..5e238176a 100644 --- a/modules/client/rooms/messages.cc +++ b/modules/client/rooms/messages.cc @@ -90,7 +90,7 @@ get__messages(client &client, request.user_id }; - m::room::messages it + m::room::events it { room, page.from }; diff --git a/modules/client/sync/rooms/ephemeral/receipt.cc b/modules/client/sync/rooms/ephemeral/receipt.cc index a876b6f88..c313e4334 100644 --- a/modules/client/sync/rooms/ephemeral/receipt.cc +++ b/modules/client/sync/rooms/ephemeral/receipt.cc @@ -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 }; diff --git a/modules/client/sync/rooms/state.cc b/modules/client/sync/rooms/state.cc index 39f55a03b..25a36d9b0 100644 --- a/modules/client/sync/rooms/state.cc +++ b/modules/client/sync/rooms/state.cc @@ -407,7 +407,7 @@ ircd::m::sync::room_state_phased_member_events(data &data, } }; - m::room::messages it + m::room::events it { *data.room }; diff --git a/modules/client/sync/rooms/summary.cc b/modules/client/sync/rooms/summary.cc index 37c975f12..1d3e670e1 100644 --- a/modules/client/sync/rooms/summary.cc +++ b/modules/client/sync/rooms/summary.cc @@ -101,7 +101,7 @@ ircd::m::sync::room_summary_append_heroes(data &data) std::array buf; std::array last; size_t ret(0), i(0); - m::room::messages it + m::room::events it { *data.room }; diff --git a/modules/client/sync/rooms/timeline.cc b/modules/client/sync/rooms/timeline.cc index 209ae523c..2a664e1f5 100644 --- a/modules/client/sync/rooms/timeline.cc +++ b/modules/client/sync/rooms/timeline.cc @@ -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 }; diff --git a/modules/client/sync/to_device.cc b/modules/client/sync/to_device.cc index f0c8d95a1..574603744 100644 --- a/modules/client/sync/to_device.cc +++ b/modules/client/sync/to_device.cc @@ -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 }; diff --git a/modules/console.cc b/modules/console.cc index aec20c5d9..8b1a8b2bf 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -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::max()) it.seek(depth); diff --git a/modules/federation/backfill.cc b/modules/federation/backfill.cc index 4fbea33fc..662346528 100644 --- a/modules/federation/backfill.cc +++ b/modules/federation/backfill.cc @@ -102,7 +102,7 @@ get__backfill(client &client, calc_limit(request) }; - m::room::messages it + m::room::events it { room_id, event_id }; diff --git a/modules/federation/backfill_ids.cc b/modules/federation/backfill_ids.cc index 7a65e5a00..c3e4995ca 100644 --- a/modules/federation/backfill_ids.cc +++ b/modules/federation/backfill_ids.cc @@ -103,7 +103,7 @@ get__backfill_ids(client &client, calc_limit(request) }; - m::room::messages it + m::room::events it { room }; diff --git a/modules/m_room_head.cc b/modules/m_room_head.cc index d1ccbd185..8340cf4c8 100644 --- a/modules/m_room_head.cc +++ b/modules/m_room_head.cc @@ -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 }; diff --git a/modules/m_room_timeline.cc b/modules/m_room_timeline.cc index bd2672b90..541c80d79 100644 --- a/modules/m_room_timeline.cc +++ b/modules/m_room_timeline.cc @@ -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 }; diff --git a/modules/m_user_events.cc b/modules/m_user_events.cc index a595654a4..48e9b22e0 100644 --- a/modules/m_user_events.cc +++ b/modules/m_user_events.cc @@ -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 }; diff --git a/modules/m_user_highlight.cc b/modules/m_user_highlight.cc index 04dd9db5d..e96e46f19 100644 --- a/modules/m_user_highlight.cc +++ b/modules/m_user_highlight.cc @@ -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 }; diff --git a/modules/media/media.cc b/modules/media/media.cc index 912625634..91bbe28c0 100644 --- a/modules/media/media.cc +++ b/modules/media/media.cc @@ -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 };