0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

ircd:Ⓜ️ Branch for spec essential keys in event signing.

This commit is contained in:
Jason Volk 2018-03-08 14:17:47 -08:00
parent e53582d749
commit b9400e1698

View file

@ -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