diff options
| author | 2022-09-30 18:12:32 +0200 | |
|---|---|---|
| committer | 2022-09-30 18:12:32 +0200 | |
| commit | fa9c90c00e72ee7457be75104655d75fc19315fd (patch) | |
| tree | 0d6bb7315dcf3f904b5fcb3807948be1eac30c22 /activitypub.c | |
| parent | Also show Follow messages in the timeline. (diff) | |
| download | snac2-fa9c90c00e72ee7457be75104655d75fc19315fd.tar.gz snac2-fa9c90c00e72ee7457be75104655d75fc19315fd.tar.xz snac2-fa9c90c00e72ee7457be75104655d75fc19315fd.zip | |
Add a date to a Follow message if it doesn't include one.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/activitypub.c b/activitypub.c index 7a30010..5e26fb6 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -600,13 +600,20 @@ int process_message(snac *snac, char *msg, char *req) | |||
| 600 | } | 600 | } |
| 601 | 601 | ||
| 602 | if (strcmp(type, "Follow") == 0) { | 602 | if (strcmp(type, "Follow") == 0) { |
| 603 | xs *reply = msg_accept(snac, msg, actor); | 603 | xs *f_msg = xs_dup(msg); |
| 604 | xs *reply = msg_accept(snac, f_msg, actor); | ||
| 604 | 605 | ||
| 605 | post(snac, reply); | 606 | post(snac, reply); |
| 606 | 607 | ||
| 607 | timeline_add(snac, xs_dict_get(msg, "id"), msg, NULL, NULL); | 608 | if (xs_is_null(xs_dict_get(f_msg, "published"))) { |
| 609 | /* add a date if it doesn't include one (Mastodon) */ | ||
| 610 | xs *date = xs_utc_time("%Y-%m-%dT%H:%M:%SZ"); | ||
| 611 | f_msg = xs_dict_set(f_msg, "published", date); | ||
| 612 | } | ||
| 613 | |||
| 614 | timeline_add(snac, xs_dict_get(f_msg, "id"), f_msg, NULL, NULL); | ||
| 608 | 615 | ||
| 609 | follower_add(snac, actor, msg); | 616 | follower_add(snac, actor, f_msg); |
| 610 | 617 | ||
| 611 | snac_log(snac, xs_fmt("New follower %s", actor)); | 618 | snac_log(snac, xs_fmt("New follower %s", actor)); |
| 612 | } | 619 | } |