diff --git a/modules/webhook.cc b/modules/webhook.cc index 0ee8cac0a..bb676e75d 100644 --- a/modules/webhook.cc +++ b/modules/webhook.cc @@ -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 << " " + << "" + << action + << "" + ; + + if(action == "member_added") + { + const json::object &membership + { + content["membership"] + }; + + const json::object &user + { + membership["user"] + }; + + out << " " + << "" + << unquote(user["login"]) + << "" + ; + + out << " with role " + << unquote(membership["role"]) + ; + } + + return out; +} + std::ostream & github_handle__watch(std::ostream &out, const json::object &content)