summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-05-15 11:28:59 +0200
committerGravatar default2023-05-15 11:28:59 +0200
commitbcf267075d389510b4917bf3c1cf3357cbc1a1e1 (patch)
tree80b8a236e4acfca53c7046ddd70a4131c268bb9f
parentDon't repeat accounts when searching. (diff)
downloadsnac2-bcf267075d389510b4917bf3c1cf3357cbc1a1e1.tar.gz
snac2-bcf267075d389510b4917bf3c1cf3357cbc1a1e1.tar.xz
snac2-bcf267075d389510b4917bf3c1cf3357cbc1a1e1.zip
Made mastoapi account search case-insensitive.
-rw-r--r--mastoapi.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 93c4d5a..b1e2f79 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -960,9 +960,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
960 960
961 if (logged_in && strcmp(uid, "search") == 0) { /** **/ 961 if (logged_in && strcmp(uid, "search") == 0) { /** **/
962 /* search for accounts starting with q */ 962 /* search for accounts starting with q */
963 const char *q = xs_dict_get(args, "q"); 963 const char *aq = xs_dict_get(args, "q");
964 964
965 if (!xs_is_null(q)) { 965 if (!xs_is_null(aq)) {
966 xs *q = xs_tolower_i(xs_dup(aq));
966 out = xs_list_new(); 967 out = xs_list_new();
967 xs *wing = following_list(&snac1); 968 xs *wing = following_list(&snac1);
968 xs *wers = follower_list(&snac1); 969 xs *wers = follower_list(&snac1);
@@ -986,10 +987,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
986 if (valid_status(object_get(v, &actor))) { 987 if (valid_status(object_get(v, &actor))) {
987 const char *uname = xs_dict_get(actor, "preferredUsername"); 988 const char *uname = xs_dict_get(actor, "preferredUsername");
988 989
989 if (!xs_is_null(uname) && xs_startswith(uname, q)) { 990 if (!xs_is_null(uname)) {
990 xs *acct = mastoapi_account(actor); 991 xs *luname = xs_tolower_i(xs_dup(uname));
991 992
992 out = xs_list_append(out, acct); 993 if (xs_startswith(luname, q)) {
994 xs *acct = mastoapi_account(actor);
995
996 out = xs_list_append(out, acct);
997 }
993 } 998 }
994 } 999 }
995 } 1000 }