Add json::pull_request_body().

This commit is contained in:
tastytea 2020-07-02 00:18:40 +02:00
parent 119d304164
commit 772d982ea8
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -20,15 +20,20 @@
#include "cgi.hpp"
#include <string>
#include <string_view>
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