commit ee0c638
default
·
2024-01-14 14:08:54 +0000 UTC
parent 33a0386
Ensure to now overwrite the Accept + Follow object on repeated follows.
1 files changed,
+13,
-0
M
data.c
M
data.c
+13,
-0
1@@ -1206,6 +1206,19 @@ int following_add(snac *snac, const char *actor, const xs_dict *msg)
2 int ret = 201; /* created */
3 xs *fn = _following_fn(snac, actor);
4 FILE *f;
5+ xs *p_object = NULL;
6+
7+ if (valid_status(following_get(snac, actor, &p_object))) {
8+ /* object already exists; if it's of type Accept,
9+ the actor is already being followed and confirmed,
10+ so do nothing */
11+ char *type = xs_dict_get(p_object, "type");
12+
13+ if (!xs_is_null(type) && strcmp(type, "Accept") == 0) {
14+ snac_debug(snac, 1, xs_fmt("following_add actor already confirmed %s", actor));
15+ return 200;
16+ }
17+ }
18
19 if ((f = fopen(fn, "w")) != NULL) {
20 xs_json_dump(msg, 4, f);