aboutsummaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2025-05-29 13:12:43 +0200
committergrunfink <grunfink@comam.es>2025-05-29 13:12:43 +0200
commit34d85b3e1bbda2e89191026b3815dd9b6f23afcb (patch)
tree631e216fb24ae3dd028ebb4043364de88c80d7df /mastoapi.c
parent77b9cbe6c3064c1656fa5375f7d2d498e34a34e6 (diff)
mastoapi: fixed uploaded images name collision.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index df713a8..27c476e 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -2978,8 +2978,10 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
if (*fn != '\0') {
char *ext = strrchr(fn, '.');
- xs *hash = xs_md5_hex(fn, strlen(fn));
- xs *id = xs_fmt("%s%s", hash, ext);
+ char rnd[32];
+ xs_rnd_buf(rnd, sizeof(rnd));
+ xs *hash = xs_md5_hex(rnd, sizeof(rnd));
+ xs *id = xs_fmt("post-%s%s", hash, ext ? ext : "");
xs *url = xs_fmt("%s/s/%s", snac.actor, id);
int fo = xs_number_get(xs_list_get(file, 1));
int fs = xs_number_get(xs_list_get(file, 2));