diff options
| author | 2022-11-18 08:21:40 +0100 | |
|---|---|---|
| committer | 2022-11-18 08:21:40 +0100 | |
| commit | 654326aa8bb1cae5105ffca2f227b71e5981290a (patch) | |
| tree | ff4df0c3e747c936286049b7e86694c85c583931 | |
| parent | Fixed Follow bug, introduced by latest sharedInbox change. (diff) | |
| download | penes-snac2-654326aa8bb1cae5105ffca2f227b71e5981290a.tar.gz penes-snac2-654326aa8bb1cae5105ffca2f227b71e5981290a.tar.xz penes-snac2-654326aa8bb1cae5105ffca2f227b71e5981290a.zip | |
New function enqueue_output_to_actor().
| -rw-r--r-- | data.c | 14 | ||||
| -rw-r--r-- | html.c | 5 | ||||
| -rw-r--r-- | main.c | 4 | ||||
| -rw-r--r-- | snac.h | 1 |
4 files changed, 18 insertions, 6 deletions
| @@ -1064,7 +1064,7 @@ void enqueue_input(snac *snac, char *msg, char *req, int retries) | |||
| 1064 | 1064 | ||
| 1065 | 1065 | ||
| 1066 | void enqueue_output(snac *snac, char *msg, char *inbox, int retries) | 1066 | void enqueue_output(snac *snac, char *msg, char *inbox, int retries) |
| 1067 | /* enqueues an output message for an actor */ | 1067 | /* enqueues an output message to an inbox */ |
| 1068 | { | 1068 | { |
| 1069 | if (xs_startswith(inbox, snac->actor)) { | 1069 | if (xs_startswith(inbox, snac->actor)) { |
| 1070 | snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); | 1070 | snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); |
| @@ -1088,6 +1088,18 @@ void enqueue_output(snac *snac, char *msg, char *inbox, int retries) | |||
| 1088 | } | 1088 | } |
| 1089 | 1089 | ||
| 1090 | 1090 | ||
| 1091 | void enqueue_output_by_actor(snac *snac, char *msg, char *actor, int retries) | ||
| 1092 | /* enqueues an output message for an actor */ | ||
| 1093 | { | ||
| 1094 | xs *inbox = get_actor_inbox(snac, actor); | ||
| 1095 | |||
| 1096 | if (!xs_is_null(inbox)) | ||
| 1097 | enqueue_output(snac, msg, inbox, retries); | ||
| 1098 | else | ||
| 1099 | snac_log(snac, xs_fmt("enqueue_output_by_actor cannot get inbox %s", actor)); | ||
| 1100 | } | ||
| 1101 | |||
| 1102 | |||
| 1091 | void enqueue_email(snac *snac, char *msg, int retries) | 1103 | void enqueue_email(snac *snac, char *msg, int retries) |
| 1092 | /* enqueues an email message to be sent */ | 1104 | /* enqueues an email message to be sent */ |
| 1093 | { | 1105 | { |
| @@ -1215,11 +1215,10 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, | |||
| 1215 | if (msg != NULL) { | 1215 | if (msg != NULL) { |
| 1216 | /* reload the actor from the message, in may be different */ | 1216 | /* reload the actor from the message, in may be different */ |
| 1217 | actor = xs_dict_get(msg, "object"); | 1217 | actor = xs_dict_get(msg, "object"); |
| 1218 | xs *inbox = get_actor_inbox(&snac, actor); | ||
| 1219 | 1218 | ||
| 1220 | following_add(&snac, actor, msg); | 1219 | following_add(&snac, actor, msg); |
| 1221 | 1220 | ||
| 1222 | enqueue_output(&snac, msg, inbox, 0); | 1221 | enqueue_output_by_actor(&snac, msg, actor, 0); |
| 1223 | } | 1222 | } |
| 1224 | } | 1223 | } |
| 1225 | else | 1224 | else |
| @@ -1232,7 +1231,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, | |||
| 1232 | 1231 | ||
| 1233 | following_del(&snac, actor); | 1232 | following_del(&snac, actor); |
| 1234 | 1233 | ||
| 1235 | enqueue_output(&snac, msg, actor, 0); | 1234 | enqueue_output_by_actor(&snac, msg, actor, 0); |
| 1236 | 1235 | ||
| 1237 | snac_log(&snac, xs_fmt("unfollowed actor %s", actor)); | 1236 | snac_log(&snac, xs_fmt("unfollowed actor %s", actor)); |
| 1238 | } | 1237 | } |
| @@ -178,7 +178,7 @@ int main(int argc, char *argv[]) | |||
| 178 | 178 | ||
| 179 | following_add(&snac, actor, msg); | 179 | following_add(&snac, actor, msg); |
| 180 | 180 | ||
| 181 | enqueue_output(&snac, msg, actor, 0); | 181 | enqueue_output_by_actor(&snac, msg, actor, 0); |
| 182 | 182 | ||
| 183 | if (dbglevel) { | 183 | if (dbglevel) { |
| 184 | xs *j = xs_json_dumps_pp(msg, 4); | 184 | xs *j = xs_json_dumps_pp(msg, 4); |
| @@ -197,7 +197,7 @@ int main(int argc, char *argv[]) | |||
| 197 | 197 | ||
| 198 | following_del(&snac, url); | 198 | following_del(&snac, url); |
| 199 | 199 | ||
| 200 | enqueue_output(&snac, msg, url, 0); | 200 | enqueue_output_by_actor(&snac, msg, url, 0); |
| 201 | 201 | ||
| 202 | snac_log(&snac, xs_fmt("unfollowed actor %s", url)); | 202 | snac_log(&snac, xs_fmt("unfollowed actor %s", url)); |
| 203 | } | 203 | } |
| @@ -93,6 +93,7 @@ d_char *history_list(snac *snac); | |||
| 93 | 93 | ||
| 94 | void enqueue_input(snac *snac, char *msg, char *req, int retries); | 94 | void enqueue_input(snac *snac, char *msg, char *req, int retries); |
| 95 | void enqueue_output(snac *snac, char *msg, char *inbox, int retries); | 95 | void enqueue_output(snac *snac, char *msg, char *inbox, int retries); |
| 96 | void enqueue_output_by_actor(snac *snac, char *msg, char *actor, int retries); | ||
| 96 | void enqueue_email(snac *snac, char *msg, int retries); | 97 | void enqueue_email(snac *snac, char *msg, int retries); |
| 97 | 98 | ||
| 98 | d_char *queue(snac *snac); | 99 | d_char *queue(snac *snac); |