diff --git a/.gitmodules b/.gitmodules index 4519c08..ea3b9b1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -31,3 +31,6 @@ [submodule "src/json-ld"] path = src/json-ld url = https://gitea.polaris-1.work/teknomunk/json-ld.git +[submodule "src/util"] + path = src/util + url = https://gitea.polaris-1.work/teknomunk/util.git diff --git a/build.sh b/build.sh index 820d5d2..967571a 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,7 @@ set -e rm debug release 2>/dev/null || true find src | grep -E "\.template$" | while read FILE; do - ruby src/embed.rb "$FILE" + ruby tools/builder/tools/embed.rb "$FILE" done ruby tools/builder/build.rb src/apogee.build.json diff --git a/src/controller/pleroma_api.c b/src/controller/pleroma_api.c index f0679f4..f94520a 100644 --- a/src/controller/pleroma_api.c +++ b/src/controller/pleroma_api.c @@ -14,6 +14,20 @@ bool http_request_route_id( struct http_request* req, int* id ); +// Route: /api/v1/pleroma/statuses/%d{s->id}/quotes +void show_status_quotes( struct http_request* req, struct status* s ) +{ + struct { + struct status** items; + int count; + } quotes; + + status_get_quotes( s, "es ); + printf( "Got %d statuses\n", quotes.count ); + + show_statuses( req, quotes.items, quotes.count ); +} + // Route: /api/v1/pleroma/statuses/reactions/ static bool handle_reactions( struct http_request* req, struct status* s ) { @@ -57,8 +71,13 @@ static bool handle_reactions( struct http_request* req, struct status* s ) // Route: /api/v1/pleroma/statuses static bool route_status( struct http_request* req, struct status* s ) { + printf( __FILE__ " route_status. Remaining: '%s'\n", http_request_get_remaining_path(req) ); if( http_request_route( req, "reactions/" ) ) { return handle_reactions( req, s ); + } else if( http_request_route_term( req, "quotes" ) ) { + printf( __FILE__ " quotes\n" ); + show_status_quotes( req, s ); + return true; } return false; @@ -88,6 +107,7 @@ bool route_pleroma_api2( struct http_request* req ) // Route: /api/v1/pleroma bool route_pleroma_api( struct http_request* req ) { + printf( "route: route_pleroma_api\n" ); if( http_request_route( req, "/statuses" ) ) { printf( "route: statuses\n" ); if( http_request_route( req, "/" ) ) { diff --git a/src/json b/src/json index 2d81ba6..7714930 160000 --- a/src/json +++ b/src/json @@ -1 +1 @@ -Subproject commit 2d81ba6575bfade5b2fbd723d2ec0e900fd4042f +Subproject commit 77149308f513caa5be458247b509c3fb7f7e5de3 diff --git a/src/model/fetch.c b/src/model/fetch.c index 0c54cc8..21c8344 100644 --- a/src/model/fetch.c +++ b/src/model/fetch.c @@ -24,7 +24,7 @@ static size_t handle_header( char* header, size_t size, size_t nitems, void* use int bytes = size * nitems; int result = bytes; - printf( "? Header: |%.*s|\n", bytes, header ); + //printf( "? Header: |%.*s|\n", bytes, header ); if( 0 != strncmp("onion-location: ",header,sizeof("onion-location: ")-1 ) ) { return result; diff --git a/src/model/status.c b/src/model/status.c index 2f790d2..7b31d2d 100644 --- a/src/model/status.c +++ b/src/model/status.c @@ -787,6 +787,23 @@ void status_get_context( struct status* s, void* ancestors_ptr, void* replies_pt array_append( replies, sizeof(reply), &reply ); } } +void status_get_quotes( struct status* s, void* quotes_ptr ) +{ + struct array_of_status { + struct status** items; + int count; + }; + + struct array_of_status* quotes = quotes_ptr; + memset( quotes, 0, sizeof(*quotes) ); + + for( int i = 0; i < s->quotes.count; ++i ) { + struct status* q = status_from_id( s->quotes.items[i] ); + if( q ) { + array_append( quotes, sizeof(q), &q ); + } + } +} void status_add_react( struct status* s, const char* react, struct account* a ) { diff --git a/src/model/status.h b/src/model/status.h index 6d7f4fd..de881d1 100644 --- a/src/model/status.h +++ b/src/model/status.h @@ -113,6 +113,7 @@ void status_flag_for_async_fetch( struct status* s ); void status_add_to_timeline( struct status* s, int timeline_id ); void status_get_context( struct status* s, void* ancestors, void* replies ); +void status_get_quotes( struct status* s, void* quotes ); void status_add_mention( struct status* s, int id ); void status_add_tag( struct status* s, const char* tag ); diff --git a/src/util b/src/util new file mode 160000 index 0000000..24b374e --- /dev/null +++ b/src/util @@ -0,0 +1 @@ +Subproject commit 24b374ef03befcff66499be372d089ade16e2381 diff --git a/src/util/format.c b/src/util/format.c deleted file mode 100644 index 126063a..0000000 --- a/src/util/format.c +++ /dev/null @@ -1,47 +0,0 @@ -#define _GNU_SOURCE -#include "format.h" - -#include -#include -#include -#include - -const char* format( char* buffer, int size, const char* f, ... ) -{ - va_list args; - va_start(args,f); - vsnprintf( buffer, size, f, args ); - va_end(args); - - return buffer; -} -char* aformat( const char* f, ... ) -{ - va_list args; - va_start(args,f); - char* res = NULL; - vasprintf( &res, f, args ); - va_end(args); - - return res; -} - -char* safe_strdup( const char* str ) -{ - if( !str ) { return NULL; } - return strdup(str); -} - -void mkdir_p( const char* ch, int mode ) -{ - char buffer[512]; - strncpy(buffer,ch,512); - char* rem = NULL; - char next_create[512] = ""; - for( char* iter = strtok_r(buffer,"/",&rem); iter; iter = strtok_r(NULL,"/",&rem) ) { - strcat(next_create,iter); - mkdir( next_create, mode ); - strcat(next_create,"/"); - } -} - diff --git a/src/util/format.h b/src/util/format.h deleted file mode 100644 index 644b37f..0000000 --- a/src/util/format.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -const char* format( char* buffer, int size, const char* f, ... ); -char* aformat( const char* f, ... ); -char* safe_strdup( const char* str ); -void mkdir_p( const char* ch, int mode ); - diff --git a/tools/builder b/tools/builder index d94711a..41f6f54 160000 --- a/tools/builder +++ b/tools/builder @@ -1 +1 @@ -Subproject commit d94711a32676c69ecf492a50f030e132acd1647a +Subproject commit 41f6f54239a9b2f6638da67554db1305f2d69562