diff --git a/modules/webhook.cc b/modules/webhook.cc index 2ef607c0b..ba8557cce 100644 --- a/modules/webhook.cc +++ b/modules/webhook.cc @@ -100,6 +100,10 @@ static std::ostream & github_handle__pull_request(std::ostream &, const json::object &content); +static std::ostream & +github_handle__issues(std::ostream &, + const json::object &content); + static std::ostream & github_handle__ping(std::ostream &, const json::object &content); @@ -155,6 +159,8 @@ github_handle(client &client, github_handle__push(out, request.content); else if(type == "pull_request") github_handle__pull_request(out, request.content); + else if(type == "issues") + github_handle__issues(out, request.content); if(!string_view(webhook_room)) return; @@ -442,6 +448,81 @@ github_handle__pull_request(std::ostream &out, return out; } +static std::ostream & +github_handle__issues(std::ostream &out, + const json::object &content) +{ + out << " " + << "" + << unquote(content["action"]) + << "" + ; + + const json::object issue + { + content["issue"] + }; + + switch(hash(unquote(content["action"]))) + { + case "assigned"_: + case "unassigned"_: + { + const json::object assignee + { + content["assignee"] + }; + + out << " " + << "" + << unquote(assignee["login"]) + << "" + ; + + break; + } + } + + out << " " + << "" + << "" + << unquote(issue["title"]) + << "" + << "" + ; + + if(unquote(content["action"]) == "opened") + { + out << " " + << "
" + << "
"
+		    ;
+
+		static const auto delim("\\r\\n");
+		const auto body(unquote(issue["body"]));
+		auto lines(split(body, delim)); do
+		{
+			out << lines.first
+			    << "
" + ; + + lines = split(lines.second, delim); + } + while(!empty(lines.second)); + + out << "" + << "
" + << "
" + ; + } + + return out; +} + static std::ostream & github_handle__ping(std::ostream &out, const json::object &content)