|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
#include "poll.h"
|
|
|
|
|
|
|
|
|
|
#include "model/account.h"
|
|
|
|
|
#include "model/activity.h"
|
|
|
|
|
#include "model/emoji.h"
|
|
|
|
|
#include "model/server.h"
|
|
|
|
|
#include "model/status.h"
|
|
|
|
|
|
|
|
|
|
#include "ap/object.h"
|
|
|
|
|
#include "collections/array.h"
|
|
|
|
|
#include "util/format.h"
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
@ -108,15 +112,54 @@ bool status_poll_add_vote( struct status* s, struct account* a, void* choices_pt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Federate response if account is owner
|
|
|
|
|
if( a->id == owner_account_id ) {
|
|
|
|
|
// Federate response if account is owner and this isn't a local poll
|
|
|
|
|
if( s->remote && a->id == owner_account_id ) {
|
|
|
|
|
s->poll->voted = true;
|
|
|
|
|
|
|
|
|
|
// https://www.w3.org/TR/activitystreams-vocabulary/#questions
|
|
|
|
|
// See Example 153
|
|
|
|
|
|
|
|
|
|
printf( "TODO: Create federation object\n" );
|
|
|
|
|
//struct ap_object* obj;
|
|
|
|
|
struct account* owner = account_from_id( owner_account_id );
|
|
|
|
|
struct account* poll_owner = account_from_id( s->account_id );
|
|
|
|
|
char* cc;
|
|
|
|
|
|
|
|
|
|
// Create the note
|
|
|
|
|
struct ap_object* note = ap_object_new();
|
|
|
|
|
note->type = ap_Note;
|
|
|
|
|
note->id = aformat( "https://%s/votes/%d", g_server->domain, s->id );
|
|
|
|
|
note->attributed_to = aformat( "https://%s/owner/actor", g_server->domain );
|
|
|
|
|
note->actor = aformat( "https://%s/owner/actor", g_server->domain );
|
|
|
|
|
note->name = strdup( s->poll->options.items[choices->items[0]]->title );
|
|
|
|
|
note->in_reply_to = strdup( s->url );
|
|
|
|
|
cc = strdup( poll_owner->account_id );
|
|
|
|
|
array_append( ¬e->cc, sizeof(cc), &cc );
|
|
|
|
|
|
|
|
|
|
struct ap_activity_tag* mention = ap_activity_tag_new();
|
|
|
|
|
mention->type = aptag_mention;
|
|
|
|
|
mention->href = strdup( poll_owner->account_id );
|
|
|
|
|
mention->name = aformat( "@%s@%s", poll_owner->handle, poll_owner->server );
|
|
|
|
|
|
|
|
|
|
array_append( ¬e->tags, sizeof(mention), &mention );
|
|
|
|
|
|
|
|
|
|
// Create the activity
|
|
|
|
|
struct ap_object* act = activity_new_local_activity();
|
|
|
|
|
activity_allocate_local_id(act);
|
|
|
|
|
|
|
|
|
|
act->type = ap_Create;
|
|
|
|
|
act->actor = aformat( "https://%s/owner/actor", g_server->domain );
|
|
|
|
|
act->id = aformat( "https://%s/activity/%d", g_server->domain, act->local_id );
|
|
|
|
|
act->object.tag = apaot_object;
|
|
|
|
|
act->object.ptr = note;
|
|
|
|
|
|
|
|
|
|
cc = strdup( poll_owner->account_id );
|
|
|
|
|
array_append( &act->cc, sizeof(cc), &cc );
|
|
|
|
|
|
|
|
|
|
account_free(owner);
|
|
|
|
|
account_free(poll_owner);
|
|
|
|
|
|
|
|
|
|
activity_save(act);
|
|
|
|
|
activity_deliver(act);
|
|
|
|
|
ap_object_free(act);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_poll_update_vote_count( s->poll );
|
|
|
|
|