You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
995 B
C

#include "activity_pub.h"
// Submodules
#include "http/server/request.h"
#include "collections/array.h"
#include "format.h"
// Model
#include "model/server.h"
#include "model/status.h"
#include "model/account.h"
#include "model/ap/activity.h"
#include <string.h>
#include <stdlib.h>
char* status_render_source( struct status* s );
// Route: /note/
bool route_ap_note( struct http_request* req )
{
char* id_str = http_request_route_get_dir_or_file(req);
if( !id_str || !*id_str ) { return false; }
// Route: /note/%d{id}
int id = -1;
if( 1 != sscanf( id_str, "%d", &id ) ) { return false; }
struct status* s = status_from_id( id );
if( !s ) { return false; }
if( s->remote ) { return false; }
struct ap_activity* act = ap_activity_create_note( s );
http_request_send_headers( req, 200, "application/ld+json", true );
FILE* f = http_request_get_response_body( req );
ap_activity_write_to_FILE( act, f );
fflush(f);
ap_activity_free(act);
status_free(s);
return true;
}