diff --git a/src/database/sqlite/sqlite.cpp b/src/database/sqlite/sqlite.cpp index 20afee3..86d047d 100644 --- a/src/database/sqlite/sqlite.cpp +++ b/src/database/sqlite/sqlite.cpp @@ -325,16 +325,16 @@ User SQLite::get_user(const decltype(User::acct)& acct) // It's still recommended to use them for clarity bool SQLite::try_migration() { - const char* create_tables[] = { - R"sql( + const char *create_tables[] = { + R"sql( CREATE TABLE IF NOT EXISTS instances ( id INTEGER PRIMARY KEY ASC, host TEXT, users_count INTEGER ) )sql", - - R"sql( + + R"sql( CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY ASC, email TEXT, @@ -390,6 +390,37 @@ CREATE TABLE IF NOT EXISTS applications ( created_at DATETIME, updated_at DATETIME ) +)sql", + + R"sql( +CREATE TABLE IF NOT EXISTS statuses ( + id INTEGER PRIMARY KEY ASC, + application TEXT, + content TEXT, + language TEXT, + mentions TEXT, /* comma separated array */ + +) +)sql", + + /* I was on the fence for if it's better to store databases in something + * more editor friendly, such as XML, but I figured most users would be + * happy just dragging their database file around. + * + * On the `config' schema key: Consider modules. Someone adds a payment + * system for each post... and they want an easy way to configure it, and + * they want to _not_ touch Wormhole's source code and give it to other + * people... strange example indeed, but that's what that's for. + */ + R"sql( +CREATE TABLE IF NOT EXISTS config ( + id INTEGER PRIMARY KEY CHECK (id = 0), + instance_name TEXT NOT NULL, + instance_domain TEXT NOT NULL, /* Full URL */ + instance_description TEXT, /* Full URL */ + instance_logo INTEGER, /* media */ + config BLOB, +) )sql", // R"sql( diff --git a/src/protocol/activitypub/activitypub.cpp b/src/protocol/activitypub/activitypub.cpp index 13ecf7b..da37e50 100644 --- a/src/protocol/activitypub/activitypub.cpp +++ b/src/protocol/activitypub/activitypub.cpp @@ -21,7 +21,10 @@ using namespace Protocol; -HTTP::Response Route::ActivityPub::user_inbox(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg) +HTTP::Response +Route::ActivityPub::user_inbox(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg) { using namespace std::string_literals; @@ -55,7 +58,10 @@ HTTP::Response Route::ActivityPub::user_inbox(std::any& args, const HTTP::Reques return HTTP::Response( rjson::to_string(root), HTTP::MIME::ACTIVITY_JSON ); } -HTTP::Response Route::ActivityPub::user_outbox(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg) +HTTP::Response +Route::ActivityPub::user_outbox(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg) { using namespace std::string_literals; @@ -88,7 +94,10 @@ HTTP::Response Route::ActivityPub::user_outbox(std::any& args, const HTTP::Reque return HTTP::Response( rjson::to_string(root), HTTP::MIME::ACTIVITY_JSON ); } -HTTP::Response Route::ActivityPub::user_followers(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg) +HTTP::Response +Route::ActivityPub::user_followers(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg) { using namespace std::string_literals; @@ -121,7 +130,10 @@ HTTP::Response Route::ActivityPub::user_followers(std::any& args, const HTTP::Re return HTTP::Response( rjson::to_string(root), HTTP::MIME::ACTIVITY_JSON ); } -HTTP::Response Route::ActivityPub::user_following(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg) +HTTP::Response +Route::ActivityPub::user_following(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg) { DESTRUCT_WORMHOLE_ARGS(args); using namespace std::string_literals; diff --git a/src/protocol/activitypub/activitypub.h b/src/protocol/activitypub/activitypub.h index 9edd324..04c8ca3 100644 --- a/src/protocol/activitypub/activitypub.h +++ b/src/protocol/activitypub/activitypub.h @@ -6,7 +6,10 @@ #pragma once #ifndef MODULE_WEBFINGER -#warning "You SHOULD (think: MUST) build Webfinger support if you want to build ActivityPub support. If you don't, then there wont be a way for most servers to discover users on your server. If you are simply testing ActivityPub routes, then you can ignore this message." +#warning "You SHOULD (think: MUST) build Webfinger support if you want to" \ + " build ActivityPub support. If you don't, then there wont be a way for" \ + " most servers to discover users on your server. If you are simply testing" \ + " ActivityPub routes, then you can safely ignore this message." #endif #include "http/httpserver.h" @@ -16,11 +19,21 @@ namespace Route { namespace ActivityPub { - HTTP::Response user_inbox(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg); - HTTP::Response user_outbox(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg); - HTTP::Response user_following(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg); - HTTP::Response user_followers(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg); - HTTP::Response user(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg); + HTTP::Response user_inbox(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg); + HTTP::Response user_outbox(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg); + HTTP::Response user_following(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg); + HTTP::Response user_followers(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg); + HTTP::Response user(std::any& args, + const HTTP::Request& req, + const HTTP::RequestArgs_t& arg); } } diff --git a/src/protocol/masto-api/apps.cpp b/src/protocol/masto-api/apps.cpp index b6abb3d..d3d0116 100644 --- a/src/protocol/masto-api/apps.cpp +++ b/src/protocol/masto-api/apps.cpp @@ -55,8 +55,7 @@ HTTP::Response Route::MastoAPI::create_app(std::any& args, const std::string& website = req.param.at("website").string(); root.AddMember("website", website, a); } - catch(...) - { + catch(...) { root.AddMember("website", rjson::Value(), a); } // Tokens