|
|
|
@ -41,6 +41,7 @@ static struct json_object_field status_layout[] = {
|
|
|
|
|
|
|
|
|
|
JSON_FIELD_STRING( content, false ),
|
|
|
|
|
JSON_FIELD_STRING( source, false ),
|
|
|
|
|
JSON_FIELD_STRING( spoiler_text, false ),
|
|
|
|
|
JSON_FIELD_BOOL( pinned, false ),
|
|
|
|
|
JSON_FIELD_BOOL( bookmarked, false ),
|
|
|
|
|
JSON_FIELD_DATETIME( published, false ),
|
|
|
|
@ -278,6 +279,9 @@ bool status_sync_from_activity_pub( struct status* s, struct ap_object* act )
|
|
|
|
|
s->remote = true;
|
|
|
|
|
s->stub = false;
|
|
|
|
|
s->sensitive = act->sensitive;
|
|
|
|
|
if( act->summary ) {
|
|
|
|
|
s->spoiler_text = strdup(act->summary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Force this status to have an id
|
|
|
|
|
status_save_new(s);
|
|
|
|
@ -390,29 +394,13 @@ failed:
|
|
|
|
|
|
|
|
|
|
bool status_sync_from_uri( struct status* s, const char* uri )
|
|
|
|
|
{
|
|
|
|
|
struct ap_object* act = NULL;
|
|
|
|
|
FILE* f = NULL;
|
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
|
|
mkdir_p( "data/statuses/ap", 0755 );
|
|
|
|
|
// Fetch the object from the remote server
|
|
|
|
|
char filename[512];
|
|
|
|
|
snprintf( filename, sizeof(filename), "data/statuses/ap/%d.json", s->id );
|
|
|
|
|
f = fopen(filename,"r");
|
|
|
|
|
if( !f ) {
|
|
|
|
|
if( !pull_remote_file( filename, uri ) ) { goto failed; }
|
|
|
|
|
f = fopen(filename,"r");
|
|
|
|
|
if( !f ) { goto failed; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load the activity and sync status
|
|
|
|
|
act = ap_object_from_FILE(f); f = NULL;
|
|
|
|
|
struct ap_object* act = fetch_ap_object_ref( uri );
|
|
|
|
|
if( !act ) { goto failed; }
|
|
|
|
|
if( !status_sync_from_activity_pub(s,act) ) { goto failed; }
|
|
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
|
cleanup:
|
|
|
|
|
if( f ) { fclose(f); }
|
|
|
|
|
ap_object_free(act);
|
|
|
|
|
return result;
|
|
|
|
|
failed:
|
|
|
|
@ -606,6 +594,7 @@ void status_free( struct status* s )
|
|
|
|
|
|
|
|
|
|
free(s->content);
|
|
|
|
|
free(s->source);
|
|
|
|
|
free(s->spoiler_text);
|
|
|
|
|
|
|
|
|
|
// Free media
|
|
|
|
|
for( int i = 0; i < s->media.count; ++i ) {
|
|
|
|
@ -737,6 +726,7 @@ void status_get_context( struct status* s, void* ancestors_ptr, void* replies_pt
|
|
|
|
|
struct status* parent = NULL;
|
|
|
|
|
for( int i = s->in_reply_to; i != 0; i = parent->in_reply_to ) {
|
|
|
|
|
parent = status_from_id( i );
|
|
|
|
|
if( !parent ) { break; }
|
|
|
|
|
array_append( ancestors, sizeof(parent), &parent );
|
|
|
|
|
};
|
|
|
|
|
// reverse ancestors
|
|
|
|
|