diff --git a/ircd/m/event.cc b/ircd/m/event.cc index af134ecb6..ade650f81 100644 --- a/ircd/m/event.cc +++ b/ircd/m/event.cc @@ -496,15 +496,101 @@ ircd::m::event::signatures(const mutable_buffer &out, ircd::ed25519::sig ircd::m::event::sign(json::iov &event, - const json::iov &content) + const json::iov &contents) { - //TODO: essential keys - const json::iov::push _content + const auto &type { - event, { "content", "{}" } + event.at("type") }; - return sign(event); + if(type == "m.room.aliases") + { + const json::iov::push _content{event, + { + "content", json::members + { + { "aliases", contents.at("aliases") } + } + }}; + + return sign(event); + } + else if(type == "m.room.create") + { + const json::iov::push _content{event, + { + "content", json::members + { + { "creator", contents.at("creator") } + } + }}; + + return sign(event); + } + else if(type == "m.room.history_visibility") + { + const json::iov::push _content{event, + { + "content", json::members + { + { "history_visibility", contents.at("history_visibility") } + } + }}; + + return sign(event); + } + else if(type == "m.room.join_rules") + { + const json::iov::push _content{event, + { + "content", json::members + { + { "join_rule", contents.at("join_rule") } + } + }}; + + return sign(event); + } + else if(type == "m.room.member") + { + const json::iov::push _content{event, + { + "content", json::members + { + { "membership", contents.at("membership") } + } + }}; + + return sign(event); + } + else if(type == "m.room.power_levels") + { + const json::iov::push _content{event, + { + "content", json::members + { + { "ban", contents.at("ban") }, + { "events", contents.at("events") }, + { "events_default", contents.at("events_default") }, + { "kick", contents.at("kick") }, + { "redact", contents.at("redact") }, + { "state_default", contents.at("state_default") }, + { "users", contents.at("users") }, + { "users_default", contents.at("users_default") }, + } + }}; + + return sign(event); + } + else + { + const json::iov::push _content + { + event, { "content", "{}" } + }; + + return sign(event); + } } ircd::ed25519::sig