diff options
author | default <nobody@localhost> | 2023-03-02 08:43:50 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2023-03-02 08:43:50 +0100 |
commit | 5e3c50d6e1ea2105add614fa2eb45612e577ddac (patch) | |
tree | 5444d35bde941cb7acd91c543a2eb4edfc0a2b0a /data.c | |
parent | eb0c7eabbb88bed8e30fd7dcd337ce48a5f46a8f (diff) |
New inbox collection functions.
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -96,6 +96,9 @@ int srv_open(char *basedir, int auto_upgrade) xs *qdir = xs_fmt("%s/queue", srv_basedir); mkdirx(qdir); + xs *ibdir = xs_fmt("%s/inboxes", srv_basedir); + mkdirx(ibdir); + #ifdef __OpenBSD__ char *v = xs_dict_get(srv_config, "disable_openbsd_security"); @@ -1363,6 +1366,37 @@ d_char *history_list(snac *snac) } +/** inbox collection **/ + +void inbox_add(const char *inbox) +/* collects a shared inbox */ +{ + xs *md5 = xs_md5_hex(inbox, strlen(inbox)); + xs *fn = xs_fmt("%s/inboxes/%s", srv_basedir, md5); + FILE *f; + + if ((f = fopen(fn, "w")) != NULL) { + pthread_mutex_lock(&data_mutex); + + fprintf(f, "%s\n", inbox); + fclose(f); + + pthread_mutex_unlock(&data_mutex); + } +} + + +void inbox_add_by_actor(const xs_dict *actor) +/* collects an actor's shared inbox, if it has one */ +{ + char *v; + + if (!xs_is_null(v = xs_dict_get(actor, "endpoints")) && + !xs_is_null(v = xs_dict_get(v, "sharedInbox"))) + inbox_add(v); +} + + /** the queue **/ static xs_dict *_enqueue_put(const char *fn, xs_dict *msg) |