From 772d982ea88c421f6f4f02f77e6d5546ce3deb86 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 2 Jul 2020 00:18:40 +0200 Subject: [PATCH] Add json::pull_request_body(). --- src/json.cpp | 9 +++++++++ src/json.hpp | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/json.cpp b/src/json.cpp index bc34ab1..e64e173 100644 --- a/src/json.cpp +++ b/src/json.cpp @@ -33,4 +33,13 @@ string to_json(const cgi::entry_type &entry) return json.dump(4); } +string pull_request_body(string_view branch, const cgi::entry_type &entry) +{ + const nlohmann::json json{{"base", "main"}, + {"head", branch}, + {"title", "From web: " + entry.instance}, + {"body", entry.description}}; + return json.dump(); +} + } // namespace FediBlock::json diff --git a/src/json.hpp b/src/json.hpp index 02a0fd2..e0501ea 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -20,15 +20,20 @@ #include "cgi.hpp" #include +#include namespace FediBlock::json { using std::string; +using std::string_view; // Convert an entry_type into a JSON string. [[nodiscard]] string to_json(const cgi::entry_type &entry); +[[nodiscard]] string pull_request_body(string_view branch, + const cgi::entry_type &entry); + } // namespace FediBlock::json #endif // FEDIBLOCK_BACKEND_JSON_HPP