diff options
| author | 2023-02-02 05:21:16 +0100 | |
|---|---|---|
| committer | 2023-02-02 05:21:16 +0100 | |
| commit | 928f22fbbaec5d52836b217ec7a281b880b23f92 (patch) | |
| tree | 07990b389795025cbd184dfc79d8807ae96d9a5a /activitypub.c | |
| parent | New function queue() (the global queue). (diff) | |
| download | snac2-928f22fbbaec5d52836b217ec7a281b880b23f92.tar.gz snac2-928f22fbbaec5d52836b217ec7a281b880b23f92.tar.xz snac2-928f22fbbaec5d52836b217ec7a281b880b23f92.zip | |
Email notifications have been moved to the global queue.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/activitypub.c b/activitypub.c index 5cc059d..9c9ea7c 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -839,7 +839,7 @@ void notify(snac *snac, char *type, char *utype, char *actor, char *msg) | |||
| 839 | body = xs_str_cat(body, s1); | 839 | body = xs_str_cat(body, s1); |
| 840 | } | 840 | } |
| 841 | 841 | ||
| 842 | enqueue_email(snac, body, 0); | 842 | enqueue_email(body, 0); |
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | 845 | ||
| @@ -1137,26 +1137,6 @@ void process_user_queue_item(snac *snac, xs_dict *q_item) | |||
| 1137 | } | 1137 | } |
| 1138 | } | 1138 | } |
| 1139 | } | 1139 | } |
| 1140 | else | ||
| 1141 | if (strcmp(type, "email") == 0) { | ||
| 1142 | /* send this email */ | ||
| 1143 | xs_str *msg = xs_dict_get(q_item, "message"); | ||
| 1144 | int retries = xs_number_get(xs_dict_get(q_item, "retries")); | ||
| 1145 | |||
| 1146 | if (!send_email(msg)) | ||
| 1147 | snac_debug(snac, 1, xs_fmt("email message sent")); | ||
| 1148 | else { | ||
| 1149 | if (retries > queue_retry_max) | ||
| 1150 | snac_log(snac, xs_fmt("process_queue email giving up (errno: %d)", errno)); | ||
| 1151 | else { | ||
| 1152 | /* requeue */ | ||
| 1153 | snac_log(snac, xs_fmt( | ||
| 1154 | "process_queue email requeue #%d (errno: %d)", retries + 1, errno)); | ||
| 1155 | |||
| 1156 | enqueue_email(snac, msg, retries + 1); | ||
| 1157 | } | ||
| 1158 | } | ||
| 1159 | } | ||
| 1160 | } | 1140 | } |
| 1161 | 1141 | ||
| 1162 | 1142 | ||
| @@ -1184,6 +1164,30 @@ void process_user_queue(snac *snac) | |||
| 1184 | void process_queue_item(xs_dict *q_item) | 1164 | void process_queue_item(xs_dict *q_item) |
| 1185 | /* processes an item from the global queue */ | 1165 | /* processes an item from the global queue */ |
| 1186 | { | 1166 | { |
| 1167 | char *type = xs_dict_get(q_item, "type"); | ||
| 1168 | int queue_retry_max = xs_number_get(xs_dict_get(srv_config, "queue_retry_max")); | ||
| 1169 | |||
| 1170 | if (strcmp(type, "email") == 0) { | ||
| 1171 | /* send this email */ | ||
| 1172 | xs_str *msg = xs_dict_get(q_item, "message"); | ||
| 1173 | int retries = xs_number_get(xs_dict_get(q_item, "retries")); | ||
| 1174 | |||
| 1175 | if (!send_email(msg)) | ||
| 1176 | srv_debug(1, xs_fmt("email message sent")); | ||
| 1177 | else { | ||
| 1178 | retries++; | ||
| 1179 | |||
| 1180 | if (retries > queue_retry_max) | ||
| 1181 | srv_log(xs_fmt("process_queue email giving up (errno: %d)", errno)); | ||
| 1182 | else { | ||
| 1183 | /* requeue */ | ||
| 1184 | srv_log(xs_fmt( | ||
| 1185 | "process_queue email requeue #%d (errno: %d)", retries, errno)); | ||
| 1186 | |||
| 1187 | enqueue_email(msg, retries); | ||
| 1188 | } | ||
| 1189 | } | ||
| 1190 | } | ||
| 1187 | } | 1191 | } |
| 1188 | 1192 | ||
| 1189 | 1193 | ||