mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 06:25:04 +00:00
mastoapi: some tweaks to better match the returned data in timelines.
This commit is contained in:
parent
4676f8ce13
commit
1b3f768a57
2 changed files with 23 additions and 18 deletions
18
data.c
18
data.c
|
@ -1121,15 +1121,6 @@ xs_list *timeline_top_level(snac *snac, xs_list *list)
|
||||||
xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int show)
|
xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int show)
|
||||||
/* returns a timeline (with all entries) */
|
/* returns a timeline (with all entries) */
|
||||||
{
|
{
|
||||||
int c_max;
|
|
||||||
|
|
||||||
/* maximum number of items in the timeline */
|
|
||||||
c_max = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
|
|
||||||
|
|
||||||
/* never more timeline entries than the configured maximum */
|
|
||||||
if (show > c_max)
|
|
||||||
show = c_max;
|
|
||||||
|
|
||||||
xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name);
|
xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name);
|
||||||
|
|
||||||
return index_list_desc(idx, skip, show);
|
return index_list_desc(idx, skip, show);
|
||||||
|
@ -1139,6 +1130,15 @@ xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int sh
|
||||||
xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show)
|
xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show)
|
||||||
/* returns a timeline (only top level entries) */
|
/* returns a timeline (only top level entries) */
|
||||||
{
|
{
|
||||||
|
int c_max;
|
||||||
|
|
||||||
|
/* maximum number of items in the timeline */
|
||||||
|
c_max = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
|
||||||
|
|
||||||
|
/* never more timeline entries than the configured maximum */
|
||||||
|
if (show > c_max)
|
||||||
|
show = c_max;
|
||||||
|
|
||||||
xs *list = timeline_simple_list(snac, idx_name, skip, show);
|
xs *list = timeline_simple_list(snac, idx_name, skip, show);
|
||||||
|
|
||||||
return timeline_top_level(snac, list);
|
return timeline_top_level(snac, list);
|
||||||
|
|
23
mastoapi.c
23
mastoapi.c
|
@ -1265,7 +1265,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
if (limit == 0)
|
if (limit == 0)
|
||||||
limit = 20;
|
limit = 20;
|
||||||
|
|
||||||
xs *timeline = timeline_simple_list(&snac1, "private", 0, 256);
|
xs *timeline = timeline_simple_list(&snac1, "private", 0, 2048);
|
||||||
|
|
||||||
xs *out = xs_list_new();
|
xs *out = xs_list_new();
|
||||||
xs_list *p = timeline;
|
xs_list *p = timeline;
|
||||||
|
@ -1304,19 +1304,24 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
|
if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if 0
|
const char *atto = xs_dict_get(msg, "attributedTo");
|
||||||
/* discard notes from people we don't follow with no boosts */
|
const char *id = xs_dict_get(msg, "id");
|
||||||
if (!following_check(&snac1, xs_dict_get(msg, "attributedTo")) &&
|
|
||||||
object_announces_len(xs_dict_get(msg, "id")) == 0)
|
/* is this message from a person we don't follow? */
|
||||||
continue;
|
if (strcmp(atto, snac1.actor) && !following_check(&snac1, atto)) {
|
||||||
#endif
|
/* if we didn't boost it, discard */
|
||||||
|
xs *idx = object_announces(id);
|
||||||
|
|
||||||
|
if (xs_list_in(idx, snac1.md5) == -1)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* discard notes from muted morons */
|
/* discard notes from muted morons */
|
||||||
if (is_muted(&snac1, xs_dict_get(msg, "attributedTo")))
|
if (is_muted(&snac1, atto))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* discard hidden notes */
|
/* discard hidden notes */
|
||||||
if (is_hidden(&snac1, xs_dict_get(msg, "id")))
|
if (is_hidden(&snac1, id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* discard poll votes (they have a name) */
|
/* discard poll votes (they have a name) */
|
||||||
|
|
Loading…
Reference in a new issue