diff options
author | default <nobody@localhost> | 2022-09-27 15:28:08 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-09-27 15:28:08 +0200 |
commit | 05bf4b2c3c9888ab8830e8f4bbe73e8ad4538760 (patch) | |
tree | d801296d3f04efc7424b7e4f02d5f391d28cbb4e /activitypub.c | |
parent | 6144e0eeeb4f28cfa5f03bf2a583aa58af7d90d0 (diff) |
New function msg_follow().
Diffstat (limited to 'activitypub.c')
-rw-r--r-- | activitypub.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index d54e5ba..3ea05f5 100644 --- a/activitypub.c +++ b/activitypub.c @@ -380,6 +380,34 @@ d_char *msg_create(snac *snac, char *object) } +d_char *msg_follow(snac *snac, char *actor) +/* creates a 'Follow' message */ +{ + d_char *actor_o = NULL; + d_char *msg = NULL; + int status; + + /* request the actor */ + status = actor_request(snac, actor, &actor_o); + + if (valid_status(status)) { + /* check if the actor is an alias */ + char *r_actor = xs_dict_get(actor_o, "id"); + + if (r_actor && strcmp(actor, r_actor) != 0) { + snac_log(snac, xs_fmt("actor to follow is an alias %s -> %s", actor, r_actor)); + actor = r_actor; + } + + msg = msg_base(snac, "Follow", "@dummy", snac->actor, NULL, actor); + } + else + snac_log(snac, xs_fmt("cannot get actor to follow %s %d", actor, status)); + + return msg; +} + + d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) /* creates a 'Note' message */ { |