mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
The instance timeline now works.
This commit is contained in:
parent
e31c4810a8
commit
cfa0df3ac5
2 changed files with 13 additions and 20 deletions
29
mastoapi.c
29
mastoapi.c
|
@ -1036,7 +1036,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
}
|
||||
else
|
||||
if (strcmp(cmd, "/v1/timelines/public") == 0) {
|
||||
/* the public timeline (public timelines for all users) */
|
||||
/* the instance public timeline (public timelines for all users) */
|
||||
|
||||
/* NOTE: this api call needs no authorization; but,
|
||||
I need a logged-in user in mastoapi_status() for
|
||||
is_msg_public() and the liked/boosted flags,
|
||||
so it will silently fail for pure public access */
|
||||
|
||||
const char *limit_s = xs_dict_get(args, "limit");
|
||||
int limit = 0;
|
||||
|
@ -1053,7 +1058,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
xs_list *p = timeline;
|
||||
xs_str *md5;
|
||||
|
||||
while (xs_list_iter(&p, &md5) && cnt < limit) {
|
||||
while (logged_in && xs_list_iter(&p, &md5) && cnt < limit) {
|
||||
xs *msg = NULL;
|
||||
|
||||
/* get the entry */
|
||||
|
@ -1064,23 +1069,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
if (strcmp(xs_dict_get(msg, "type"), "Note") != 0)
|
||||
continue;
|
||||
|
||||
/* get the uid */
|
||||
xs *l = xs_split(xs_dict_get(msg, "attributedTo"), "/");
|
||||
const char *uid = xs_list_get(l, -1);
|
||||
|
||||
if (!xs_is_null(uid)) {
|
||||
snac user;
|
||||
|
||||
if (user_open(&user, uid)) {
|
||||
/* convert the Note into a Mastodon status */
|
||||
xs *st = mastoapi_status(&user, msg);
|
||||
|
||||
if (st != NULL)
|
||||
out = xs_list_append(out, st);
|
||||
|
||||
user_free(&user);
|
||||
}
|
||||
/* convert the Note into a Mastodon status */
|
||||
xs *st = mastoapi_status(&snac1, msg);
|
||||
|
||||
if (st != NULL) {
|
||||
out = xs_list_append(out, st);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
|
4
snac.h
4
snac.h
|
@ -127,8 +127,8 @@ int is_muted(snac *snac, const char *actor);
|
|||
void hide(snac *snac, const char *id);
|
||||
int is_hidden(snac *snac, const char *id);
|
||||
|
||||
int actor_add(snac *snac, const char *actor, d_char *msg);
|
||||
int actor_get(snac *snac, const char *actor, d_char **data);
|
||||
int actor_add(snac *snac, const char *actor, xs_dict *msg);
|
||||
int actor_get(snac *snac, const char *actor, xs_dict **data);
|
||||
|
||||
int static_get(snac *snac, const char *id, d_char **data, int *size);
|
||||
void static_put(snac *snac, const char *id, const char *data, int size);
|
||||
|
|
Loading…
Reference in a new issue