diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 22 |
1 files changed, 18 insertions, 4 deletions
| @@ -1358,6 +1358,20 @@ int pending_count(snac *user) | |||
| 1358 | } | 1358 | } |
| 1359 | 1359 | ||
| 1360 | 1360 | ||
| 1361 | int is_msg_mine(snac *user, const char *id) | ||
| 1362 | /* returns true if a post id is by the given user */ | ||
| 1363 | { | ||
| 1364 | int ret = 0; | ||
| 1365 | |||
| 1366 | if (xs_is_string(id)) { | ||
| 1367 | xs *s1 = xs_fmt("%s/", user->actor); | ||
| 1368 | ret = xs_startswith(id, s1); | ||
| 1369 | } | ||
| 1370 | |||
| 1371 | return ret; | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | |||
| 1361 | /** timeline **/ | 1375 | /** timeline **/ |
| 1362 | 1376 | ||
| 1363 | double timeline_mtime(snac *snac) | 1377 | double timeline_mtime(snac *snac) |
| @@ -1453,7 +1467,7 @@ void timeline_update_indexes(snac *snac, const char *id) | |||
| 1453 | { | 1467 | { |
| 1454 | object_user_cache_add(snac, id, "private"); | 1468 | object_user_cache_add(snac, id, "private"); |
| 1455 | 1469 | ||
| 1456 | if (xs_startswith(id, snac->actor)) { | 1470 | if (is_msg_mine(snac, id)) { |
| 1457 | xs *msg = NULL; | 1471 | xs *msg = NULL; |
| 1458 | 1472 | ||
| 1459 | if (valid_status(object_get(id, &msg))) { | 1473 | if (valid_status(object_get(id, &msg))) { |
| @@ -1913,7 +1927,7 @@ int pin(snac *user, const char *id) | |||
| 1913 | { | 1927 | { |
| 1914 | int ret = -2; | 1928 | int ret = -2; |
| 1915 | 1929 | ||
| 1916 | if (xs_startswith(id, user->actor)) { | 1930 | if (is_msg_mine(user, id)) { |
| 1917 | if (is_pinned(user, id)) | 1931 | if (is_pinned(user, id)) |
| 1918 | ret = -3; | 1932 | ret = -3; |
| 1919 | else | 1933 | else |
| @@ -3513,7 +3527,7 @@ void enqueue_output(snac *snac, const xs_dict *msg, | |||
| 3513 | const xs_str *inbox, int retries, int p_status) | 3527 | const xs_str *inbox, int retries, int p_status) |
| 3514 | /* enqueues an output message to an inbox */ | 3528 | /* enqueues an output message to an inbox */ |
| 3515 | { | 3529 | { |
| 3516 | if (xs_startswith(inbox, snac->actor)) { | 3530 | if (is_msg_mine(snac, inbox)) { |
| 3517 | snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); | 3531 | snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); |
| 3518 | return; | 3532 | return; |
| 3519 | } | 3533 | } |
| @@ -4041,7 +4055,7 @@ void delete_purged_posts(snac *user, int days) | |||
| 4041 | if (xs_is_dict(msg)) { | 4055 | if (xs_is_dict(msg)) { |
| 4042 | const char *id = xs_dict_get(msg, "id"); | 4056 | const char *id = xs_dict_get(msg, "id"); |
| 4043 | 4057 | ||
| 4044 | if (xs_is_string(id) && xs_startswith(id, user->actor)) { | 4058 | if (xs_is_string(id) && is_msg_mine(user, id)) { |
| 4045 | xs *d_msg = msg_delete(user, id); | 4059 | xs *d_msg = msg_delete(user, id); |
| 4046 | 4060 | ||
| 4047 | enqueue_message(user, d_msg); | 4061 | enqueue_message(user, d_msg); |