diff options
| author | 2023-02-05 17:45:00 +0100 | |
|---|---|---|
| committer | 2023-02-05 17:45:00 +0100 | |
| commit | 71a7569467a53f8533c0eb0f5c62ed94744ed996 (patch) | |
| tree | 7bebbe5d9059a1e7308ff87110cba718b6fd43c5 /data.c | |
| parent | Renamed timeline_get() to timeline_get_by_md5(), as that is what id does. (diff) | |
| download | snac2-71a7569467a53f8533c0eb0f5c62ed94744ed996.tar.gz snac2-71a7569467a53f8533c0eb0f5c62ed94744ed996.tar.xz snac2-71a7569467a53f8533c0eb0f5c62ed94744ed996.zip | |
Deleted the type argument from object_get_my_md5() and object_get().
It was never used.
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 29 |
1 files changed, 9 insertions, 20 deletions
| @@ -466,7 +466,7 @@ int object_here(char *id) | |||
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | 468 | ||
| 469 | int object_get_by_md5(const char *md5, d_char **obj, const char *type) | 469 | int object_get_by_md5(const char *md5, xs_dict **obj) |
| 470 | /* returns a stored object, optionally of the requested type */ | 470 | /* returns a stored object, optionally of the requested type */ |
| 471 | { | 471 | { |
| 472 | int status = 404; | 472 | int status = 404; |
| @@ -481,19 +481,8 @@ int object_get_by_md5(const char *md5, d_char **obj, const char *type) | |||
| 481 | 481 | ||
| 482 | *obj = xs_json_loads(j); | 482 | *obj = xs_json_loads(j); |
| 483 | 483 | ||
| 484 | if (*obj) { | 484 | if (*obj) |
| 485 | status = 200; | 485 | status = 200; |
| 486 | |||
| 487 | /* specific type requested? */ | ||
| 488 | if (!xs_is_null(type)) { | ||
| 489 | char *v = xs_dict_get(*obj, "type"); | ||
| 490 | |||
| 491 | if (xs_is_null(v) || strcmp(v, type) != 0) { | ||
| 492 | status = 404; | ||
| 493 | *obj = xs_free(*obj); | ||
| 494 | } | ||
| 495 | } | ||
| 496 | } | ||
| 497 | } | 486 | } |
| 498 | else | 487 | else |
| 499 | *obj = NULL; | 488 | *obj = NULL; |
| @@ -502,11 +491,11 @@ int object_get_by_md5(const char *md5, d_char **obj, const char *type) | |||
| 502 | } | 491 | } |
| 503 | 492 | ||
| 504 | 493 | ||
| 505 | int object_get(const char *id, d_char **obj, const char *type) | 494 | int object_get(const char *id, xs_dict **obj) |
| 506 | /* returns a stored object, optionally of the requested type */ | 495 | /* returns a stored object, optionally of the requested type */ |
| 507 | { | 496 | { |
| 508 | xs *md5 = xs_md5_hex(id, strlen(id)); | 497 | xs *md5 = xs_md5_hex(id, strlen(id)); |
| 509 | return object_get_by_md5(md5, obj, type); | 498 | return object_get_by_md5(md5, obj); |
| 510 | } | 499 | } |
| 511 | 500 | ||
| 512 | 501 | ||
| @@ -803,7 +792,7 @@ d_char *follower_list(snac *snac) | |||
| 803 | while (xs_list_iter(&p, &v)) { | 792 | while (xs_list_iter(&p, &v)) { |
| 804 | xs *a_obj = NULL; | 793 | xs *a_obj = NULL; |
| 805 | 794 | ||
| 806 | if (valid_status(object_get_by_md5(v, &a_obj, NULL))) { | 795 | if (valid_status(object_get_by_md5(v, &a_obj))) { |
| 807 | char *actor = xs_dict_get(a_obj, "id"); | 796 | char *actor = xs_dict_get(a_obj, "id"); |
| 808 | 797 | ||
| 809 | if (!xs_is_null(actor)) | 798 | if (!xs_is_null(actor)) |
| @@ -827,7 +816,7 @@ double timeline_mtime(snac *snac) | |||
| 827 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg) | 816 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg) |
| 828 | /* gets a message from the timeline */ | 817 | /* gets a message from the timeline */ |
| 829 | { | 818 | { |
| 830 | return object_get_by_md5(md5, msg, NULL); | 819 | return object_get_by_md5(md5, msg); |
| 831 | } | 820 | } |
| 832 | 821 | ||
| 833 | 822 | ||
| @@ -851,7 +840,7 @@ void timeline_update_indexes(snac *snac, const char *id) | |||
| 851 | if (xs_startswith(id, snac->actor)) { | 840 | if (xs_startswith(id, snac->actor)) { |
| 852 | xs *msg = NULL; | 841 | xs *msg = NULL; |
| 853 | 842 | ||
| 854 | if (valid_status(object_get(id, &msg, NULL))) { | 843 | if (valid_status(object_get(id, &msg))) { |
| 855 | /* if its ours and is public, also store in public */ | 844 | /* if its ours and is public, also store in public */ |
| 856 | if (is_msg_public(snac, msg)) | 845 | if (is_msg_public(snac, msg)) |
| 857 | object_user_cache_add(snac, id, "public"); | 846 | object_user_cache_add(snac, id, "public"); |
| @@ -1138,7 +1127,7 @@ void hide(snac *snac, const char *id) | |||
| 1138 | xs *co = NULL; | 1127 | xs *co = NULL; |
| 1139 | 1128 | ||
| 1140 | /* resolve to get the id */ | 1129 | /* resolve to get the id */ |
| 1141 | if (valid_status(object_get_by_md5(v, &co, NULL))) { | 1130 | if (valid_status(object_get_by_md5(v, &co))) { |
| 1142 | if ((v = xs_dict_get(co, "id")) != NULL) | 1131 | if ((v = xs_dict_get(co, "id")) != NULL) |
| 1143 | hide(snac, v); | 1132 | hide(snac, v); |
| 1144 | } | 1133 | } |
| @@ -1178,7 +1167,7 @@ int actor_get(snac *snac, const char *actor, d_char **data) | |||
| 1178 | } | 1167 | } |
| 1179 | 1168 | ||
| 1180 | /* read the object */ | 1169 | /* read the object */ |
| 1181 | if (!valid_status(status = object_get(actor, &d, NULL))) | 1170 | if (!valid_status(status = object_get(actor, &d))) |
| 1182 | return status; | 1171 | return status; |
| 1183 | 1172 | ||
| 1184 | if (data) | 1173 | if (data) |