summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
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)
96 int status, status2; 96 int status, status2;
97 xs *payload = NULL; 97 xs *payload = NULL;
98 98
99 if (data)
100 *data = NULL;
101
99 /* get from disk first */ 102 /* get from disk first */
100 status = actor_get(snac, actor, data); 103 status = actor_get(snac, actor, data);
101 104
102 if (status == 200) 105 if (status != 200) {
103 return status; 106 /* actor data non-existent or stale: get from the net */
107 status2 = activitypub_request(snac, actor, &payload);
108
109 if (valid_status(status2)) {
110 /* renew data */
111 status = actor_add(snac, actor, payload);
112
113 if (data != NULL) {
114 *data = payload;
115 payload = NULL;
116 }
117 }
118 }
104 119
105 /* actor data non-existent or stale: get from the net */ 120#if 0
106 status2 = activitypub_request(snac, actor, &payload); 121 if (valid_status(status) && data && *data) {
122 xs *fn = xs_fmt("%s/inboxes.lst", srv_basedir);
123 FILE *f;
107 124
108 if (valid_status(status2)) { 125 if ((f = fopen(fn, "a")) != NULL) {
109 /* renew data */ 126 char *v;
110 status = actor_add(snac, actor, payload); 127 if (!xs_is_null(v = xs_dict_get(*data, "endpoints")) &&
128 !xs_is_null(v = xs_dict_get(v, "sharedInbox"))) {
129 fprintf(f, "%s\n", v);
130 }
111 131
112 if (data != NULL) { 132 fclose(f);
113 *data = payload;
114 payload = NULL;
115 } 133 }
116 } 134 }
135#endif
117 136
118 return status; 137 return status;
119} 138}