#pragma once #include "json/layout.h" #include "object/context.h" #include "object/tag.h" #include // Reference: https://www.w3.org/TR/activitystreams-vocabulary/ // TODO: rename this to ap_object, as this is really an Object base and not an Activity base struct ap_object; #define ap_activity ap_object struct ap_activity_source { char* mime_type; char* content; // TODO: add map; }; enum ap_signature_type { apst_rsa_signature_2017 = 1, }; struct ap_signature { int type; char* creator; time_t created; char* value; }; enum ap_object_type { // Activity Types ap_Undo = 1, ap_Follow = 2, ap_Delete = 3, ap_Accept = 4, ap_Create = 5, ap_TentativeAccept = 6, ap_Add = 7, ap_Arrive = 8, ap_Ignore = 9, ap_Join = 10, ap_Leave = 11, ap_Like = 12, ap_Offer = 13, ap_Invite = 14, ap_Reject = 15, ap_TentativeReject = 16, ap_Remove = 17, ap_Update = 18, ap_View = 19, ap_Listen = 20, ap_Read = 21, ap_Move = 22, ap_Travel = 23, ap_Announce = 24, ap_Block = 25, ap_Flag = 26, ap_Dislike = 27, // Object Types ap_Note = 100, ap_Question = 101, ap_Article = 102, ap_Audio = 103, ap_Document = 104, ap_Event = 105, ap_Image = 106, ap_Page = 107, ap_Place = 108, ap_Profile = 109, ap_Relationship = 110, ap_Tombstone = 111, ap_Video = 112, // Actor Types ap_Person = 200, ap_Service = 201, ap_Application = 202, ap_Group = 203, ap_Organization = 204, // Collection Types ap_OrderedCollection = 301, ap_OrderedCollectionPage = 302, ap_Collection = 303, ap_CollectionPage = 304, /// Pleroma Types pleroma_EmojiReact = 28, /// Musicbox Types mb_Track = 501, mb_Album = 502, /// Forge Types (https://forgefed.org/vocabulary.html) forge_Grant = 601, forge_Push = 602, forge_Repository = 603, forge_TicketTracker = 604, forge_PatchTracker = 605, forge_Project = 606, forge_Team = 607, forge_Branch = 608, forge_Commit = 609, forge_TicketDependency = 610, forge_Ticket = 611, /// Schema.org types schema_PropertyValue = 401, // https://schema.org/PropertyValue }; extern struct json_enum ap_object_type_enum[]; enum ap_activity_object_type { apaot_ref = 1, apaot_activity = 2, apaot_object = 2, }; struct ap_attachment { int type; char* mediaType; char* name; char* url; char* value; }; void ap_attachment_free( struct ap_attachment* a ); extern struct json_field_type ap_attachment_type; struct ap_object_ptr_or_ref { int tag; union { char* ref; struct ap_object* ptr; }; }; struct ap_public_key { char* id; char* owner; char* public_key; }; void ap_object_ptr_or_ref_free( struct ap_object_ptr_or_ref* oor ); void ap_object_ptr_or_ref_free_composite( struct ap_object_ptr_or_ref* oor ); struct ap_object { struct ap_activity_context ap_context; char* id; char* actor; char* name; int local_id; int type; // Actor-specific fields char* inbox; char* outbox; char* preferred_username; char* url; struct { char* shared_inbox; } endpoints; char* featured; char* followers; char* following; struct { bool show; bool accepts_chat_messages; } capabilities; char* avatar; char* banner; bool discoverable; bool manually_approves_followers; struct ap_public_key* public_key; char* context; int context_id; bool direct_message; char* attributed_to; char* target; char* in_reply_to; struct ap_activity_source content; char* conversation; time_t published; struct ap_activity_source source; char* summary; bool sensitive; struct { struct ap_activity_tag** items; int count; } tags; struct { struct ap_attachment** items; int count; } attachments; struct { char** items; int count; } also_known_as; struct { struct ap_object_ptr_or_ref* items; int count; } collection_items; struct { char** items; int count; } to, cc, bcc; struct ap_object_ptr_or_ref object; char* state; int has_signature; struct ap_signature signature; // Collection fields struct ap_object_ptr_or_ref first; char* next; char* prev; char* part_of; int total_items; }; struct json_object_field; extern struct json_field_type ap_object_type; extern struct json_object_field ap_object_layout[]; struct ap_object* ap_activity_new(); struct ap_object* ap_activity_dup( struct ap_object* o ); struct ap_object* ap_object_from_FILE( FILE* f ); struct ap_object* ap_object_from_file( const char* filename ); void ap_object_free( struct ap_object* o ); void ap_activity_free_composite( struct ap_object* o ); void ap_object_write_to_FILE( struct ap_object* o, FILE* f );