2022-08-14 05:06:18 +02:00
|
|
|
// The Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) The Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2022 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_MESSAGES_H
|
|
|
|
|
2022-09-28 20:47:56 +02:00
|
|
|
namespace ircd::m
|
|
|
|
{
|
|
|
|
/// Returns `true` if `msg` reassigned with content from fetched `buf`.
|
|
|
|
bool replace(room::message &msg, event::fetch &buf, const event::idx &);
|
|
|
|
}
|
|
|
|
|
2022-08-14 05:06:18 +02:00
|
|
|
/// Rendering
|
|
|
|
///
|
|
|
|
struct ircd::m::room::messages
|
|
|
|
{
|
2023-02-17 05:53:30 +01:00
|
|
|
using closure = util::function_bool
|
2022-08-14 05:06:18 +02:00
|
|
|
<
|
2023-02-17 05:53:30 +01:00
|
|
|
const message &, const uint64_t &, const event::idx &
|
2022-08-14 05:06:18 +02:00
|
|
|
>;
|
|
|
|
|
|
|
|
static const event::fetch::opts fopts;
|
|
|
|
|
|
|
|
room::type events;
|
2022-09-29 00:02:02 +02:00
|
|
|
bool redacted {false};
|
2022-08-14 05:06:18 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
bool for_each(const closure &) const;
|
|
|
|
|
|
|
|
messages(const m::room &,
|
2022-09-29 00:02:02 +02:00
|
|
|
const decltype(room::type::range) & = { -1UL, -1L },
|
|
|
|
const bool redacted = false);
|
2022-08-14 05:06:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
|
|
|
ircd::m::room::messages::messages(const m::room &room,
|
2022-09-29 00:02:02 +02:00
|
|
|
const decltype(room::type::range) &range,
|
|
|
|
const bool redacted)
|
2022-08-14 05:06:18 +02:00
|
|
|
:events
|
|
|
|
{
|
|
|
|
room.room_id,
|
|
|
|
"m.room.message",
|
|
|
|
range,
|
|
|
|
false,
|
|
|
|
}
|
2022-09-29 00:02:02 +02:00
|
|
|
,redacted
|
|
|
|
{
|
|
|
|
redacted
|
|
|
|
}
|
2022-08-14 05:06:18 +02:00
|
|
|
{}
|