mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 02:18:53 +02:00
ircd:Ⓜ️:event: Add a source json::object as a member.
This commit is contained in:
parent
d798124c03
commit
f857e25ea7
4 changed files with 26 additions and 43 deletions
|
@ -109,11 +109,13 @@ struct ircd::m::event
|
|||
static sha256::buf hash(json::iov &event, const string_view &content);
|
||||
static json::object hashes(const mutable_buffer &, json::iov &event, const string_view &content);
|
||||
|
||||
using super_type::tuple;
|
||||
using super_type::operator=;
|
||||
json::object source; // Contextual availability only.
|
||||
|
||||
event(const idx &, const mutable_buffer &buf);
|
||||
event(const id &, const mutable_buffer &buf);
|
||||
using super_type::tuple;
|
||||
event(const json::object &);
|
||||
event() = default;
|
||||
|
||||
using super_type::operator=;
|
||||
event &operator=(const json::object &);
|
||||
};
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -435,40 +435,24 @@ ircd::m::event::max_size
|
|||
// event::event
|
||||
//
|
||||
|
||||
ircd::m::event::event(const id &id,
|
||||
const mutable_buffer &buf)
|
||||
:event
|
||||
ircd::m::event::event(const json::object &source)
|
||||
:super_type
|
||||
{
|
||||
index(id), buf
|
||||
source
|
||||
}
|
||||
,source
|
||||
{
|
||||
source
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::m::event::event(const idx &idx,
|
||||
const mutable_buffer &buf)
|
||||
ircd::m::event &
|
||||
ircd::m::event::operator=(const json::object &source)
|
||||
{
|
||||
assert(bool(dbs::events));
|
||||
|
||||
db::gopts opts;
|
||||
for(size_t i(0); i < dbs::event_column.size(); ++i)
|
||||
{
|
||||
const db::cell cell
|
||||
{
|
||||
dbs::event_column[i], byte_view<string_view>{idx}, opts
|
||||
};
|
||||
|
||||
db::assign(*this, cell, byte_view<string_view>{idx});
|
||||
}
|
||||
|
||||
const json::object obj
|
||||
{
|
||||
string_view
|
||||
{
|
||||
data(buf), json::print(buf, *this)
|
||||
}
|
||||
};
|
||||
|
||||
new (this) m::event(obj);
|
||||
this->super_type::operator=(source);
|
||||
this->source = source;
|
||||
return *this;
|
||||
}
|
||||
|
||||
namespace ircd::m
|
||||
|
@ -1559,7 +1543,7 @@ ircd::m::seek(event::fetch &fetch,
|
|||
if(query_json)
|
||||
{
|
||||
if((fetch.valid = fetch._json.load(key, opts.gopts)))
|
||||
event = m::event
|
||||
event = json::object
|
||||
{
|
||||
fetch._json.val()
|
||||
};
|
||||
|
|
|
@ -260,14 +260,16 @@ bootstrap(const string_view &host,
|
|||
64_KiB
|
||||
};
|
||||
|
||||
const m::event mevent
|
||||
const m::event::fetch mevent
|
||||
{
|
||||
event_id, ebuf
|
||||
event_id
|
||||
};
|
||||
|
||||
const string_view strung
|
||||
{
|
||||
data(ebuf), serialized(mevent)
|
||||
mevent.source?
|
||||
string_view{mevent.source}:
|
||||
string_view{data(ebuf), serialized(mevent)}
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf2
|
||||
|
|
|
@ -5939,14 +5939,9 @@ console_cmd__eval(opt &out, const string_view &line)
|
|||
param[1]
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
const m::event::fetch event
|
||||
{
|
||||
64_KiB
|
||||
};
|
||||
|
||||
const m::event event
|
||||
{
|
||||
event_id, buf
|
||||
event_id
|
||||
};
|
||||
|
||||
m::vm::opts opts;
|
||||
|
|
Loading…
Reference in a new issue