mastoapi: some search by content tweaks.

This commit is contained in:
default 2024-05-09 09:24:39 +02:00
parent 2c8d4ce6bd
commit 8de93b9cd7
2 changed files with 6 additions and 11 deletions

4
data.c
View File

@ -10,6 +10,7 @@
#include "xs_set.h" #include "xs_set.h"
#include "xs_time.h" #include "xs_time.h"
#include "xs_regex.h" #include "xs_regex.h"
#include "xs_match.h"
#include "snac.h" #include "snac.h"
@ -2570,8 +2571,7 @@ xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, i
if (!valid_status(timeline_get_by_md5(user, md5, &post))) if (!valid_status(timeline_get_by_md5(user, md5, &post)))
continue; continue;
/* must be a Note */ if (!xs_match(xs_dict_get_def(post, "type", "-"), "Note|Question|Page|Article|Video"))
if (strcmp(xs_dict_get_def(post, "type", ""), "Note"))
continue; continue;
char *content = xs_dict_get(post, "content"); char *content = xs_dict_get(post, "content");

View File

@ -1467,9 +1467,6 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
if (limit == 0) if (limit == 0)
limit = 20; limit = 20;
xs *ja = xs_json_dumps(args, 0);
snac_debug(&snac1, 1, xs_fmt("/v1/timelines/home: args='%s'", ja));
xs *timeline = timeline_simple_list(&snac1, "private", 0, 2048); xs *timeline = timeline_simple_list(&snac1, "private", 0, 2048);
xs *out = xs_list_new(); xs *out = xs_list_new();
@ -2266,19 +2263,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
xs *tl = content_search(&snac1, q, 1, 0, &to); xs *tl = content_search(&snac1, q, 1, 0, &to);
int c = 0; int c = 0;
char *v; char *v;
int cnt = 40;
while (xs_list_next(tl, &v, &c)) { while (xs_list_next(tl, &v, &c) && --cnt) {
xs *post = NULL; xs *post = NULL;
if (!valid_status(timeline_get_by_md5(&snac1, v, &post))) if (!valid_status(timeline_get_by_md5(&snac1, v, &post)))
continue; continue;
char *type = xs_dict_get_def(post, "type", "-");
if (!xs_match(type, "Note|Article|Question|Page|Video"))
continue;
xs *s = mastoapi_status(&snac1, post); xs *s = mastoapi_status(&snac1, post);
if (!xs_is_null(s))
stl = xs_list_append(stl, s); stl = xs_list_append(stl, s);
} }
} }