commit ee0c6386ccfda1efddf2f6aab6fa1cba0e51db4b
parent 33a0386a1ee4aad045260b7dd36c6d4d5dea087c
Author: default <nobody@localhost>
Date: Sun, 14 Jan 2024 15:08:54 +0100
Ensure to now overwrite the Accept + Follow object on repeated follows.
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/data.c b/data.c
@@ -1206,6 +1206,19 @@ int following_add(snac *snac, const char *actor, const xs_dict *msg)
int ret = 201; /* created */
xs *fn = _following_fn(snac, actor);
FILE *f;
+ xs *p_object = NULL;
+
+ if (valid_status(following_get(snac, actor, &p_object))) {
+ /* object already exists; if it's of type Accept,
+ the actor is already being followed and confirmed,
+ so do nothing */
+ char *type = xs_dict_get(p_object, "type");
+
+ if (!xs_is_null(type) && strcmp(type, "Accept") == 0) {
+ snac_debug(snac, 1, xs_fmt("following_add actor already confirmed %s", actor));
+ return 200;
+ }
+ }
if ((f = fopen(fn, "w")) != NULL) {
xs_json_dump(msg, 4, f);