0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-13 08:23:56 +01:00

ircd:Ⓜ️:event: Add event::my(event::idx) query util; branch for event:🆔:host() use.

This commit is contained in:
Jason Volk 2019-12-10 11:05:33 -08:00
parent 2ea3cdcc9b
commit 5c74bfbd7f
2 changed files with 18 additions and 6 deletions

View file

@ -115,6 +115,7 @@ struct ircd::m::event
static constexpr const size_t &ORIGIN_MAX_SIZE {256};
static conf::item<size_t> max_size;
static bool my(const idx &);
static void essential(json::iov &event, const json::iov &content, const closure_iov_mutable &);
static bool verify(const json::object &, const ed25519::pk &, const ed25519::sig &sig);
static ed25519::sig sign(const string_view &, const ed25519::sk &);

View file

@ -194,7 +194,7 @@ ircd::m::event::signatures(const mutable_buffer &out,
const string_view public_key_id
{
m::public_key_id(my(origin))
m::public_key_id(m::my(origin))
};
thread_local char sigb64buf[b64encode_size(sizeof(sig))];
@ -277,7 +277,7 @@ ircd::m::event::sign(json::iov &event,
const auto &secret_key
{
m::secret_key(my(origin))
m::secret_key(m::my(origin))
};
return sign(event, contents, secret_key);
@ -337,7 +337,7 @@ ircd::m::event::sign(const json::object &event)
const auto &secret_key
{
m::secret_key(my(origin))
m::secret_key(m::my(origin))
};
return sign(event, secret_key);
@ -367,7 +367,7 @@ ircd::m::event::sign(const string_view &event)
const auto &secret_key
{
m::secret_key(my(origin))
m::secret_key(m::my(origin))
};
return sign(event, secret_key);
@ -1033,8 +1033,19 @@ ircd::m::my(const event &event)
bool
ircd::m::my(const id::event &event_id)
{
assert(event_id.host());
return self::host(event_id.host());
return event_id.version() == "1"?
self::host(event_id.host()):
event::my(index(event_id));
}
bool
ircd::m::event::my(const idx &event_idx)
{
return m::query(std::nothrow, event_idx, "origin", []
(const string_view &origin)
{
return m::my_host(origin);
});
}
//