mirror of
https://github.com/matrix-construct/construct
synced 2024-10-02 13:48:53 +02:00
modules/webhook: Implement github organization type handler and member_added action.
This commit is contained in:
parent
0e5b10816a
commit
745f392855
1 changed files with 47 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue