Basic nodeinfo/2.1 implementation

master
teknomunk 1 year ago
parent 996da6dd87
commit 38856cb9ad

@ -3,6 +3,7 @@
#include "controller/mastodon_api.h"
#include "controller/oauth.h"
#include "controller/webfinger.h"
#include "controller/nodeinfo.h"
#include "controller/owner.h"
bool route_asset( struct http_request* req )
@ -38,7 +39,9 @@ bool route_request( struct http_request* req )
return route_owner( req );
} else if( http_request_route( req, "/.well-known" ) ) {
if( http_request_route( req, "/webfinger?" ) ) {
return route_well_known( req );
return route_wellknown_webfinger( req );
} else if( http_request_route( req, "/nodeinfo" ) ) {
return route_wellknown_nodeinfo( req );
}
} else if( http_request_route( req, "/assets/" ) ) {
printf( "handling asset\n" );

@ -0,0 +1,30 @@
#include "nodeinfo.h"
#include "http_server/http_request.h"
#include "model/server.h"
#include <stdio.h>
bool route_wellknown_nodeinfo( struct http_request* req )
{
http_request_send_headers( req, 200, "application/json", true );
FILE* f = http_request_get_response_body(req);
#define RENDER
#include "src/view/nodeinfo.json.inc"
#undef RENDER
return true;
}
bool route_nodeinfo( struct http_request* req )
{
if( http_request_route( req, "/2.1" ) ) {
http_request_send_headers( req, 200, "application/json", true );
FILE* f = http_request_get_response_body(req);
#define RENDER
#include "src/view/nodeinfo_2_1.json.inc"
#undef RENDER
return true;
}
return false;
}

@ -0,0 +1,9 @@
#pragma once
#include <stdbool.h>
struct http_request;
bool route_wellknown_nodeinfo( struct http_request* req );
bool route_nodeinfo( struct http_request* req );

@ -4,7 +4,7 @@
#include <string.h>
bool route_well_known( struct http_request* req )
bool route_wellknown_webfinger( struct http_request* req )
{
// /.well-known/webfinger?resource=acct:teknomunk@apogee.polaris-1.work
const char* key;

@ -4,5 +4,5 @@
struct http_request;
bool route_well_known( struct http_request* );
bool route_wellknown_webfinger( struct http_request* );

@ -0,0 +1,5 @@
#include "server.h"
// TODO: make this configurable
const char* g_server_name = "apogee.polaris-1.work";

@ -0,0 +1,4 @@
#pragma once
extern const char* g_server_name;

@ -0,0 +1,9 @@
{
"links": [
{
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.1",
"href": "https://%s{g_server_name}/nodeinfo/2.1"
}
]
}

@ -0,0 +1,26 @@
{
"version": "2.1",
"software": {
"name": "apogee",
"version": "0.1alpha",
"repository": "https://gitea.polaris-1.work/teknomunk/apogee",
},
"protocols": ["activitypub"],
"services": {
"inbound": [],
"outbound": []
},
"openRegistrations": false,
"usage": {
"users": {
"total": 1,
"activeHalfyear": 0,
"activeMonth": 0
},
"localPosts": 0,
"localComments": 0
},
"metadata": {
"chat_enabled": false
}
}
Loading…
Cancel
Save