0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-02 16:58:19 +02:00

modules/webhook: Implement github organization type handler and member_added action.

This commit is contained in:
Jason Volk 2019-03-27 15:58:33 -07:00
parent 0e5b10816a
commit 745f392855

View file

@ -116,6 +116,10 @@ static std::ostream &
github_handle__label(std::ostream &,
const json::object &content);
static std::ostream &
github_handle__organization(std::ostream &,
const json::object &content);
static std::ostream &
github_handle__ping(std::ostream &,
const json::object &content);
@ -179,6 +183,8 @@ github_handle(client &client,
github_handle__watch(out, request.content);
else if(type == "label")
github_handle__label(out, request.content);
else if(type == "organization")
github_handle__organization(out, request.content);
if(!string_view(webhook_room))
return;
@ -793,6 +799,47 @@ github_handle__label(std::ostream &out,
return out;
}
std::ostream &
github_handle__organization(std::ostream &out,
const json::object &content)
{
const json::string &action
{
content["action"]
};
out << " "
<< "<b>"
<< action
<< "</b>"
;
if(action == "member_added")
{
const json::object &membership
{
content["membership"]
};
const json::object &user
{
membership["user"]
};
out << " "
<< "<a href=" << user["html_url"] << ">"
<< unquote(user["login"])
<< "</a>"
;
out << " with role "
<< unquote(membership["role"])
;
}
return out;
}
std::ostream &
github_handle__watch(std::ostream &out,
const json::object &content)