mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
Process 'Create' messages (untested).
This commit is contained in:
parent
b070d2d8f8
commit
5792ef5d24
2 changed files with 34 additions and 3 deletions
|
@ -173,22 +173,51 @@ d_char *msg_update(snac *snac, char *object)
|
||||||
void process_message(snac *snac, char *msg, char *req)
|
void process_message(snac *snac, char *msg, char *req)
|
||||||
/* processes an ActivityPub message from the input queue */
|
/* processes an ActivityPub message from the input queue */
|
||||||
{
|
{
|
||||||
/* they exist, were checked previously */
|
/* actor and type exist, were checked previously */
|
||||||
char *actor = xs_dict_get(msg, "actor");
|
char *actor = xs_dict_get(msg, "actor");
|
||||||
char *type = xs_dict_get(msg, "type");
|
char *type = xs_dict_get(msg, "type");
|
||||||
|
|
||||||
|
char *object, *utype;
|
||||||
|
|
||||||
|
object = xs_dict_get(msg, "object");
|
||||||
|
if (object != NULL && xs_type(object) == XSTYPE_SOD)
|
||||||
|
utype = xs_dict_get(object, "type");
|
||||||
|
else
|
||||||
|
utype = "(null)";
|
||||||
|
|
||||||
/* check the signature */
|
/* check the signature */
|
||||||
/* ... */
|
/* ... */
|
||||||
|
|
||||||
|
/*
|
||||||
if (strcmp(type, "Follow") == 0) {
|
if (strcmp(type, "Follow") == 0) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(type, "Undo") == 0) {
|
if (strcmp(type, "Undo") == 0) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
*/
|
||||||
if (strcmp(type, "Create") == 0) {
|
if (strcmp(type, "Create") == 0) {
|
||||||
|
if (strcmp(utype, "Note") == 0) {
|
||||||
|
if (is_muted(snac, actor))
|
||||||
|
snac_log(snac, xs_fmt("ignored 'Note' from muted actor %s", actor));
|
||||||
|
else {
|
||||||
|
char *id = xs_dict_get(object, "id");
|
||||||
|
char *in_reply_to = xs_dict_get(object, "inReplyTo");
|
||||||
|
|
||||||
|
if (in_reply_to != NULL) {
|
||||||
|
/* recursively download ancestors */
|
||||||
|
/* ... */
|
||||||
|
}
|
||||||
|
|
||||||
|
snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
|
||||||
|
timeline_add(snac, id, msg, in_reply_to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
snac_debug(snac, 1, xs_fmt("ignored 'Create' for object type '%s'", utype));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/*
|
||||||
if (strcmp(type, "Accept") == 0) {
|
if (strcmp(type, "Accept") == 0) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -201,6 +230,7 @@ void process_message(snac *snac, char *msg, char *req)
|
||||||
if (strcmp(type, "Delete") == 0) {
|
if (strcmp(type, "Delete") == 0) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
*/
|
||||||
snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type));
|
snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
snac.h
1
snac.h
|
@ -55,6 +55,7 @@ d_char *timeline_find(snac *snac, char *id);
|
||||||
void timeline_del(snac *snac, char *id);
|
void timeline_del(snac *snac, char *id);
|
||||||
d_char *timeline_get(snac *snac, char *fn);
|
d_char *timeline_get(snac *snac, char *fn);
|
||||||
d_char *timeline_list(snac *snac);
|
d_char *timeline_list(snac *snac);
|
||||||
|
void timeline_add(snac *snac, char *id, char *msg, char *parent);
|
||||||
|
|
||||||
int following_add(snac *snac, char *actor, char *msg);
|
int following_add(snac *snac, char *actor, char *msg);
|
||||||
int following_del(snac *snac, char *actor);
|
int following_del(snac *snac, char *actor);
|
||||||
|
|
Loading…
Reference in a new issue