ircd:Ⓜ️:user::keys: Implement m.signing_key_update broadcast interface.
This commit is contained in:
parent
ca80d66e85
commit
9301980f9d
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
struct ircd::m::user::keys
|
struct ircd::m::user::keys
|
||||||
{
|
{
|
||||||
|
struct send;
|
||||||
|
|
||||||
static string_view make_sigs_state_key(const mutable_buffer &, const string_view &tgt, const string_view &src);
|
static string_view make_sigs_state_key(const mutable_buffer &, const string_view &tgt, const string_view &src);
|
||||||
static std::tuple<string_view, string_view> unmake_sigs_state_key(const string_view &) noexcept;
|
static std::tuple<string_view, string_view> unmake_sigs_state_key(const string_view &) noexcept;
|
||||||
|
|
||||||
|
@ -39,6 +41,12 @@ struct ircd::m::user::keys
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ircd::m::user::keys::send
|
||||||
|
{
|
||||||
|
send(const m::user::keys &,
|
||||||
|
const string_view = {});
|
||||||
|
};
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ircd::m::user::keys::cross_user(json::stack::object &out)
|
ircd::m::user::keys::cross_user(json::stack::object &out)
|
||||||
const
|
const
|
||||||
|
|
|
@ -8,6 +8,85 @@
|
||||||
// copyright notice and this permission notice is present in all copies. The
|
// copyright notice and this permission notice is present in all copies. The
|
||||||
// full license for this software is available in the LICENSE file.
|
// full license for this software is available in the LICENSE file.
|
||||||
|
|
||||||
|
ircd::m::user::keys::send::send(const m::user::keys &user_keys,
|
||||||
|
const string_view room_id)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto &user_id
|
||||||
|
{
|
||||||
|
user_keys.user_room.user.user_id
|
||||||
|
};
|
||||||
|
|
||||||
|
const unique_mutable_buffer keys_buf[2]
|
||||||
|
{
|
||||||
|
{ 4_KiB },
|
||||||
|
{ 4_KiB },
|
||||||
|
};
|
||||||
|
|
||||||
|
json::stack keys[2]
|
||||||
|
{
|
||||||
|
{ keys_buf[0] },
|
||||||
|
{ keys_buf[1] },
|
||||||
|
};
|
||||||
|
|
||||||
|
// master
|
||||||
|
{
|
||||||
|
json::stack::object object{keys[0]};
|
||||||
|
user_keys.cross_master(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
// self
|
||||||
|
{
|
||||||
|
json::stack::object object{keys[1]};
|
||||||
|
user_keys.cross_self(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
json::iov event, content;
|
||||||
|
const json::iov::push push[]
|
||||||
|
{
|
||||||
|
{ event, { "type", "m.signing_key_update" } },
|
||||||
|
{ event, { "sender", user_id } },
|
||||||
|
{ content, { "master_key", keys[0].completed() } },
|
||||||
|
{ content, { "self_signing_key", keys[1].completed() } },
|
||||||
|
{ content, { "user_id", user_id } },
|
||||||
|
};
|
||||||
|
|
||||||
|
// For diagnostic purposes; usually not defined.
|
||||||
|
const json::iov::push push_room_id
|
||||||
|
{
|
||||||
|
event, m::valid(m::id::ROOM, room_id),
|
||||||
|
{
|
||||||
|
"room_id", [&room_id]
|
||||||
|
{
|
||||||
|
return room_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
m::vm::copts opts;
|
||||||
|
opts.edu = true;
|
||||||
|
opts.prop_mask.reset();
|
||||||
|
opts.prop_mask.set("origin");
|
||||||
|
opts.notify_clients = false;
|
||||||
|
m::vm::eval
|
||||||
|
{
|
||||||
|
event, content, opts
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch(const ctx::interrupted &)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
catch(const std::exception &e)
|
||||||
|
{
|
||||||
|
log::error
|
||||||
|
{
|
||||||
|
m::log, "Sending m.signing_key_update for %s :%s",
|
||||||
|
string_view{user_keys.user_room.user.user_id},
|
||||||
|
e.what(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::m::user::keys::device(json::stack::object &out,
|
ircd::m::user::keys::device(json::stack::object &out,
|
||||||
const string_view &device_id)
|
const string_view &device_id)
|
||||||
|
|
|
@ -14515,6 +14515,43 @@ console_id__device(opt &out,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
console_cmd__user__keys__update(opt &out, const string_view &line)
|
||||||
|
{
|
||||||
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"user_id", "room_id"
|
||||||
|
}};
|
||||||
|
|
||||||
|
const m::user::id &user_id
|
||||||
|
{
|
||||||
|
param.at("user_id")
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::room::id::buf room_id
|
||||||
|
{
|
||||||
|
m::valid(m::id::ROOM, param["room_id"])?
|
||||||
|
m::room_id(param["room_id"]):
|
||||||
|
m::room::id::buf{}
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::user::keys keys
|
||||||
|
{
|
||||||
|
user_id
|
||||||
|
};
|
||||||
|
|
||||||
|
m::user::keys::send
|
||||||
|
{
|
||||||
|
keys, room_id
|
||||||
|
};
|
||||||
|
|
||||||
|
out
|
||||||
|
<< "broadcast: "
|
||||||
|
<< user_id
|
||||||
|
<< std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__user__ignores(opt &out, const string_view &line)
|
console_cmd__user__ignores(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue