2022-09-19 19:13:40 +00:00
|
|
|
/* snac - A simple, minimalistic ActivityPub instance */
|
2024-01-04 08:22:03 +00:00
|
|
|
/* copyright (c) 2022 - 2024 grunfink et al. / MIT license */
|
2022-09-19 18:47:22 +00:00
|
|
|
|
2024-09-16 07:36:07 +00:00
|
|
|
#define VERSION "2.60-dev"
|
2022-09-27 16:01:51 +00:00
|
|
|
|
|
|
|
#define USER_AGENT "snac/" VERSION
|
|
|
|
|
2023-04-25 04:40:46 +00:00
|
|
|
#define WHAT_IS_SNAC_URL "https:/" "/comam.es/what-is-snac"
|
|
|
|
|
2023-07-09 18:23:38 +00:00
|
|
|
#define DIR_PERM 00770
|
|
|
|
#define DIR_PERM_ADD 02770
|
2023-02-07 08:01:57 +00:00
|
|
|
|
2023-05-29 07:07:27 +00:00
|
|
|
#define ISO_DATE_SPEC "%Y-%m-%dT%H:%M:%SZ"
|
|
|
|
|
2024-01-08 07:21:22 +00:00
|
|
|
#ifndef MAX_THREADS
|
|
|
|
#define MAX_THREADS 256
|
|
|
|
#endif
|
|
|
|
|
2024-03-08 04:41:08 +00:00
|
|
|
#ifndef MAX_CONVERSATION_LEVELS
|
|
|
|
#define MAX_CONVERSATION_LEVELS 48
|
|
|
|
#endif
|
|
|
|
|
2024-07-23 07:59:48 +00:00
|
|
|
#define MD5_HEX_SIZE 33
|
|
|
|
|
2023-01-31 17:33:45 +00:00
|
|
|
extern double disk_layout;
|
2023-06-05 16:22:04 +00:00
|
|
|
extern xs_str *srv_basedir;
|
|
|
|
extern xs_dict *srv_config;
|
|
|
|
extern xs_str *srv_baseurl;
|
2022-09-19 19:13:40 +00:00
|
|
|
|
|
|
|
extern int dbglevel;
|
|
|
|
|
2022-09-28 07:46:21 +00:00
|
|
|
#define L(s) (s)
|
|
|
|
|
2024-05-11 17:15:18 +00:00
|
|
|
#define POSTLIKE_OBJECT_TYPE "Note|Question|Page|Article|Video|Event"
|
2024-05-11 16:46:15 +00:00
|
|
|
|
2023-02-07 08:25:01 +00:00
|
|
|
int mkdirx(const char *pathname);
|
|
|
|
|
2022-10-26 04:43:47 +00:00
|
|
|
int valid_status(int status);
|
2023-06-05 16:22:04 +00:00
|
|
|
xs_str *tid(int offset);
|
2022-09-28 15:18:30 +00:00
|
|
|
double ftime(void);
|
2022-09-19 20:19:14 +00:00
|
|
|
|
2023-09-27 11:19:46 +00:00
|
|
|
void srv_log(xs_str *str);
|
|
|
|
#define srv_debug(level, str) do { if (dbglevel >= (level)) \
|
|
|
|
{ srv_log((str)); } } while (0)
|
2022-09-19 19:13:40 +00:00
|
|
|
|
2024-01-03 10:01:25 +00:00
|
|
|
typedef struct {
|
2023-02-12 08:17:38 +00:00
|
|
|
xs_str *uid; /* uid */
|
|
|
|
xs_str *basedir; /* user base directory */
|
|
|
|
xs_dict *config; /* user configuration */
|
|
|
|
xs_dict *config_o; /* user configuration admin override */
|
|
|
|
xs_dict *key; /* keypair */
|
2024-02-15 16:34:46 +00:00
|
|
|
xs_dict *links; /* validated links */
|
2023-02-12 08:17:38 +00:00
|
|
|
xs_str *actor; /* actor url */
|
|
|
|
xs_str *md5; /* actor url md5 */
|
2022-09-19 20:19:14 +00:00
|
|
|
} snac;
|
|
|
|
|
2024-01-03 10:01:25 +00:00
|
|
|
typedef struct {
|
2024-01-10 18:16:05 +00:00
|
|
|
int s_size; /* struct size (for double checking) */
|
2024-01-03 10:01:25 +00:00
|
|
|
int srv_running; /* server running on/off */
|
|
|
|
int use_fcgi; /* FastCGI use on/off */
|
|
|
|
time_t srv_start_time; /* start time */
|
|
|
|
int job_fifo_size; /* job fifo size */
|
2024-01-10 08:16:40 +00:00
|
|
|
int peak_job_fifo_size; /* maximum job fifo size seen */
|
2024-01-03 10:01:25 +00:00
|
|
|
int n_threads; /* number of configured threads */
|
2024-01-10 18:16:05 +00:00
|
|
|
enum { THST_STOP, THST_WAIT, THST_IN, THST_QUEUE } th_state[MAX_THREADS];
|
2024-01-08 07:21:22 +00:00
|
|
|
} srv_state;
|
2024-01-03 10:01:25 +00:00
|
|
|
|
2024-01-14 11:19:35 +00:00
|
|
|
extern srv_state *p_state;
|
|
|
|
|
2023-09-27 11:19:46 +00:00
|
|
|
void snac_log(snac *user, xs_str *str);
|
|
|
|
#define snac_debug(user, level, str) do { if (dbglevel >= (level)) \
|
|
|
|
{ snac_log((user), (str)); } } while (0)
|
|
|
|
|
2024-05-21 12:12:15 +00:00
|
|
|
int srv_open(const char *basedir, int auto_upgrade);
|
2023-09-27 11:19:46 +00:00
|
|
|
void srv_free(void);
|
|
|
|
|
2022-12-04 20:14:18 +00:00
|
|
|
int user_open(snac *snac, const char *uid);
|
2022-09-19 21:03:18 +00:00
|
|
|
void user_free(snac *snac);
|
2023-05-15 11:04:30 +00:00
|
|
|
xs_list *user_list(void);
|
2023-04-16 05:43:41 +00:00
|
|
|
int user_open_by_md5(snac *snac, const char *md5);
|
2024-05-31 15:51:33 +00:00
|
|
|
int user_persist(snac *snac, int publish);
|
2022-09-19 20:23:33 +00:00
|
|
|
|
2022-12-04 20:14:18 +00:00
|
|
|
int validate_uid(const char *uid);
|
2022-09-19 20:58:27 +00:00
|
|
|
|
2023-06-05 16:22:04 +00:00
|
|
|
xs_str *hash_password(const char *uid, const char *passwd, const char *nonce);
|
2022-12-04 20:14:18 +00:00
|
|
|
int check_password(const char *uid, const char *passwd, const char *hash);
|
2022-09-20 07:48:13 +00:00
|
|
|
|
2023-03-02 16:13:17 +00:00
|
|
|
void srv_archive(const char *direction, const char *url, xs_dict *req,
|
2023-02-02 02:49:38 +00:00
|
|
|
const char *payload, int p_size,
|
|
|
|
int status, xs_dict *headers,
|
|
|
|
const char *body, int b_size);
|
2023-03-01 07:25:36 +00:00
|
|
|
void srv_archive_error(const char *prefix, const xs_str *err,
|
2023-04-12 08:41:15 +00:00
|
|
|
const xs_dict *req, const xs_val *data);
|
2024-05-21 12:12:15 +00:00
|
|
|
void srv_archive_qitem(const char *prefix, xs_dict *q_item);
|
2022-09-25 05:28:42 +00:00
|
|
|
|
2022-11-25 12:33:13 +00:00
|
|
|
double mtime_nl(const char *fn, int *n_link);
|
|
|
|
#define mtime(fn) mtime_nl(fn, NULL)
|
2023-04-12 07:43:23 +00:00
|
|
|
double f_ctime(const char *fn);
|
2022-09-20 07:48:13 +00:00
|
|
|
|
2023-11-08 08:20:34 +00:00
|
|
|
int index_add_md5(const char *fn, const char *md5);
|
|
|
|
int index_add(const char *fn, const char *id);
|
2023-02-23 09:42:09 +00:00
|
|
|
int index_gc(const char *fn);
|
2024-07-23 08:09:12 +00:00
|
|
|
int index_first(const char *fn, char md5[MD5_HEX_SIZE]);
|
2022-12-10 10:19:26 +00:00
|
|
|
int index_len(const char *fn);
|
2023-05-24 11:05:43 +00:00
|
|
|
xs_list *index_list(const char *fn, int max);
|
2024-07-23 07:59:48 +00:00
|
|
|
int index_desc_next(FILE *f, char md5[MD5_HEX_SIZE]);
|
|
|
|
int index_desc_first(FILE *f, char md5[MD5_HEX_SIZE], int skip);
|
2023-05-24 11:05:43 +00:00
|
|
|
xs_list *index_list_desc(const char *fn, int skip, int show);
|
2022-11-23 19:50:35 +00:00
|
|
|
|
2023-06-07 09:08:14 +00:00
|
|
|
int object_add(const char *id, const xs_dict *obj);
|
|
|
|
int object_add_ow(const char *id, const xs_dict *obj);
|
|
|
|
int object_here_by_md5(const char *id);
|
|
|
|
int object_here(const char *id);
|
2023-02-05 16:45:00 +00:00
|
|
|
int object_get_by_md5(const char *md5, xs_dict **obj);
|
|
|
|
int object_get(const char *id, xs_dict **obj);
|
2022-11-25 11:09:30 +00:00
|
|
|
int object_del(const char *id);
|
2022-11-27 08:45:06 +00:00
|
|
|
int object_del_if_unref(const char *id);
|
2023-04-12 07:46:42 +00:00
|
|
|
double object_ctime_by_md5(const char *md5);
|
|
|
|
double object_ctime(const char *id);
|
2024-03-12 16:54:54 +00:00
|
|
|
double object_mtime_by_md5(const char *md5);
|
|
|
|
double object_mtime(const char *id);
|
2024-03-12 17:04:09 +00:00
|
|
|
void object_touch(const char *id);
|
|
|
|
|
2022-12-03 16:58:49 +00:00
|
|
|
int object_admire(const char *id, const char *actor, int like);
|
2023-05-01 15:20:49 +00:00
|
|
|
int object_unadmire(const char *id, const char *actor, int like);
|
2022-11-25 11:09:30 +00:00
|
|
|
|
2022-12-10 10:19:26 +00:00
|
|
|
int object_likes_len(const char *id);
|
|
|
|
int object_announces_len(const char *id);
|
|
|
|
|
2023-05-24 11:05:43 +00:00
|
|
|
xs_list *object_children(const char *id);
|
|
|
|
xs_list *object_likes(const char *id);
|
|
|
|
xs_list *object_announces(const char *id);
|
2024-07-23 08:09:12 +00:00
|
|
|
int object_parent(const char *md5, char parent[MD5_HEX_SIZE]);
|
2022-12-02 18:14:59 +00:00
|
|
|
|
2022-12-03 16:58:49 +00:00
|
|
|
int object_user_cache_add(snac *snac, const char *id, const char *cachedir);
|
|
|
|
int object_user_cache_del(snac *snac, const char *id, const char *cachedir);
|
|
|
|
|
2022-11-28 09:46:42 +00:00
|
|
|
int follower_add(snac *snac, const char *actor);
|
|
|
|
int follower_del(snac *snac, const char *actor);
|
|
|
|
int follower_check(snac *snac, const char *actor);
|
2023-06-07 09:08:14 +00:00
|
|
|
xs_list *follower_list(snac *snac);
|
2022-09-20 08:02:00 +00:00
|
|
|
|
2022-09-30 07:59:13 +00:00
|
|
|
double timeline_mtime(snac *snac);
|
2023-04-14 17:17:16 +00:00
|
|
|
int timeline_touch(snac *snac);
|
2023-02-08 12:28:03 +00:00
|
|
|
int timeline_here(snac *snac, const char *md5);
|
2023-02-05 16:39:40 +00:00
|
|
|
int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg);
|
2024-05-21 12:12:15 +00:00
|
|
|
int timeline_del(snac *snac, const char *id);
|
2024-08-09 14:28:57 +00:00
|
|
|
xs_str *user_index_fn(snac *user, const char *idx_name);
|
|
|
|
xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show);
|
2023-04-30 04:39:55 +00:00
|
|
|
xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show);
|
2023-07-14 06:47:20 +00:00
|
|
|
int timeline_add(snac *snac, const char *id, const xs_dict *o_msg);
|
2024-02-21 08:22:32 +00:00
|
|
|
int timeline_admire(snac *snac, const char *id, const char *admirer, int like);
|
2022-09-20 09:31:56 +00:00
|
|
|
|
2024-05-21 12:12:15 +00:00
|
|
|
xs_list *timeline_top_level(snac *snac, const xs_list *list);
|
2023-04-30 04:39:55 +00:00
|
|
|
xs_list *local_list(snac *snac, int max);
|
2024-08-09 14:28:57 +00:00
|
|
|
xs_str *instance_index_fn(void);
|
2023-04-30 04:39:55 +00:00
|
|
|
xs_list *timeline_instance_list(int skip, int show);
|
2022-09-28 02:48:23 +00:00
|
|
|
|
2023-04-23 06:44:26 +00:00
|
|
|
int following_add(snac *snac, const char *actor, const xs_dict *msg);
|
2023-04-23 06:59:14 +00:00
|
|
|
int following_del(snac *snac, const char *actor);
|
2023-04-23 04:05:35 +00:00
|
|
|
int following_check(snac *snac, const char *actor);
|
2023-06-07 09:08:14 +00:00
|
|
|
int following_get(snac *snac, const char *actor, xs_dict **data);
|
2023-05-15 09:15:28 +00:00
|
|
|
xs_list *following_list(snac *snac);
|
2022-09-20 09:31:56 +00:00
|
|
|
|
2023-04-23 04:05:35 +00:00
|
|
|
void mute(snac *snac, const char *actor);
|
|
|
|
void unmute(snac *snac, const char *actor);
|
|
|
|
int is_muted(snac *snac, const char *actor);
|
2024-09-18 10:12:58 +00:00
|
|
|
xs_list *muted_list(snac *user);
|
2022-09-20 10:43:49 +00:00
|
|
|
|
2024-08-29 05:08:26 +00:00
|
|
|
int is_bookmarked(snac *user, const char *id);
|
|
|
|
int bookmark(snac *user, const char *id);
|
|
|
|
int unbookmark(snac *user, const char *id);
|
2024-08-29 05:45:22 +00:00
|
|
|
xs_list *bookmark_list(snac *user);
|
2024-08-29 06:30:09 +00:00
|
|
|
xs_str *bookmark_index_fn(snac *user);
|
2024-08-29 05:08:26 +00:00
|
|
|
|
2023-06-28 18:26:59 +00:00
|
|
|
int pin(snac *user, const char *id);
|
2023-06-28 18:52:09 +00:00
|
|
|
int unpin(snac *user, const char *id);
|
2023-06-28 18:26:59 +00:00
|
|
|
int is_pinned(snac *user, const char *id);
|
2023-09-18 20:52:27 +00:00
|
|
|
int is_pinned_by_md5(snac *user, const char *md5);
|
2023-06-28 18:26:59 +00:00
|
|
|
xs_list *pinned_list(snac *user);
|
|
|
|
|
2024-09-06 07:54:27 +00:00
|
|
|
int is_draft(snac *user, const char *id);
|
|
|
|
void draft_del(snac *user, const char *id);
|
|
|
|
void draft_add(snac *user, const char *id, const xs_dict *msg);
|
2024-09-06 08:31:09 +00:00
|
|
|
xs_list *draft_list(snac *user);
|
2024-09-06 07:54:27 +00:00
|
|
|
|
2023-08-06 16:40:50 +00:00
|
|
|
int limited(snac *user, const char *id, int cmd);
|
|
|
|
#define is_limited(user, id) limited((user), (id), 0)
|
|
|
|
#define limit(user, id) limited((user), (id), 1)
|
|
|
|
#define unlimit(user, id) limited((user), (id), 2)
|
|
|
|
|
2022-11-24 08:39:16 +00:00
|
|
|
void hide(snac *snac, const char *id);
|
|
|
|
int is_hidden(snac *snac, const char *id);
|
|
|
|
|
2023-11-08 07:14:34 +00:00
|
|
|
void tag_index(const char *id, const xs_dict *obj);
|
2024-08-09 14:28:57 +00:00
|
|
|
xs_str *tag_fn(const char *tag);
|
2024-05-21 12:12:15 +00:00
|
|
|
xs_list *tag_search(const char *tag, int skip, int show);
|
2023-11-08 07:14:34 +00:00
|
|
|
|
2024-04-29 06:29:18 +00:00
|
|
|
xs_val *list_maint(snac *user, const char *list, int op);
|
2024-08-09 16:07:05 +00:00
|
|
|
xs_str *list_timeline_fn(snac *user, const char *list);
|
2024-05-07 17:40:28 +00:00
|
|
|
xs_list *list_timeline(snac *user, const char *list, int skip, int show);
|
2024-04-29 07:26:37 +00:00
|
|
|
xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op);
|
2024-04-30 17:41:08 +00:00
|
|
|
void list_distribute(snac *user, const char *who, const xs_dict *post);
|
2024-04-29 05:43:01 +00:00
|
|
|
|
2024-05-21 12:12:15 +00:00
|
|
|
int actor_add(const char *actor, const xs_dict *msg);
|
2023-08-12 09:23:01 +00:00
|
|
|
int actor_get(const char *actor, xs_dict **data);
|
2024-03-12 16:54:54 +00:00
|
|
|
int actor_get_refresh(snac *user, const char *actor, xs_dict **data);
|
2022-09-22 16:50:39 +00:00
|
|
|
|
2023-07-02 09:11:01 +00:00
|
|
|
int static_get(snac *snac, const char *id, xs_val **data, int *size, const char *inm, xs_str **etag);
|
2022-10-16 16:03:28 +00:00
|
|
|
void static_put(snac *snac, const char *id, const char *data, int size);
|
2023-04-21 22:51:06 +00:00
|
|
|
void static_put_meta(snac *snac, const char *id, const char *str);
|
|
|
|
xs_str *static_get_meta(snac *snac, const char *id);
|
2022-09-28 07:29:09 +00:00
|
|
|
|
2023-04-22 06:02:23 +00:00
|
|
|
double history_mtime(snac *snac, const char *id);
|
2023-08-19 07:59:58 +00:00
|
|
|
void history_add(snac *snac, const char *id, const char *content, int size,
|
|
|
|
xs_str **etag);
|
2023-08-19 07:31:13 +00:00
|
|
|
int history_get(snac *snac, const char *id, xs_str **content, int *size,
|
|
|
|
const char *inm, xs_str **etag);
|
2023-04-22 06:02:23 +00:00
|
|
|
int history_del(snac *snac, const char *id);
|
|
|
|
xs_list *history_list(snac *snac);
|
2022-09-30 07:56:29 +00:00
|
|
|
|
2023-05-08 07:02:45 +00:00
|
|
|
void lastlog_write(snac *snac, const char *source);
|
2023-04-05 21:46:51 +00:00
|
|
|
|
2023-04-13 15:12:07 +00:00
|
|
|
xs_str *notify_check_time(snac *snac, int reset);
|
2023-04-13 14:59:17 +00:00
|
|
|
void notify_add(snac *snac, const char *type, const char *utype,
|
2024-07-31 04:22:13 +00:00
|
|
|
const char *actor, const char *objid, const xs_dict *msg);
|
2023-04-13 15:34:48 +00:00
|
|
|
xs_dict *notify_get(snac *snac, const char *id);
|
2024-02-05 09:18:38 +00:00
|
|
|
int notify_new_num(snac *snac);
|
2024-02-05 18:34:27 +00:00
|
|
|
xs_list *notify_list(snac *snac, int skip, int show);
|
2023-04-14 17:39:31 +00:00
|
|
|
void notify_clear(snac *snac);
|
2023-04-13 14:59:17 +00:00
|
|
|
|
2023-03-02 07:43:50 +00:00
|
|
|
void inbox_add(const char *inbox);
|
|
|
|
void inbox_add_by_actor(const xs_dict *actor);
|
2023-03-02 08:15:40 +00:00
|
|
|
xs_list *inbox_list(void);
|
2023-03-02 07:43:50 +00:00
|
|
|
|
2023-06-29 06:07:10 +00:00
|
|
|
int is_instance_blocked(const char *instance);
|
|
|
|
int instance_block(const char *instance);
|
|
|
|
int instance_unblock(const char *instance);
|
|
|
|
|
2024-05-15 11:31:53 +00:00
|
|
|
int content_match(const char *file, const xs_dict *msg);
|
|
|
|
xs_list *content_search(snac *user, const char *regex,
|
|
|
|
int priv, int skip, int show, int max_secs, int *timeout);
|
2024-03-11 05:00:21 +00:00
|
|
|
|
2023-05-04 07:25:09 +00:00
|
|
|
void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries);
|
2023-12-06 13:46:51 +00:00
|
|
|
void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries);
|
2023-02-07 12:31:48 +00:00
|
|
|
void enqueue_output_raw(const char *keyid, const char *seckey,
|
2024-05-21 12:12:15 +00:00
|
|
|
const xs_dict *msg, const xs_str *inbox,
|
|
|
|
int retries, int p_status);
|
|
|
|
void enqueue_output(snac *snac, const xs_dict *msg,
|
|
|
|
const xs_str *inbox, int retries, int p_status);
|
|
|
|
void enqueue_output_by_actor(snac *snac, const xs_dict *msg,
|
|
|
|
const xs_str *actor, int retries);
|
|
|
|
void enqueue_email(const xs_str *msg, int retries);
|
2023-02-07 06:37:23 +00:00
|
|
|
void enqueue_telegram(const xs_str *msg, const char *bot, const char *chat_id);
|
2024-01-12 08:54:14 +00:00
|
|
|
void enqueue_ntfy(const xs_str *msg, const char *ntfy_server, const char *ntfy_token);
|
2023-07-13 16:18:23 +00:00
|
|
|
void enqueue_message(snac *snac, const xs_dict *msg);
|
2023-05-29 09:07:38 +00:00
|
|
|
void enqueue_close_question(snac *user, const char *id, int end_secs);
|
2024-05-04 23:38:22 +00:00
|
|
|
void enqueue_object_request(snac *user, const char *id, int forward_secs);
|
2024-02-20 04:31:34 +00:00
|
|
|
void enqueue_verify_links(snac *user);
|
2024-05-11 17:16:54 +00:00
|
|
|
void enqueue_actor_refresh(snac *user, const char *actor, int forward_secs);
|
2023-05-31 20:06:31 +00:00
|
|
|
int was_question_voted(snac *user, const char *id);
|
2022-09-22 15:12:46 +00:00
|
|
|
|
2023-02-02 03:47:59 +00:00
|
|
|
xs_list *user_queue(snac *snac);
|
2023-02-02 04:21:16 +00:00
|
|
|
xs_list *queue(void);
|
2023-06-07 11:09:19 +00:00
|
|
|
xs_dict *queue_get(const char *fn);
|
2023-02-02 03:44:30 +00:00
|
|
|
xs_dict *dequeue(const char *fn);
|
2022-09-20 19:00:16 +00:00
|
|
|
|
2022-10-04 16:46:12 +00:00
|
|
|
void purge(snac *snac);
|
2022-10-17 09:00:34 +00:00
|
|
|
void purge_all(void);
|
2022-10-04 16:46:12 +00:00
|
|
|
|
2023-02-07 09:29:06 +00:00
|
|
|
xs_dict *http_signed_request_raw(const char *keyid, const char *seckey,
|
|
|
|
const char *method, const char *url,
|
2024-05-21 12:12:15 +00:00
|
|
|
const xs_dict *headers,
|
2023-02-07 09:29:06 +00:00
|
|
|
const char *body, int b_size,
|
|
|
|
int *status, xs_str **payload, int *p_size,
|
|
|
|
int timeout);
|
2023-02-02 02:49:38 +00:00
|
|
|
xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
|
2024-05-21 12:12:15 +00:00
|
|
|
const xs_dict *headers,
|
2023-02-02 02:49:38 +00:00
|
|
|
const char *body, int b_size,
|
|
|
|
int *status, xs_str **payload, int *p_size,
|
|
|
|
int timeout);
|
2024-05-21 12:12:15 +00:00
|
|
|
int check_signature(const xs_dict *req, xs_str **err);
|
2022-09-21 16:27:30 +00:00
|
|
|
|
2024-01-10 18:16:05 +00:00
|
|
|
srv_state *srv_state_op(xs_str **fname, int op);
|
2022-09-21 16:27:30 +00:00
|
|
|
void httpd(void);
|
2022-09-21 19:12:49 +00:00
|
|
|
|
2024-09-18 17:56:40 +00:00
|
|
|
int webfinger_request_signed(snac *snac, const char *qs, xs_str **actor, xs_str **user);
|
|
|
|
int webfinger_request(const char *qs, xs_str **actor, xs_str **user);
|
|
|
|
int webfinger_request_fake(const char *qs, xs_str **actor, xs_str **user);
|
|
|
|
int webfinger_get_handler(xs_dict *req, const char *q_path,
|
|
|
|
xs_val **body, int *b_size, char **ctype);
|
2022-09-23 15:33:33 +00:00
|
|
|
|
2023-01-27 17:17:11 +00:00
|
|
|
const char *default_avatar_base64(void);
|
|
|
|
|
2023-07-04 15:15:38 +00:00
|
|
|
xs_str *process_tags(snac *snac, const char *content, xs_list **tag);
|
|
|
|
|
2024-05-21 12:12:15 +00:00
|
|
|
const char *get_atto(const xs_dict *msg);
|
2024-01-24 18:30:01 +00:00
|
|
|
xs_list *get_attachments(const xs_dict *msg);
|
2024-01-18 22:04:37 +00:00
|
|
|
|
2024-05-21 12:12:15 +00:00
|
|
|
xs_dict *msg_admiration(snac *snac, const char *object, const char *type);
|
|
|
|
xs_dict *msg_repulsion(snac *user, const char *id, const char *type);
|
2023-05-24 09:49:16 +00:00
|
|
|
xs_dict *msg_create(snac *snac, const xs_dict *object);
|
2023-04-23 06:44:26 +00:00
|
|
|
xs_dict *msg_follow(snac *snac, const char *actor);
|
2023-02-20 08:32:44 +00:00
|
|
|
|
2023-04-15 17:05:26 +00:00
|
|
|
xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
|
2024-05-21 12:12:15 +00:00
|
|
|
const xs_str *in_reply_to, const xs_list *attach, int priv);
|
2023-02-20 08:32:44 +00:00
|
|
|
|
2024-05-21 12:12:15 +00:00
|
|
|
xs_dict *msg_undo(snac *snac, const xs_val *object);
|
|
|
|
xs_dict *msg_delete(snac *snac, const char *id);
|
2023-06-04 08:34:39 +00:00
|
|
|
xs_dict *msg_actor(snac *snac);
|
2024-05-21 12:12:15 +00:00
|
|
|
xs_dict *msg_update(snac *snac, const xs_dict *object);
|
2023-05-05 07:54:41 +00:00
|
|
|
xs_dict *msg_ping(snac *user, const char *rcpt);
|
|
|
|
xs_dict *msg_pong(snac *user, const char *rcpt, const char *object);
|
2024-09-18 16:34:17 +00:00
|
|
|
xs_dict *msg_move(snac *user, const char *new_account);
|
2023-05-30 03:54:45 +00:00
|
|
|
xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
|
|
|
|
const xs_list *opts, int multiple, int end_secs);
|
2022-09-26 08:08:14 +00:00
|
|
|
|
2023-04-23 03:33:54 +00:00
|
|
|
int activitypub_request(snac *snac, const char *url, xs_dict **data);
|
2023-12-17 18:53:54 +00:00
|
|
|
int actor_request(snac *user, const char *actor, xs_dict **data);
|
2023-02-07 09:29:06 +00:00
|
|
|
int send_to_inbox_raw(const char *keyid, const char *seckey,
|
|
|
|
const xs_str *inbox, const xs_dict *msg,
|
|
|
|
xs_val **payload, int *p_size, int timeout);
|
|
|
|
int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg,
|
|
|
|
xs_val **payload, int *p_size, int timeout);
|
2024-10-08 15:37:15 +00:00
|
|
|
xs_str *get_actor_inbox(const char *actor, int shared);
|
2023-07-13 16:18:23 +00:00
|
|
|
int send_to_actor(snac *snac, const char *actor, const xs_dict *msg,
|
2023-07-13 15:58:18 +00:00
|
|
|
xs_val **payload, int *p_size, int timeout);
|
2023-08-12 07:43:01 +00:00
|
|
|
int is_msg_public(const xs_dict *msg);
|
2024-02-10 08:08:09 +00:00
|
|
|
int is_msg_from_private_user(const xs_dict *msg);
|
2023-04-11 07:50:12 +00:00
|
|
|
int is_msg_for_me(snac *snac, const xs_dict *msg);
|
2023-02-02 04:21:16 +00:00
|
|
|
|
2023-02-22 07:39:54 +00:00
|
|
|
int process_user_queue(snac *snac);
|
2023-02-06 19:07:29 +00:00
|
|
|
void process_queue_item(xs_dict *q_item);
|
2023-02-22 07:39:54 +00:00
|
|
|
int process_queue(void);
|
2023-02-02 04:21:16 +00:00
|
|
|
|
2023-05-04 07:25:09 +00:00
|
|
|
int activitypub_get_handler(const xs_dict *req, const char *q_path,
|
2022-09-23 18:59:19 +00:00
|
|
|
char **body, int *b_size, char **ctype);
|
2023-05-04 07:25:09 +00:00
|
|
|
int activitypub_post_handler(const xs_dict *req, const char *q_path,
|
2022-09-23 18:28:23 +00:00
|
|
|
char *payload, int p_size,
|
|
|
|
char **body, int *b_size, char **ctype);
|
2022-09-27 07:38:46 +00:00
|
|
|
|
2024-03-25 14:33:14 +00:00
|
|
|
xs_dict *emojis(void);
|
2024-03-25 15:15:09 +00:00
|
|
|
xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag);
|
2023-05-21 18:11:06 +00:00
|
|
|
xs_str *sanitize(const char *content);
|
2023-07-11 17:45:58 +00:00
|
|
|
xs_str *encode_html(const char *str);
|
2022-10-28 16:06:42 +00:00
|
|
|
|
2024-02-21 07:12:05 +00:00
|
|
|
xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
|
2024-02-22 11:26:32 +00:00
|
|
|
int skip, int show, int show_more,
|
2024-10-06 07:56:40 +00:00
|
|
|
const char *title, const char *page, int utl, const char *error);
|
2023-08-14 09:24:41 +00:00
|
|
|
|
2023-05-04 07:25:09 +00:00
|
|
|
int html_get_handler(const xs_dict *req, const char *q_path,
|
2023-07-02 09:11:01 +00:00
|
|
|
char **body, int *b_size, char **ctype, xs_str **etag);
|
2023-05-04 07:25:09 +00:00
|
|
|
int html_post_handler(const xs_dict *req, const char *q_path,
|
|
|
|
char *payload, int p_size,
|
2022-09-28 03:22:08 +00:00
|
|
|
char **body, int *b_size, char **ctype);
|
2024-05-05 09:00:29 +00:00
|
|
|
xs_str *timeline_to_rss(snac *user, const xs_list *timeline, char *title, char *link, char *desc);
|
2022-10-04 06:51:24 +00:00
|
|
|
|
2024-09-04 07:48:35 +00:00
|
|
|
int write_default_css(void);
|
2023-01-31 17:38:56 +00:00
|
|
|
int snac_init(const char *_basedir);
|
2022-12-04 20:14:18 +00:00
|
|
|
int adduser(const char *uid);
|
2022-12-04 20:26:24 +00:00
|
|
|
int resetpwd(snac *snac);
|
2023-10-22 07:00:37 +00:00
|
|
|
int deluser(snac *user);
|
2023-02-06 19:29:18 +00:00
|
|
|
|
2023-08-14 16:02:20 +00:00
|
|
|
extern const char *snac_blurb;
|
|
|
|
|
2023-03-02 11:38:02 +00:00
|
|
|
void job_post(const xs_val *job, int urgent);
|
2023-02-06 19:29:18 +00:00
|
|
|
void job_wait(xs_val **job);
|
2023-04-08 04:09:05 +00:00
|
|
|
|
2023-04-08 07:09:43 +00:00
|
|
|
int oauth_get_handler(const xs_dict *req, const char *q_path,
|
|
|
|
char **body, int *b_size, char **ctype);
|
|
|
|
int oauth_post_handler(const xs_dict *req, const char *q_path,
|
2023-04-09 18:34:05 +00:00
|
|
|
const char *payload, int p_size,
|
|
|
|
char **body, int *b_size, char **ctype);
|
|
|
|
int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|
|
|
char **body, int *b_size, char **ctype);
|
|
|
|
int mastoapi_post_handler(const xs_dict *req, const char *q_path,
|
|
|
|
const char *payload, int p_size,
|
|
|
|
char **body, int *b_size, char **ctype);
|
2024-04-29 07:26:37 +00:00
|
|
|
int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
|
|
|
|
const char *payload, int p_size,
|
|
|
|
char **body, int *b_size, char **ctype);
|
2023-04-21 23:21:09 +00:00
|
|
|
int mastoapi_put_handler(const xs_dict *req, const char *q_path,
|
|
|
|
const char *payload, int p_size,
|
|
|
|
char **body, int *b_size, char **ctype);
|
2024-05-27 10:24:17 +00:00
|
|
|
void persist_image(const char *key, const xs_val *data, const char *payload, snac *snac);
|
|
|
|
int mastoapi_patch_handler(const xs_dict *req, const char *q_path,
|
|
|
|
const char *payload, int p_size,
|
|
|
|
char **body, int *b_size, char **ctype);
|
2023-04-28 06:33:02 +00:00
|
|
|
void mastoapi_purge(void);
|
2024-02-15 18:24:10 +00:00
|
|
|
|
|
|
|
void verify_links(snac *user);
|
2024-05-26 19:45:41 +00:00
|
|
|
|
2024-09-18 10:12:58 +00:00
|
|
|
void export_csv(snac *user);
|
2024-09-18 16:34:17 +00:00
|
|
|
int migrate_account(snac *user);
|
2024-09-18 10:12:58 +00:00
|
|
|
void import_csv(snac *user);
|
2024-05-26 19:45:41 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2024-05-27 14:25:20 +00:00
|
|
|
#define HTTP_STATUS(code, name, text) HTTP_STATUS_ ## name = code,
|
|
|
|
#include "http_codes.h"
|
|
|
|
#undef HTTP_STATUS
|
2024-05-26 19:45:41 +00:00
|
|
|
} http_status;
|
2024-05-27 14:25:20 +00:00
|
|
|
|
|
|
|
const char *http_status_text(int status);
|
2024-05-30 22:30:37 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double timestamp;
|
|
|
|
char *text;
|
|
|
|
} t_announcement;
|
|
|
|
t_announcement *announcement(double after);
|