commit 694ae65
default
·
2022-11-24 12:10:03 +0000 UTC
parent 8be8a92
Use index_in() in object_admire() to avoid admiring more than once.
1 files changed,
+7,
-3
M
data.c
M
data.c
+7,
-3
1@@ -196,7 +196,7 @@ double mtime(char *fn)
2 int index_add_md5(const char *fn, const char *md5)
3 /* adds an md5 to an index */
4 {
5- int status = 200;
6+ int status = 201; /* Created */
7 FILE *f;
8
9 if ((f = fopen(fn, "a")) != NULL) {
10@@ -498,13 +498,17 @@ d_char *object_children(const char *id)
11 int object_admire(const char *id, const char *actor, int like)
12 /* actor likes or announces this object */
13 {
14- xs *fn = _object_fn(id);
15+ int status = 200;
16+ xs *fn = _object_fn(id);
17
18 fn = xs_replace_i(fn, ".json", like ? "_l.idx" : "_a.idx");
19
20 srv_debug(0, xs_fmt("object_admire (%s) %s %s", like ? "Like" : "Announce", actor, fn));
21
22- return index_add(fn, actor);
23+ if (!index_in(fn, actor))
24+ status = index_add(fn, actor);
25+
26+ return status;
27 }
28
29