mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 11:40:27 +03:00
New inbox collection functions.
This commit is contained in:
parent
eb0c7eabbb
commit
5e3c50d6e1
@ -117,22 +117,8 @@ int actor_request(snac *snac, char *actor, d_char **data)
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (valid_status(status) && data && *data) {
|
||||
xs *fn = xs_fmt("%s/inboxes.lst", srv_basedir);
|
||||
FILE *f;
|
||||
|
||||
if ((f = fopen(fn, "a")) != NULL) {
|
||||
char *v;
|
||||
if (!xs_is_null(v = xs_dict_get(*data, "endpoints")) &&
|
||||
!xs_is_null(v = xs_dict_get(v, "sharedInbox"))) {
|
||||
fprintf(f, "%s\n", v);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (valid_status(status) && data && *data)
|
||||
inbox_add_by_actor(*data);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
34
data.c
34
data.c
@ -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)
|
||||
|
3
snac.h
3
snac.h
@ -132,6 +132,9 @@ d_char *history_get(snac *snac, char *id);
|
||||
int history_del(snac *snac, char *id);
|
||||
d_char *history_list(snac *snac);
|
||||
|
||||
void inbox_add(const char *inbox);
|
||||
void inbox_add_by_actor(const xs_dict *actor);
|
||||
|
||||
void enqueue_input(snac *snac, xs_dict *msg, xs_dict *req, int retries);
|
||||
void enqueue_output_raw(const char *keyid, const char *seckey,
|
||||
xs_dict *msg, xs_str *inbox, int retries);
|
||||
|
3
utils.c
3
utils.c
@ -157,6 +157,9 @@ int snac_init(const char *basedir)
|
||||
xs *qdir = xs_fmt("%s/queue", srv_basedir);
|
||||
mkdirx(qdir);
|
||||
|
||||
xs *ibdir = xs_fmt("%s/inbox", srv_basedir);
|
||||
mkdirx(ibdir);
|
||||
|
||||
xs *gfn = xs_fmt("%s/greeting.html", srv_basedir);
|
||||
if ((f = fopen(gfn, "w")) == NULL) {
|
||||
printf("ERROR: cannot create '%s'\n", gfn);
|
||||
|
Loading…
Reference in New Issue
Block a user