Fix outbox processing, fix actor on EmojiReact activity

master
teknomunk 10 months ago
parent 2190fd660f
commit e28ccd7f7c

@ -89,6 +89,10 @@ static bool process_envelope( struct outbox_envelope* env )
if( env->shared_inbox ) {
inbox = env->shared_inbox;
}
if( !inbox ) {
printf( "No inbox URL available for %s (id=%d), discarding delivery of activity %d.\n", to_account->display_name, to_account->id, env->activity_id );
goto discard;
};
// Try to get peer information
char domain[512];
@ -99,7 +103,7 @@ static bool process_envelope( struct outbox_envelope* env )
fd.p = p;
printf( "Processing outbox/%d.json\n", env->id );
printf( "inbox=%s\b", inbox );
printf( "inbox=%s\n", inbox );
printf( "account_id=%d\n", env->account_id );
printf( "activity_id=%d\n", env->activity_id );

@ -46,12 +46,12 @@ struct ap_object* account_ap_actor( struct account* a )
struct ap_object* avatar = ap_object_new();
avatar->type = ap_Image;
ap_object_array_append_ref( &act->url, aformat( "https://%s/owner/avatar.blob", g_server->domain ) );
ap_object_array_append_ref( &avatar->url, aformat( "https://%s/owner/avatar.blob", g_server->domain ) );
act->icon = avatar;
struct ap_object* banner = ap_object_new();
banner->type = ap_Image;
ap_object_array_append_ref( &act->url, aformat( "https://%s/owner/banner.blob", g_server->domain ) );
ap_object_array_append_ref( &banner->url, aformat( "https://%s/owner/banner.blob", g_server->domain ) );
act->image = banner;
ap_object_array_append_ref( &act->url, aformat( "https://%s/@%s@%s", g_server->domain, a->handle, g_server->domain ) );

@ -78,17 +78,12 @@ void activity_accept( struct ap_object* act, int deliver_to_account_id )
{
struct ap_object* accept = activity_create_Accept(act);
activity_save(accept);
struct outbox_envelope* env = outbox_envelope_new();
env->activity_id = accept->local_id;
env->account_id = deliver_to_account_id;
outbox_envelope_save( env );
outbox_envelope_free( env );
activity_deliver(accept);
ap_object_free(accept);
}
struct ap_object* activity_create_EmojiReact( struct status* s, const char* react )
struct ap_object* activity_create_EmojiReact( struct status* s, struct account* reactor, const char* react )
{
if( !*react ) {
return NULL;
@ -99,7 +94,7 @@ struct ap_object* activity_create_EmojiReact( struct status* s, const char* reac
struct ap_object* act = activity_new_local_activity();
activity_allocate_local_id(act);
act->id = aformat( "https://%s/activity/%d", g_server->domain, act->local_id );
act->actor = strdup(a->account_url);
act->actor = strdup(reactor->account_url);
act->type = pleroma_EmojiReact;
act->content.content = safe_strdup(react);
act->published = time(NULL);
@ -118,19 +113,13 @@ struct ap_object* activity_create_EmojiReact( struct status* s, const char* reac
return act;
}
void activity_react( struct status* s, const char* react )
void activity_react( struct account* reactor, struct status* s, const char* react )
{
struct ap_object* act = activity_create_EmojiReact(s,react);
struct ap_object* act = activity_create_EmojiReact(s,reactor,react);
if( !act ) { return; }
activity_save(act);
struct outbox_envelope* env = outbox_envelope_new();
env->activity_id = act->local_id;
env->account_id = s->account_id;
outbox_envelope_save( env );
outbox_envelope_free( env );
activity_deliver(act);
ap_object_free(act);
}
@ -159,14 +148,9 @@ int activity_follow( struct account* follower, struct account* following )
if( !act ) { goto failed; }
activity_save(act);
activity_deliver(act);
res = act->local_id;
struct outbox_envelope* env = outbox_envelope_new();
if( !env ) { goto failed; }
env->activity_id = act->local_id;
env->account_id = following->id;
outbox_envelope_save( env );
outbox_envelope_free( env );
cleanup:
ap_object_free(act);
return res;
@ -198,20 +182,7 @@ void activity_undo( struct ap_object* act, int deliver_to_account_id )
if( !undo_act ) { goto failed; }
activity_save(undo_act);
/*
printf( "act=" );
ap_activity_write_to_FILE( act, stdout );
printf( "\nundo_act=");
ap_activity_write_to_FILE( undo_act, stdout );
printf( "\n" );
*/
struct outbox_envelope* env = outbox_envelope_new();
if( !env ) { goto failed; }
env->activity_id = undo_act->local_id;
env->account_id = deliver_to_account_id;
outbox_envelope_save( env );
outbox_envelope_free( env );
activity_deliver(undo_act);
cleanup:
ap_object_free(undo_act);
return;
@ -256,7 +227,8 @@ int activity_like( struct status* s )
if( !act ) { return 0; }
activity_save(act);
activity_deliver( act );
activity_deliver(act);
ap_object_free(act);
return 1;
}

@ -14,7 +14,7 @@ struct ap_object* activity_new_local_activity();
// Creation
struct ap_object* activity_create_Accept( struct ap_object* act );
struct ap_object* activity_create_EmojiReact( struct status* s, const char* react );
struct ap_object* activity_create_EmojiReact( struct status* s, struct account* a, const char* react );
struct ap_object* activity_create_Undo( struct ap_object* act );
struct ap_object* activity_create_Like( struct status* s );
struct ap_object* activity_create_Note( struct status* s );
@ -22,7 +22,7 @@ struct ap_object* activity_create_Create( struct ap_object* act );
struct ap_object* activity_create_Accept( struct ap_object* act );
// Actions
void activity_react( struct status* s, const char* react );
void activity_react( struct account* reactor, struct status* s, const char* react );
int activity_follow( struct account* follower, struct account* following );
void activity_unfollow( struct account* follower, struct account* to_unfollow );
void activity_undo( struct ap_object* act, int deliver_to_account_id );

@ -867,7 +867,7 @@ void status_add_react( struct status* s, const char* react, struct account* a )
return;
} else {
// Deliver react to post owner
activity_react( s, react );
activity_react( a, s, react );
}
}

Loading…
Cancel
Save