|
|
|
@ -147,10 +147,10 @@ static struct status* lookup_object_status( struct ap_activity* act )
|
|
|
|
|
|
|
|
|
|
switch( act->object.tag ) {
|
|
|
|
|
case apaot_ref:
|
|
|
|
|
printf( "! Status %s doesn't exist locally\n", act->object.ref );
|
|
|
|
|
printf( "! Status %s doesn't exist locally (object.ref)\n", act->object.ref );
|
|
|
|
|
break;
|
|
|
|
|
case apaot_activity:
|
|
|
|
|
printf( "! Status %s doesn't exist locally\n", act->object.ptr->id );
|
|
|
|
|
printf( "! Status %s doesn't exist locally (object.ptr)\n", act->object.ptr->id );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
@ -170,6 +170,10 @@ static bool route_like( struct ap_activity* act )
|
|
|
|
|
struct status* s = lookup_object_status(act);
|
|
|
|
|
struct account* liker = lookup_actor_account(act);
|
|
|
|
|
|
|
|
|
|
if( !s ) {
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
status_add_like( s, liker );
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
@ -187,6 +191,7 @@ static bool route_emoji_react( struct ap_activity* act )
|
|
|
|
|
|
|
|
|
|
static bool route_create( struct ap_activity* act )
|
|
|
|
|
{
|
|
|
|
|
struct status* s = NULL;
|
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
|
|
// Requires an object
|
|
|
|
@ -214,10 +219,7 @@ static bool route_create( struct ap_activity* act )
|
|
|
|
|
|
|
|
|
|
check_is_follower:
|
|
|
|
|
// Get actor account
|
|
|
|
|
struct account* actor_account = account_from_uri( obj->actor );
|
|
|
|
|
if( !actor_account ) {
|
|
|
|
|
actor_account = account_fetch_from_uri( obj->actor );
|
|
|
|
|
}
|
|
|
|
|
struct account* actor_account = account_from_uri_or_fetch( obj->actor );
|
|
|
|
|
if( !actor_account ) {
|
|
|
|
|
printf( "! Unable to fetch %s\n", obj->actor );
|
|
|
|
|
goto failed;
|
|
|
|
@ -234,7 +236,6 @@ check_is_follower:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create local status
|
|
|
|
|
struct status* s;
|
|
|
|
|
s = status_from_uri( obj->id );
|
|
|
|
|
if( !s ) {
|
|
|
|
|
s = status_from_activity(obj);
|
|
|
|
@ -281,15 +282,53 @@ static bool route_accept( struct ap_activity* act )
|
|
|
|
|
|
|
|
|
|
static bool route_announce( struct ap_activity* act )
|
|
|
|
|
{
|
|
|
|
|
struct account* owner_account = account_from_id( owner_account_id );
|
|
|
|
|
struct account* actor_account = account_from_uri( act->actor );
|
|
|
|
|
if( !account_does_follow( owner_account, actor_account->id ) ) {
|
|
|
|
|
// Not following, discard
|
|
|
|
|
printf( "%s does not follow %s\n", owner_account->handle, actor_account->account_url );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reposts do not show up in notifications unless notifications for the user are enabled
|
|
|
|
|
if( actor_account->notify_for_posts ) {
|
|
|
|
|
printf( "? TODO: notification\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( act->object.tag != apaot_ref ) {
|
|
|
|
|
printf( "! object not reference\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct status* original_post = status_fetch_from_uri( act->object.ref );
|
|
|
|
|
|
|
|
|
|
// TODO: handle repost
|
|
|
|
|
ap_activity_write_to_FILE( act, stdout );
|
|
|
|
|
struct status* s;
|
|
|
|
|
s = malloc(sizeof(*s));
|
|
|
|
|
memset(s,0,sizeof(*s));
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
s->url = strdup(act->id);
|
|
|
|
|
s->published = act->published;
|
|
|
|
|
s->repost_id = original_post->id;
|
|
|
|
|
s->account_id = actor_account->id;
|
|
|
|
|
s->sensitive = act->sensitive;
|
|
|
|
|
|
|
|
|
|
status_save_new(s);
|
|
|
|
|
|
|
|
|
|
status_add_to_timeline( s, home_timeline_id );
|
|
|
|
|
status_add_to_timeline( s, public_timeline_id );
|
|
|
|
|
status_add_to_timeline( s, actor_account->id );
|
|
|
|
|
|
|
|
|
|
status_free(s);
|
|
|
|
|
status_free(original_post);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool route_activity( struct ap_activity* act )
|
|
|
|
|
{
|
|
|
|
|
printf( "Handling %s\n", act->id );
|
|
|
|
|
ap_activity_write_to_FILE( act, stdout );
|
|
|
|
|
|
|
|
|
|
switch( act->type ) {
|
|
|
|
|
case apat_undo: return route_undo_activity(act);
|
|
|
|
|