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.
53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
#include "../inbox.h"
|
|
|
|
// Submodules
|
|
#include "ap/object.h"
|
|
|
|
// Model
|
|
#include "model/account.h"
|
|
#include "model/status.h"
|
|
|
|
// Standard Library
|
|
#include <string.h>
|
|
|
|
bool route_add( struct ap_activity* act )
|
|
{
|
|
bool result = false;
|
|
struct status* s = NULL;
|
|
struct account* a = NULL;
|
|
struct ap_object* apa = NULL;
|
|
|
|
// Make sure this is to pin a status
|
|
a = account_from_uri_or_fetch( act->actor );
|
|
if( !a ) {
|
|
printf( "Don't have account...\n" );
|
|
goto failed;
|
|
} // Don't have ActivityPub account data, try again later
|
|
apa = account_activity_pub(a);
|
|
if( 0 != strcmp( apa->featured, act->target ) ) {
|
|
printf( "Not adding to featured...\n" );
|
|
printf( "apa->featured = %s\n", apa->featured );
|
|
printf( "act->target = %s\n", act->target );
|
|
goto failed;
|
|
}
|
|
|
|
// Get the status
|
|
if( act->object.tag == apaot_ref ) {
|
|
s = status_from_uri_or_fetch( act->object.ref );
|
|
}
|
|
if( !s ) { goto failed; }
|
|
|
|
s->pinned = true;
|
|
status_save(s);
|
|
|
|
result = true;
|
|
cleanup:
|
|
status_free(s);
|
|
ap_object_free(apa);
|
|
account_free(a);
|
|
return result;
|
|
failed:
|
|
result = false;
|
|
goto cleanup;
|
|
}
|