diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 22 |
1 files changed, 12 insertions, 10 deletions
| @@ -1352,7 +1352,7 @@ int is_muted(snac *snac, const char *actor) | |||
| 1352 | xs_str *_pinned_fn(snac *user, const char *id) | 1352 | xs_str *_pinned_fn(snac *user, const char *id) |
| 1353 | { | 1353 | { |
| 1354 | xs *md5 = xs_md5_hex(id, strlen(id)); | 1354 | xs *md5 = xs_md5_hex(id, strlen(id)); |
| 1355 | return xs_fmt("%s/pinned/%s", user->basedir, md5); | 1355 | return xs_fmt("%s/pinned/%s.json", user->basedir, md5); |
| 1356 | } | 1356 | } |
| 1357 | 1357 | ||
| 1358 | 1358 | ||
| @@ -1367,26 +1367,28 @@ int is_pinned(snac *user, const char *id) | |||
| 1367 | int pin(snac *user, const char *id) | 1367 | int pin(snac *user, const char *id) |
| 1368 | /* pins a message */ | 1368 | /* pins a message */ |
| 1369 | { | 1369 | { |
| 1370 | int ret = 0; | 1370 | int ret = -2; |
| 1371 | 1371 | ||
| 1372 | if (xs_startswith(id, user->actor)) { | 1372 | if (xs_startswith(id, user->actor)) { |
| 1373 | /* create the subfolder, if it does not exist */ | 1373 | if (is_pinned(user, id)) |
| 1374 | xs *fn = xs_fmt("%s/pinned/", user->basedir); | 1374 | ret = -3; |
| 1375 | mkdirx(fn); | 1375 | else { |
| 1376 | 1376 | /* create the subfolder, if it does not exist */ | |
| 1377 | object_user_cache_add(user, id, "pinned"); | 1377 | xs *fn = xs_fmt("%s/pinned/", user->basedir); |
| 1378 | mkdirx(fn); | ||
| 1378 | 1379 | ||
| 1379 | ret = 1; | 1380 | ret = object_user_cache_add(user, id, "pinned"); |
| 1381 | } | ||
| 1380 | } | 1382 | } |
| 1381 | 1383 | ||
| 1382 | return ret; | 1384 | return ret; |
| 1383 | } | 1385 | } |
| 1384 | 1386 | ||
| 1385 | 1387 | ||
| 1386 | void unpin(snac *user, const char *id) | 1388 | int unpin(snac *user, const char *id) |
| 1387 | /* unpin a message */ | 1389 | /* unpin a message */ |
| 1388 | { | 1390 | { |
| 1389 | object_user_cache_del(user, id, "pinned"); | 1391 | return object_user_cache_del(user, id, "pinned"); |
| 1390 | } | 1392 | } |
| 1391 | 1393 | ||
| 1392 | 1394 | ||