diff options
| author | 2023-06-07 12:04:59 +0200 | |
|---|---|---|
| committer | 2023-06-07 12:04:59 +0200 | |
| commit | ecde1c219e583d45e5ef46dcdd82c24b888fef1b (patch) | |
| tree | ef3861be55944b489151d045efaec61ae4c41713 | |
| parent | Changed timeline_request_replies() to receive an id and not an object. (diff) | |
| download | snac2-ecde1c219e583d45e5ef46dcdd82c24b888fef1b.tar.gz snac2-ecde1c219e583d45e5ef46dcdd82c24b888fef1b.tar.xz snac2-ecde1c219e583d45e5ef46dcdd82c24b888fef1b.zip | |
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.
| -rw-r--r-- | activitypub.c | 13 | ||||
| -rw-r--r-- | data.c | 13 | ||||
| -rw-r--r-- | snac.h | 2 |
3 files changed, 24 insertions, 4 deletions
diff --git a/activitypub.c b/activitypub.c index f9e7077..10e0e64 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -143,8 +143,6 @@ int actor_request(snac *snac, const char *actor, xs_dict **data) | |||
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | void timeline_request_replies(snac *user, const char *id); | ||
| 147 | |||
| 148 | int timeline_request(snac *snac, char **id, xs_str **wrk) | 146 | int timeline_request(snac *snac, char **id, xs_str **wrk) |
| 149 | /* ensures that an entry and its ancestors are in the timeline */ | 147 | /* ensures that an entry and its ancestors are in the timeline */ |
| 150 | { | 148 | { |
| @@ -191,7 +189,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk) | |||
| 191 | } | 189 | } |
| 192 | } | 190 | } |
| 193 | 191 | ||
| 194 | timeline_request_replies(snac, *id); | 192 | enqueue_request_replies(snac, *id); |
| 195 | } | 193 | } |
| 196 | 194 | ||
| 197 | return status; | 195 | return status; |
| @@ -1679,7 +1677,14 @@ void process_user_queue_item(snac *snac, xs_dict *q_item) | |||
| 1679 | update_question(snac, id); | 1677 | update_question(snac, id); |
| 1680 | } | 1678 | } |
| 1681 | else | 1679 | else |
| 1682 | snac_log(snac, xs_fmt("unexpected q_item type '%s'", type)); | 1680 | if (strcmp(type, "request_replies") == 0) { |
| 1681 | const char *id = xs_dict_get(q_item, "message"); | ||
| 1682 | |||
| 1683 | if (!xs_is_null(id)) | ||
| 1684 | timeline_request_replies(snac, id); | ||
| 1685 | } | ||
| 1686 | else | ||
| 1687 | snac_log(snac, xs_fmt("unexpected user q_item type '%s'", type)); | ||
| 1683 | } | 1688 | } |
| 1684 | 1689 | ||
| 1685 | 1690 | ||
| @@ -1935,6 +1935,19 @@ void enqueue_close_question(snac *user, const char *id, int end_secs) | |||
| 1935 | } | 1935 | } |
| 1936 | 1936 | ||
| 1937 | 1937 | ||
| 1938 | void enqueue_request_replies(snac *user, const char *id) | ||
| 1939 | /* enqueues a request for the replies of a message */ | ||
| 1940 | { | ||
| 1941 | xs *qmsg = _new_qmsg("request_replies", id, 0); | ||
| 1942 | char *ntid = xs_dict_get(qmsg, "ntid"); | ||
| 1943 | xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); | ||
| 1944 | |||
| 1945 | qmsg = _enqueue_put(fn, qmsg); | ||
| 1946 | |||
| 1947 | snac_debug(user, 0, xs_fmt("enqueue_request_replies %s", id)); | ||
| 1948 | } | ||
| 1949 | |||
| 1950 | |||
| 1938 | int was_question_voted(snac *user, const char *id) | 1951 | int was_question_voted(snac *user, const char *id) |
| 1939 | /* returns true if the user voted in this poll */ | 1952 | /* returns true if the user voted in this poll */ |
| 1940 | { | 1953 | { |
| @@ -165,6 +165,7 @@ void enqueue_email(xs_str *msg, int retries); | |||
| 165 | void enqueue_telegram(const xs_str *msg, const char *bot, const char *chat_id); | 165 | void enqueue_telegram(const xs_str *msg, const char *bot, const char *chat_id); |
| 166 | void enqueue_message(snac *snac, char *msg); | 166 | void enqueue_message(snac *snac, char *msg); |
| 167 | void enqueue_close_question(snac *user, const char *id, int end_secs); | 167 | void enqueue_close_question(snac *user, const char *id, int end_secs); |
| 168 | void enqueue_request_replies(snac *user, const char *id); | ||
| 168 | int was_question_voted(snac *user, const char *id); | 169 | int was_question_voted(snac *user, const char *id); |
| 169 | 170 | ||
| 170 | xs_list *user_queue(snac *snac); | 171 | xs_list *user_queue(snac *snac); |
| @@ -213,6 +214,7 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, | |||
| 213 | 214 | ||
| 214 | int activitypub_request(snac *snac, const char *url, xs_dict **data); | 215 | int activitypub_request(snac *snac, const char *url, xs_dict **data); |
| 215 | int actor_request(snac *snac, const char *actor, xs_dict **data); | 216 | int actor_request(snac *snac, const char *actor, xs_dict **data); |
| 217 | void timeline_request_replies(snac *user, const char *id); | ||
| 216 | int send_to_inbox_raw(const char *keyid, const char *seckey, | 218 | int send_to_inbox_raw(const char *keyid, const char *seckey, |
| 217 | const xs_str *inbox, const xs_dict *msg, | 219 | const xs_str *inbox, const xs_dict *msg, |
| 218 | xs_val **payload, int *p_size, int timeout); | 220 | xs_val **payload, int *p_size, int timeout); |