Ugly webfinger show-off

FossilOrigin-Name: f1d46a480c7f0447faf0a5184f5b72e9e50270f591e51fd28e95bad03b8b8b45
This commit is contained in:
nekobit 2022-10-07 01:34:01 +00:00
parent a45c13f4b5
commit 634b86fe1a

View file

@ -56,30 +56,31 @@ namespace
// TODO a lot
HTTP::Response Route::webfinger(std::any& args, const HTTP::Request& req, const HTTP::RequestArgs_t& arg)
{
using namespace std::string_literals;
rapidjson::Document root(rapidjson::kObjectType);
rapidjson::Document::AllocatorType& a = root.GetAllocator();
rapidjson::Value links(rapidjson::kArrayType);
// Logger::instance() << req.get.at("resource").string();
const std::string& resource = req.get.at("resource").string();
// Add profile page
links.PushBack(make_resource({"https://localhost/users/",
links.PushBack(make_resource({"https://localhost/users/"s + resource,
"http://webfinger.net/rel/profile-page",
"text/html", {}}, a), a);
// Add self page
links.PushBack(make_resource({"https://localhost/users/",
links.PushBack(make_resource({"https://localhost/users/"s + resource,
"self",
"application/activity+json", {}}, a), a);
// Add activity stream
links.PushBack(make_resource({"https://localhost/",
links.PushBack(make_resource({"https://localhost/users/"s + resource,
"http://webfinger.net/rel/profile-page",
"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", {}}, a), a);
root.AddMember("links", links.Move(), root.GetAllocator());
root.AddMember("subject", "acct:", a);
root.AddMember("subject", rapidjson::Value(std::string("acct:"s + resource).c_str(), a).Move(), a);
// Stringify TODO write helper!
rapidjson::StringBuffer buf;