mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
New function enqueue_request_replies().
This way, the (potentially expensive and slow) call to timeline_request_replies() is detached from actions like replying a message from the web ui.
This commit is contained in:
parent
e926fa2309
commit
ecde1c219e
3 changed files with 24 additions and 4 deletions
|
@ -143,8 +143,6 @@ int actor_request(snac *snac, const char *actor, xs_dict **data)
|
|||
}
|
||||
|
||||
|
||||
void timeline_request_replies(snac *user, const char *id);
|
||||
|
||||
int timeline_request(snac *snac, char **id, xs_str **wrk)
|
||||
/* ensures that an entry and its ancestors are in the timeline */
|
||||
{
|
||||
|
@ -191,7 +189,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk)
|
|||
}
|
||||
}
|
||||
|
||||
timeline_request_replies(snac, *id);
|
||||
enqueue_request_replies(snac, *id);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1679,7 +1677,14 @@ void process_user_queue_item(snac *snac, xs_dict *q_item)
|
|||
update_question(snac, id);
|
||||
}
|
||||
else
|
||||
snac_log(snac, xs_fmt("unexpected q_item type '%s'", type));
|
||||
if (strcmp(type, "request_replies") == 0) {
|
||||
const char *id = xs_dict_get(q_item, "message");
|
||||
|
||||
if (!xs_is_null(id))
|
||||
timeline_request_replies(snac, id);
|
||||
}
|
||||
else
|
||||
snac_log(snac, xs_fmt("unexpected user q_item type '%s'", type));
|
||||
}
|
||||
|
||||
|
||||
|
|
13
data.c
13
data.c
|
@ -1935,6 +1935,19 @@ void enqueue_close_question(snac *user, const char *id, int end_secs)
|
|||
}
|
||||
|
||||
|
||||
void enqueue_request_replies(snac *user, const char *id)
|
||||
/* enqueues a request for the replies of a message */
|
||||
{
|
||||
xs *qmsg = _new_qmsg("request_replies", id, 0);
|
||||
char *ntid = xs_dict_get(qmsg, "ntid");
|
||||
xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid);
|
||||
|
||||
qmsg = _enqueue_put(fn, qmsg);
|
||||
|
||||
snac_debug(user, 0, xs_fmt("enqueue_request_replies %s", id));
|
||||
}
|
||||
|
||||
|
||||
int was_question_voted(snac *user, const char *id)
|
||||
/* returns true if the user voted in this poll */
|
||||
{
|
||||
|
|
2
snac.h
2
snac.h
|
@ -165,6 +165,7 @@ void enqueue_email(xs_str *msg, int retries);
|
|||
void enqueue_telegram(const xs_str *msg, const char *bot, const char *chat_id);
|
||||
void enqueue_message(snac *snac, char *msg);
|
||||
void enqueue_close_question(snac *user, const char *id, int end_secs);
|
||||
void enqueue_request_replies(snac *user, const char *id);
|
||||
int was_question_voted(snac *user, const char *id);
|
||||
|
||||
xs_list *user_queue(snac *snac);
|
||||
|
@ -213,6 +214,7 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
|
|||
|
||||
int activitypub_request(snac *snac, const char *url, xs_dict **data);
|
||||
int actor_request(snac *snac, const char *actor, xs_dict **data);
|
||||
void timeline_request_replies(snac *user, const char *id);
|
||||
int send_to_inbox_raw(const char *keyid, const char *seckey,
|
||||
const xs_str *inbox, const xs_dict *msg,
|
||||
xs_val **payload, int *p_size, int timeout);
|
||||
|
|
Loading…
Reference in a new issue