Fix bugs where account_url was being used where account_id should have been, make sure newly created owner account has account_url and account_id set correctly

master
teknomunk 5 months ago
parent 33ab478771
commit eec6d2b80a

@ -59,7 +59,7 @@ bool handle_admin_initial_owner_setup( struct http_request* req )
struct account* owner = account_new();
owner->id = owner_account_id;
owner->server = strdup(g_server->domain);
owner->account_url = aformat("https://%s/owner/actor", g_server->domain );
owner->account_id = aformat("https://%s/owner/actor", g_server->domain );
owner->banner = aformat("https://%s/owner/banner.blob", g_server->domain );
owner->avatar.url = aformat("https://%s/owner/avatar.blob", g_server->domain );
owner->avatar.static_url = aformat("https://%s/owner/avatar.blob", g_server->domain );
@ -108,6 +108,7 @@ bool handle_admin_initial_owner_setup( struct http_request* req )
} else if( 0 == strcmp(key,"handle") ) {
owner->handle = strdup(form_pull_parser_read_value(fp));
owner->display_name = strdup(owner->handle);
owner->account_url = aformat("https://%s/@%s", g_server->domain, owner->handle );
account_save(owner);
}
}

@ -20,7 +20,7 @@
void account_deliver_activity( struct account* a, struct ap_object* act, struct outbox_envelope_list* oel )
{
if( a->defunct ) {
printf( "Account %s id defunct, not delivering activity\n", a->account_url );
printf( "Account %s id defunct, not delivering activity\n", a->account_id );
return;
}
@ -42,9 +42,9 @@ void account_deliver_activity( struct account* a, struct ap_object* act, struct
env->count = 1;
if( a->shared_inbox ) {
env->shared_inbox = strdup(a->shared_inbox);
printf( "Delivering activity %s to account %s via shared inbox %s\n", act->id, a->account_url, a->shared_inbox );
printf( "Delivering activity %s to account %s via shared inbox %s\n", act->id, a->account_id, a->shared_inbox );
} else {
printf( "Delivering activity %s to account %s via inbox %s\n", act->id, a->account_url, a->inbox );
printf( "Delivering activity %s to account %s via inbox %s\n", act->id, a->account_id, a->inbox );
}
env->account_id = a->id;
array_append( oel, sizeof(env), &env );
@ -52,7 +52,7 @@ void account_deliver_activity( struct account* a, struct ap_object* act, struct
void account_deliver_activity_to_followers( struct account* a, struct ap_object* act, struct outbox_envelope_list* oel )
{
printf( "Delivering activity %s to followers of account %s\n", act->id, a->account_url );
printf( "Delivering activity %s to followers of account %s\n", act->id, a->account_id );
struct {
char** items;
int count;
@ -132,7 +132,7 @@ struct status* account_announce( struct account* a, struct status* original_post
act->type = ap_Announce;
act->object.tag = apaot_ref;
act->object.ref = strdup(original_post->url);
act->actor = strdup(a->account_url);
act->actor = strdup(a->account_id);
// Create To: list
char* str = strdup("https://www.w3.org/ns/activitystreams#Public");
@ -142,7 +142,7 @@ struct status* account_announce( struct account* a, struct status* original_post
array_append( &act->to, sizeof(str), &str );
struct account* origin_post_account = account_from_id(original_post->account_id);
str = strdup(origin_post_account->account_url);
str = strdup(origin_post_account->account_id);
array_append( &act->to, sizeof(str), &str );
account_free(origin_post_account);
}
@ -202,7 +202,7 @@ void account_unfollow( struct account* a, struct account* to_unfollow )
);
if( !res ) {
printf( "Unable to find activity to undo follow\n" );
printf( "%s is trying to unfollow %s\n", a->account_url, to_unfollow->account_url );
printf( "%s is trying to unfollow %s\n", a->account_id, to_unfollow->account_id );
return;
}
@ -230,7 +230,7 @@ void account_update( struct account* a )
activity_allocate_local_id(act);
act->id = aformat( "https://%s/activity/%d", g_server->domain, act->id );
act->type = ap_Update;
act->actor = strdup(a->account_url);
act->actor = strdup(a->account_id);
act->object.tag = apaot_activity;
act->object.ptr = account_get_activity_pub_data(a);

@ -96,19 +96,19 @@ struct ap_object* activity_create_EmojiReact( struct status* s, struct account*
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(reactor->account_url);
act->actor = strdup(reactor->account_id);
act->type = pleroma_EmojiReact;
act->content.content = safe_strdup(react);
act->published = time(NULL);
act->object.tag = apaot_ref;
act->object.ref = strdup( s->url );
char* to = aformat( "%s/followers", a->account_url );
char* to = aformat( "%s/followers", a->account_id );
array_append( &act->to, sizeof(to), &to );
char* cc = strdup( "https://www.w3.org/ns/activitystreams#Public" );
array_append( &act->cc, sizeof(cc), &cc );
cc = strdup( a->account_url );
cc = strdup( a->account_id );
array_append( &act->cc, sizeof(cc), &cc );
account_free(a);
@ -130,14 +130,14 @@ struct ap_object* activity_create_Follow( struct account* follower, struct accou
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( follower->account_url );
act->actor = strdup( follower->account_id );
act->type = ap_Follow;
act->published = time(NULL);
act->object.tag = apaot_ref;
act->state = strdup("pending");
act->object.ref = strdup( following->account_url );
act->object.ref = strdup( following->account_id );
char* to = strdup(following->account_url);
char* to = strdup(following->account_id);
array_append( &act->to, sizeof(to), &to );
return act;
@ -199,7 +199,7 @@ struct ap_object* activity_create_Like( struct status* s )
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(a->account_id);
act->type = ap_Like;
act->published = time(NULL);
act->object.tag = apaot_ref;
@ -207,11 +207,11 @@ struct ap_object* activity_create_Like( struct status* s )
char* to = aformat( "https://%s/owner/followers", g_server->domain );
array_append( &act->to, sizeof(to), &to );
to = strdup(a->account_url);
to = strdup(a->account_id);
array_append( &act->to, sizeof(to), &to );
for( int i = 0; i < s->mentions.count; ++i ) {
struct account* mentioned = account_from_id( s->mentions.items[i] );
to = strdup(mentioned->account_url);
to = strdup(mentioned->account_id);
array_append( &act->to, sizeof(to), &to );
account_free(mentioned);
}
@ -266,8 +266,8 @@ struct ap_object* activity_create_Note( struct status* s )
/* set account related parameters */ {
struct account* a = account_from_id( s->account_id );
act->actor = strdup( a->account_url );
act->attributed_to = strdup( a->account_url );
act->actor = strdup( a->account_id );
act->attributed_to = strdup( a->account_id );
account_free(a);
}
@ -334,14 +334,14 @@ struct ap_object* activity_create_Note( struct status* s )
for( int i = 0; i < s->mentions.count; ++i ) {
struct account* mentioned = account_from_id( s->mentions.items[i] );
str = strdup(mentioned->account_url);
str = strdup(mentioned->account_id);
array_append( &act->to, sizeof(str), &str );
struct ap_activity_tag* tag;
tag = malloc(sizeof(*tag));
memset(tag,0,sizeof(*tag));
tag->type = aptag_mention;
tag->href = strdup(mentioned->account_url);
tag->href = strdup(mentioned->account_id);
tag->name = aformat( "%s@%s", mentioned->handle, mentioned->server );
array_append( &act->tags, sizeof(tag), &tag );

@ -79,6 +79,7 @@ char* webfinger_query( const char* handle, const char* rel, const char* type )
HTTP_REQ_URL, uri,
HTTP_REQ_OUTFILE, f,
HTTP_REQ_RESULT_STATUS, &status_code,
HTTP_REQ_TIMEOUT, (void*)2,
NULL,
};

Loading…
Cancel
Save