summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-03-01 09:22:32 +0100
committerdefault <nobody@localhost>2023-03-01 09:22:32 +0100
commiteb0c7eabbb88bed8e30fd7dcd337ce48a5f46a8f (patch)
tree868a80c896ea59cecff2fc7ac44ab15064f96be0 /activitypub.c
parentd75a22adab5b93c0705b9f58fe660d82219ad573 (diff)
Minor refactoring to actor_request().
Including commented out experimental code for collecting sharedInboxes.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/activitypub.c b/activitypub.c
index bb68a7d..a259a25 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -96,24 +96,43 @@ int actor_request(snac *snac, char *actor, d_char **data)
int status, status2;
xs *payload = NULL;
+ if (data)
+ *data = NULL;
+
/* get from disk first */
status = actor_get(snac, actor, data);
- if (status == 200)
- return status;
+ if (status != 200) {
+ /* actor data non-existent or stale: get from the net */
+ status2 = activitypub_request(snac, actor, &payload);
+
+ if (valid_status(status2)) {
+ /* renew data */
+ status = actor_add(snac, actor, payload);
+
+ if (data != NULL) {
+ *data = payload;
+ payload = NULL;
+ }
+ }
+ }
- /* actor data non-existent or stale: get from the net */
- status2 = activitypub_request(snac, actor, &payload);
+#if 0
+ if (valid_status(status) && data && *data) {
+ xs *fn = xs_fmt("%s/inboxes.lst", srv_basedir);
+ FILE *f;
- if (valid_status(status2)) {
- /* renew data */
- status = actor_add(snac, actor, payload);
+ 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);
+ }
- if (data != NULL) {
- *data = payload;
- payload = NULL;
+ fclose(f);
}
}
+#endif
return status;
}