/* This file is part of FediBlock-backend. * Copyright © 2020 tastytea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #include "cgi.hpp" #include "files.hpp" #include "fs-compat.hpp" #include "git.hpp" #include "gitea.hpp" #include "json.hpp" #include #include #include #include using std::cerr; using std::cout; using std::exception; using std::to_string; using namespace FediBlock; void print_debug(const cgi::entry_type &entry) { cout << "\r\n\r\nDEBUG:\r\n"; cout << " Instance: " << entry.instance << "\r\n"; cout << " Tags:"; for (const auto &tag : entry.tags) { cout << " " << tag; } cout << "\r\n"; cout << " Receipts:"; for (const auto &receipt : entry.receipts) { cout << " " << receipt; } cout << "\r\n"; cout << " Description: " << entry.description << "\r\n"; cout << " Screenshot: " << entry.screenshot_filepath << "\r\n"; cout << "\r\n\r\nJSON:\r\n"; cout << json::to_json(entry) << "\r\n"; cout << "\r\n\r\nDATADIR: " << files::get_datadir() << "\r\n"; } int main() { cout << "Content-Type: text/plain; charset=utf-8\r\n\r\n"; cout << "Received and filed to /dev/null. 😝\r\n"; const cgi::entry_type entry{cgi::parse_formdata()}; print_debug(entry); git_libgit2_init(); git::clone(); git::create_branch(); git::commit(entry); git::push(); cout << "Created branch: " << "\r\n"; gitea::init(); gitea::pull_request("web-" + to_string(git::get_last_id()), entry); try { files::remove_tmpdir(); } catch (const exception &e) { cerr << e.what() << '\n'; } git_libgit2_shutdown(); gitea::cleanup(); return 0; }