|
|
|
@ -49,6 +49,14 @@ struct ap_object* activity_from_local_id( int id )
|
|
|
|
|
return act;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct ap_object* new_local_activity()
|
|
|
|
|
{
|
|
|
|
|
struct ap_object* act = ap_object_new();
|
|
|
|
|
ap_object_add_context( act, "https://www.w3.org/ns/activitystreams");
|
|
|
|
|
char buffer[512];
|
|
|
|
|
ap_object_add_context( act, format( buffer, 512, "https://%s/schemas/litepub-0.1.jsonld", g_server->domain ) );
|
|
|
|
|
return act;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ap_object* activity_create_Accept( struct ap_object* act )
|
|
|
|
|
{
|
|
|
|
@ -91,10 +99,8 @@ struct ap_object* activity_create_EmojiReact( struct status* s, const char* reac
|
|
|
|
|
|
|
|
|
|
struct account* a = account_from_id( s->account_id );
|
|
|
|
|
|
|
|
|
|
struct ap_object* act = ap_object_new();
|
|
|
|
|
struct ap_object* act = new_local_activity();
|
|
|
|
|
activity_allocate_local_id(act);
|
|
|
|
|
ap_object_add_context( act, "https://www.w3.org/ns/activitystreams");
|
|
|
|
|
ap_object_add_context( act, "https://apogee.polaris-1.work/schemas/litepub-0.1.jsonld");
|
|
|
|
|
act->id = aformat( "https://%s/activity/%d", g_server->domain, act->local_id );
|
|
|
|
|
act->actor = aformat( "https://%s/owner/actor", g_server->domain );
|
|
|
|
|
act->type = pleroma_EmojiReact;
|
|
|
|
@ -222,21 +228,48 @@ failed:
|
|
|
|
|
|
|
|
|
|
struct ap_object* activity_create_Like( struct status* s )
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
struct ap_object* act = new_local_activity();
|
|
|
|
|
activity_allocate_local_id(act);
|
|
|
|
|
act->id = aformat( "https://%s/activity/%d", g_server->domain, act->local_id );
|
|
|
|
|
act->actor = aformat( "https://%s/owner/actor", g_server->domain );
|
|
|
|
|
act->type = ap_Like;
|
|
|
|
|
act->published = time(NULL);
|
|
|
|
|
act->object.tag = apaot_ref;
|
|
|
|
|
act->object.ref = strdup( s->url );
|
|
|
|
|
|
|
|
|
|
struct account* a = account_from_id( s->account_id );
|
|
|
|
|
char* to = aformat( "https://%s/owner/followers", g_server->domain );
|
|
|
|
|
array_append( &act->to, sizeof(to), &to );
|
|
|
|
|
to = strdup(a->account_url);
|
|
|
|
|
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);
|
|
|
|
|
array_append( &act->to, sizeof(to), &to );
|
|
|
|
|
account_free(mentioned);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* cc = strdup( "https://www.w3.org/ns/activitystreams#Public" );
|
|
|
|
|
array_append( &act->cc, sizeof(cc), &cc );
|
|
|
|
|
|
|
|
|
|
account_free(a);
|
|
|
|
|
return act;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int activity_like( struct status* s )
|
|
|
|
|
{
|
|
|
|
|
printf( "TODO: like\n" );
|
|
|
|
|
struct ap_object* act = activity_create_Like( s );
|
|
|
|
|
if( !act ) { return 0; }
|
|
|
|
|
|
|
|
|
|
activity_save(act);
|
|
|
|
|
activity_deliver( act );
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ap_object* activity_create_Note( struct status* s )
|
|
|
|
|
{
|
|
|
|
|
struct ap_object* act = ap_object_new();
|
|
|
|
|
ap_object_add_context( act, "https://www.w3.org/ns/activitystreams");
|
|
|
|
|
ap_object_add_context( act, "https://apogee.polaris-1.work/schemas/litepub-0.1.jsonld");
|
|
|
|
|
struct ap_object* act = new_local_activity();
|
|
|
|
|
act->id = aformat( "https://%s/note/%d", g_server->domain, s->id );
|
|
|
|
|
act->type = ap_Note;
|
|
|
|
|
act->published = s->published;
|
|
|
|
|