summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2022-09-25 07:58:25 +0200
committerGravatar default2022-09-25 07:58:25 +0200
commit5792ef5d24bd58f5c74a37c43d80720c46a6758a (patch)
tree924c45037ad69eed1b76bb938e026df727bb1fe7
parentThe HTTP request headers are stored in a plain dict. (diff)
downloadsnac2-5792ef5d24bd58f5c74a37c43d80720c46a6758a.tar.gz
snac2-5792ef5d24bd58f5c74a37c43d80720c46a6758a.tar.xz
snac2-5792ef5d24bd58f5c74a37c43d80720c46a6758a.zip
Process 'Create' messages (untested).
-rw-r--r--activitypub.c36
-rw-r--r--snac.h1
2 files changed, 34 insertions, 3 deletions
diff --git a/activitypub.c b/activitypub.c
index ec1d820..a6fa645 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -173,22 +173,51 @@ d_char *msg_update(snac *snac, char *object)
173void process_message(snac *snac, char *msg, char *req) 173void process_message(snac *snac, char *msg, char *req)
174/* processes an ActivityPub message from the input queue */ 174/* processes an ActivityPub message from the input queue */
175{ 175{
176 /* they exist, were checked previously */ 176 /* actor and type exist, were checked previously */
177 char *actor = xs_dict_get(msg, "actor"); 177 char *actor = xs_dict_get(msg, "actor");
178 char *type = xs_dict_get(msg, "type"); 178 char *type = xs_dict_get(msg, "type");
179
180 char *object, *utype;
181
182 object = xs_dict_get(msg, "object");
183 if (object != NULL && xs_type(object) == XSTYPE_SOD)
184 utype = xs_dict_get(object, "type");
185 else
186 utype = "(null)";
179 187
180 /* check the signature */ 188 /* check the signature */
181 /* ... */ 189 /* ... */
182 190
191/*
183 if (strcmp(type, "Follow") == 0) { 192 if (strcmp(type, "Follow") == 0) {
184 } 193 }
185 else 194 else
186 if (strcmp(type, "Undo") == 0) { 195 if (strcmp(type, "Undo") == 0) {
187 } 196 }
188 else 197 else
198*/
189 if (strcmp(type, "Create") == 0) { 199 if (strcmp(type, "Create") == 0) {
200 if (strcmp(utype, "Note") == 0) {
201 if (is_muted(snac, actor))
202 snac_log(snac, xs_fmt("ignored 'Note' from muted actor %s", actor));
203 else {
204 char *id = xs_dict_get(object, "id");
205 char *in_reply_to = xs_dict_get(object, "inReplyTo");
206
207 if (in_reply_to != NULL) {
208 /* recursively download ancestors */
209 /* ... */
210 }
211
212 snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
213 timeline_add(snac, id, msg, in_reply_to);
214 }
215 }
216 else
217 snac_debug(snac, 1, xs_fmt("ignored 'Create' for object type '%s'", utype));
190 } 218 }
191 else 219 else
220/*
192 if (strcmp(type, "Accept") == 0) { 221 if (strcmp(type, "Accept") == 0) {
193 } 222 }
194 else 223 else
@@ -201,6 +230,7 @@ void process_message(snac *snac, char *msg, char *req)
201 if (strcmp(type, "Delete") == 0) { 230 if (strcmp(type, "Delete") == 0) {
202 } 231 }
203 else 232 else
233*/
204 snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type)); 234 snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type));
205} 235}
206 236
diff --git a/snac.h b/snac.h
index c91186f..e499f6e 100644
--- a/snac.h
+++ b/snac.h
@@ -55,6 +55,7 @@ d_char *timeline_find(snac *snac, char *id);
55void timeline_del(snac *snac, char *id); 55void timeline_del(snac *snac, char *id);
56d_char *timeline_get(snac *snac, char *fn); 56d_char *timeline_get(snac *snac, char *fn);
57d_char *timeline_list(snac *snac); 57d_char *timeline_list(snac *snac);
58void timeline_add(snac *snac, char *id, char *msg, char *parent);
58 59
59int following_add(snac *snac, char *actor, char *msg); 60int following_add(snac *snac, char *actor, char *msg);
60int following_del(snac *snac, char *actor); 61int following_del(snac *snac, char *actor);