diff options
| -rw-r--r-- | activitypub.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index 4a7c247..8ee7b3d 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -115,6 +115,38 @@ int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_s | |||
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | 117 | ||
| 118 | void process_message(snac *snac, char *msg) | ||
| 119 | /* processes an ActivityPub message */ | ||
| 120 | { | ||
| 121 | /* they exist, were checked previously */ | ||
| 122 | char *actor = xs_dict_get(msg, "actor"); | ||
| 123 | char *type = xs_dict_get(msg, "type"); | ||
| 124 | |||
| 125 | if (strcmp(type, "Follow") == 0) { | ||
| 126 | } | ||
| 127 | else | ||
| 128 | if (strcmp(type, "Undo") == 0) { | ||
| 129 | } | ||
| 130 | else | ||
| 131 | if (strcmp(type, "Create") == 0) { | ||
| 132 | } | ||
| 133 | else | ||
| 134 | if (strcmp(type, "Accept") == 0) { | ||
| 135 | } | ||
| 136 | else | ||
| 137 | if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) { | ||
| 138 | } | ||
| 139 | else | ||
| 140 | if (strcmp(type, "Update") == 0) { | ||
| 141 | } | ||
| 142 | else | ||
| 143 | if (strcmp(type, "Delete") == 0) { | ||
| 144 | } | ||
| 145 | else | ||
| 146 | snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type)); | ||
| 147 | } | ||
| 148 | |||
| 149 | |||
| 118 | void process_queue(snac *snac) | 150 | void process_queue(snac *snac) |
| 119 | /* processes the queue */ | 151 | /* processes the queue */ |
| 120 | { | 152 | { |
| @@ -152,6 +184,13 @@ void process_queue(snac *snac) | |||
| 152 | } | 184 | } |
| 153 | } | 185 | } |
| 154 | } | 186 | } |
| 187 | else | ||
| 188 | if (strcmp(type, "input") == 0) { | ||
| 189 | /* process the message */ | ||
| 190 | char *msg = xs_dict_get(q_item, "object"); | ||
| 191 | |||
| 192 | process_message(snac, msg); | ||
| 193 | } | ||
| 155 | } | 194 | } |
| 156 | } | 195 | } |
| 157 | 196 | ||
| @@ -253,6 +292,9 @@ int activitypub_post_handler(d_char *req, char *q_path, | |||
| 253 | return 404; | 292 | return 404; |
| 254 | } | 293 | } |
| 255 | 294 | ||
| 295 | /* signature checking should happen here */ | ||
| 296 | /* ... */ | ||
| 297 | |||
| 256 | /* decode */ | 298 | /* decode */ |
| 257 | xs *msg = xs_json_loads(payload); | 299 | xs *msg = xs_json_loads(payload); |
| 258 | 300 | ||
| @@ -265,5 +307,8 @@ int activitypub_post_handler(d_char *req, char *q_path, | |||
| 265 | 307 | ||
| 266 | user_free(&snac); | 308 | user_free(&snac); |
| 267 | 309 | ||
| 310 | if (valid_status(status)) | ||
| 311 | *ctype = "application/activity+json"; | ||
| 312 | |||
| 268 | return status; | 313 | return status; |
| 269 | } | 314 | } |