mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
New function enqueue_object_request().
This commit is contained in:
parent
7ea57485c7
commit
fc76ae4e9e
4 changed files with 38 additions and 0 deletions
|
@ -2313,6 +2313,22 @@ void process_user_queue_item(snac *snac, xs_dict *q_item)
|
|||
timeline_request_replies(snac, id);
|
||||
}
|
||||
else
|
||||
if (strcmp(type, "object_request") == 0) {
|
||||
const char *id = xs_dict_get(q_item, "message");
|
||||
|
||||
if (!xs_is_null(id)) {
|
||||
int status;
|
||||
xs *data = NULL;
|
||||
|
||||
status = activitypub_request(snac, id, &data);
|
||||
|
||||
if (valid_status(status))
|
||||
object_add_ow(id, data);
|
||||
|
||||
snac_debug(snac, 1, xs_fmt("object_request %s %d", id, status));
|
||||
}
|
||||
}
|
||||
else
|
||||
if (strcmp(type, "verify_links") == 0) {
|
||||
verify_links(snac);
|
||||
}
|
||||
|
|
15
data.c
15
data.c
|
@ -2651,6 +2651,21 @@ void enqueue_close_question(snac *user, const char *id, int end_secs)
|
|||
}
|
||||
|
||||
|
||||
void enqueue_object_request(snac *user, const char *id, int forward_secs)
|
||||
/* enqueues the request of an object in the future */
|
||||
{
|
||||
xs *qmsg = _new_qmsg("object_request", id, 0);
|
||||
xs *ntid = tid(forward_secs);
|
||||
xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid);
|
||||
|
||||
qmsg = xs_dict_set(qmsg, "ntid", ntid);
|
||||
|
||||
qmsg = _enqueue_put(fn, qmsg);
|
||||
|
||||
snac_debug(user, 0, xs_fmt("enqueue_object_request %s", id));
|
||||
}
|
||||
|
||||
|
||||
void enqueue_verify_links(snac *user)
|
||||
/* enqueues a link verification */
|
||||
{
|
||||
|
|
6
main.c
6
main.c
|
@ -458,6 +458,12 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(cmd, "request2") == 0) { /** **/
|
||||
enqueue_object_request(&snac, url, 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(cmd, "actor") == 0) { /** **/
|
||||
int status;
|
||||
xs *data = NULL;
|
||||
|
|
1
snac.h
1
snac.h
|
@ -226,6 +226,7 @@ void enqueue_telegram(const xs_str *msg, const char *bot, const char *chat_id);
|
|||
void enqueue_ntfy(const xs_str *msg, const char *ntfy_server, const char *ntfy_token);
|
||||
void enqueue_message(snac *snac, const xs_dict *msg);
|
||||
void enqueue_close_question(snac *user, const char *id, int end_secs);
|
||||
void enqueue_object_request(snac *user, const char *id, int forward_secs);
|
||||
void enqueue_verify_links(snac *user);
|
||||
void enqueue_actor_refresh(snac *user, const char *actor);
|
||||
void enqueue_request_replies(snac *user, const char *id);
|
||||
|
|
Loading…
Reference in a new issue