Implement creating quote posts

master
teknomunk 1 year ago
parent 837a3b62f9
commit 0f6e78ae89

@ -106,6 +106,7 @@ bool handle_post( struct http_request* req, struct account* a )
char* status;
char* visibility;
char* in_reply_to_id;
char* quote_id;
char* spoiler_text;
} params;
memset(&params,0,sizeof(params));
@ -117,6 +118,7 @@ bool handle_post( struct http_request* req, struct account* a )
JSON_FIELD_STRING( status, true ),
JSON_FIELD_STRING( visibility, true ),
JSON_FIELD_STRING( in_reply_to_id, false ),
JSON_FIELD_STRING( quote_id, false ),
JSON_FIELD_STRING( spoiler_text, false ),
JSON_FIELD_END,
};
@ -140,7 +142,16 @@ bool handle_post( struct http_request* req, struct account* a )
}
if( params.in_reply_to_id ) {
status_make_reply_to( s, atoi( params.in_reply_to_id ) );
const char* id = params.in_reply_to_id;
while( *id == '0' && id[1] != '\0' ) { ++id; }
status_make_reply_to( s, atoi( id ) );
}
if( params.quote_id ) {
const char* id = params.quote_id;
while( *id == '0' && id[1] != '\0' ) { ++id; }
status_make_quote_of( s, atoi(id) );
}
// Save status data

@ -282,6 +282,11 @@ struct ap_object* activity_create_Note( struct status* s )
act->in_reply_to = strdup( s_in_reply_to->url );
status_free(s_in_reply_to);
}
if( s->quote_id ) {
struct status* s_quote_post = status_from_id( s->quote_id );
act->quote_url = strdup( s_quote_post->url );
status_free(s_quote_post);
}
/* set account related parameters */ {
struct account* a = account_from_id( s->account_id );

@ -704,6 +704,14 @@ void status_make_quote_of( struct status* s, int id_quote_of )
// Record quote in parent
status_add_quote( quoted_post, s );
// Mention the account that made the post being replied to
status_add_mention( s, quoted_post->account_id );
// Mention everyone else in that post
for( int i = 0; i < quoted_post->mentions.count; ++i ) {
status_add_mention( s, quoted_post->mentions.items[i] );
}
// Save and cleanup
status_save( quoted_post );
status_free( quoted_post );

Loading…
Cancel
Save