summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-11-24 13:10:03 +0100
committerdefault <nobody@localhost>2022-11-24 13:10:03 +0100
commit694ae655cb7a6cf1c08bef3ac7d3811d66b08b05 (patch)
tree0c7b08924e5fe05057e800cd74373a54698a839c
parent8be8a9282e0c552256ed95eded9364759db80c53 (diff)
Use index_in() in object_admire() to avoid admiring more than once.
-rw-r--r--data.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/data.c b/data.c
index 316dca2..77375f3 100644
--- a/data.c
+++ b/data.c
@@ -196,7 +196,7 @@ double mtime(char *fn)
int index_add_md5(const char *fn, const char *md5)
/* adds an md5 to an index */
{
- int status = 200;
+ int status = 201; /* Created */
FILE *f;
if ((f = fopen(fn, "a")) != NULL) {
@@ -498,13 +498,17 @@ d_char *object_children(const char *id)
int object_admire(const char *id, const char *actor, int like)
/* actor likes or announces this object */
{
- xs *fn = _object_fn(id);
+ int status = 200;
+ xs *fn = _object_fn(id);
fn = xs_replace_i(fn, ".json", like ? "_l.idx" : "_a.idx");
srv_debug(0, xs_fmt("object_admire (%s) %s %s", like ? "Like" : "Announce", actor, fn));
- return index_add(fn, actor);
+ if (!index_in(fn, actor))
+ status = index_add(fn, actor);
+
+ return status;
}