From 745f392855739c243e5b9a087c7678437c5f38bb Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 27 Mar 2019 15:58:33 -0700 Subject: [PATCH] modules/webhook: Implement github organization type handler and member_added action. --- modules/webhook.cc | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) 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)