You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.5 KiB
C

#pragma once
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
#include <limits.h>
struct crypto_keys;
struct status;
struct ap_object;
struct outbox_envelope;
struct outbox_envelope_list;
enum {
system_account_id = INT_MAX,
owner_account_id = 0,
home_timeline_id = 1,
public_timeline_id = 2,
};
struct string_pair
{
char* key;
char* value;
};
enum account_type
{
at_owner = 1,
at_bot = 2,
at_remote_activity_pub = 3,
at_rss_feed = 4,
};
struct account
{
unsigned int id;
bool local;
char* handle;
char* server;
char* display_name;
bool stub;
bool defunct;
time_t next_stub_recheck;
int account_type;
char* account_url;
char* inbox;
char* shared_inbox;
struct {
char* url;
char* static_url;
} avatar;
char* banner;
struct {
char** items;
int count;
} aliases;
struct {
struct string_pair* items;
int count;
} fields;
int followers_count;
int following_count;
int status_count;
int follow_activity;
bool follow_confirmed;
char* note;
bool bot;
bool locked;
bool notify_for_posts;
};
void account_reindex();
void account_index_webfinger( struct account* a );
struct account* account_from_id( int id );
struct account* account_from_uri( const char* uri );
struct account* account_from_webfinger( const char* handle );
struct account* account_new();
struct account* account_from_uri_or_fetch( const char* uri );
struct account* account_fetch_from_uri( const char* uri );
void account_free( struct account* a );
void account_save( struct account* a );
// Update from external activity pub data
bool account_sync_from_activity_pub( unsigned int id );
bool account_sync_from_activity( struct account* a, struct ap_object* act );
void account_sync_following_list( struct account* a );
// Data requests
struct crypto_keys* account_get_public_key( struct account* a, const char* key_name );
struct crypto_keys* account_get_private_key( struct account* a );
void account_list_followers( struct account* a, int offset, int limit, void* id_array );
void account_list_following( struct account* a, int offset, int limit, void* id_array );
// Activity pub data
struct ap_object* account_activity_pub( struct account* a );
struct ap_object* account_ap_actor( struct account* a );
struct ap_object* account_ap_outbox( struct account* a );
struct ap_object* account_ap_outbox_page( struct account* a, int page );
struct ap_object* account_ap_followers( struct account* a );
struct ap_object* account_ap_followers_page( struct account* a, int page );
struct ap_object* account_ap_following( struct account* a );
struct ap_object* account_ap_following_page( struct account* a, int page );
// Local actions
void account_add_follower( struct account* a, struct account* follower );
void account_remove_follower( struct account* a, struct account* follower );
void account_move( struct account* a, const char* new_uri );
bool account_does_follow( struct account* a, int account_id );
// Federated actions
void account_deliver_activity( struct account* a, struct ap_object* act, struct outbox_envelope_list* oel );
void account_deliver_activity_to_followers( struct account* a, struct ap_object* act, struct outbox_envelope_list* oel );
void account_create( struct account* a, struct status* s );
struct status* account_announce( struct account* a, struct status* original_post, struct status* local_repost, struct ap_object* act );
void account_follow( struct account* a, struct account* to_follow );
void account_unfollow( struct account* a, struct account* to_unfollow );
void account_update( struct account* a );