mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
Minor refactoring to actor_request().
Including commented out experimental code for collecting sharedInboxes.
This commit is contained in:
parent
d75a22adab
commit
eb0c7eabbb
1 changed files with 30 additions and 11 deletions
|
@ -96,25 +96,44 @@ int actor_request(snac *snac, char *actor, d_char **data)
|
||||||
int status, status2;
|
int status, status2;
|
||||||
xs *payload = NULL;
|
xs *payload = NULL;
|
||||||
|
|
||||||
|
if (data)
|
||||||
|
*data = NULL;
|
||||||
|
|
||||||
/* get from disk first */
|
/* get from disk first */
|
||||||
status = actor_get(snac, actor, data);
|
status = actor_get(snac, actor, data);
|
||||||
|
|
||||||
if (status == 200)
|
if (status != 200) {
|
||||||
return status;
|
/* actor data non-existent or stale: get from the net */
|
||||||
|
status2 = activitypub_request(snac, actor, &payload);
|
||||||
|
|
||||||
/* actor data non-existent or stale: get from the net */
|
if (valid_status(status2)) {
|
||||||
status2 = activitypub_request(snac, actor, &payload);
|
/* renew data */
|
||||||
|
status = actor_add(snac, actor, payload);
|
||||||
|
|
||||||
if (valid_status(status2)) {
|
if (data != NULL) {
|
||||||
/* renew data */
|
*data = payload;
|
||||||
status = actor_add(snac, actor, payload);
|
payload = NULL;
|
||||||
|
}
|
||||||
if (data != NULL) {
|
|
||||||
*data = payload;
|
|
||||||
payload = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue