2019-12-11 20:01:11 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 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_RELATES_H
|
|
|
|
|
|
|
|
namespace ircd::m
|
|
|
|
{
|
2022-08-14 01:45:43 +02:00
|
|
|
struct relates;
|
2019-12-11 20:01:11 +01:00
|
|
|
struct relates_to;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ircd::m::relates_to
|
|
|
|
:json::tuple
|
|
|
|
<
|
2022-08-14 01:45:43 +02:00
|
|
|
/// Target event_id
|
2019-12-11 20:01:11 +01:00
|
|
|
json::property<name::event_id, json::string>,
|
2022-08-14 01:45:43 +02:00
|
|
|
|
|
|
|
/// Relation type
|
2022-08-05 03:25:49 +02:00
|
|
|
json::property<name::rel_type, json::string>,
|
2022-08-14 01:45:43 +02:00
|
|
|
|
|
|
|
/// m.in_reply_to object
|
2022-08-05 03:25:49 +02:00
|
|
|
json::property<name::m_in_reply_to, json::object>
|
2019-12-11 20:01:11 +01:00
|
|
|
>
|
|
|
|
{
|
|
|
|
using super_type::tuple;
|
|
|
|
using super_type::operator=;
|
|
|
|
};
|
2022-08-14 01:45:43 +02:00
|
|
|
|
|
|
|
/// Interface to the rel_type of the M_RELATES dbs::ref type
|
|
|
|
///
|
|
|
|
struct ircd::m::relates
|
|
|
|
{
|
|
|
|
event::refs refs;
|
|
|
|
|
|
|
|
public:
|
|
|
|
using closure = util::closure_bool
|
|
|
|
<
|
|
|
|
std::function,
|
|
|
|
const event::idx &, const json::object &, const m::relates_to &
|
|
|
|
>;
|
|
|
|
|
|
|
|
bool for_each(const string_view &type, const closure &) const;
|
|
|
|
bool for_each(const closure &) const;
|
|
|
|
|
|
|
|
event::idx get(const string_view &type, const uint at = 0) const;
|
|
|
|
event::idx latest(const string_view &type, uint *const at = nullptr) const;
|
|
|
|
|
|
|
|
bool has(const string_view &type, const event::idx &) const;
|
|
|
|
bool has(const string_view &type) const;
|
|
|
|
bool has(const event::idx &) const;
|
|
|
|
|
|
|
|
size_t count(const string_view &type = {}) const;
|
|
|
|
bool prefetch(const string_view &type = {}, const bool depth = false) const;
|
|
|
|
|
|
|
|
relates(const event::refs &refs)
|
|
|
|
:refs{refs}
|
|
|
|
{}
|
|
|
|
};
|