diff options
| author | 2023-04-30 07:00:49 +0200 | |
|---|---|---|
| committer | 2023-04-30 07:00:49 +0200 | |
| commit | cfa0df3ac5a8b62539a3d1830414ec3d81d24f5d (patch) | |
| tree | 5ec358758f000913067eccc9c9849017a6c10784 | |
| parent | actor_get() returns an actor message for local users. (diff) | |
| download | penes-snac2-cfa0df3ac5a8b62539a3d1830414ec3d81d24f5d.tar.gz penes-snac2-cfa0df3ac5a8b62539a3d1830414ec3d81d24f5d.tar.xz penes-snac2-cfa0df3ac5a8b62539a3d1830414ec3d81d24f5d.zip | |
The instance timeline now works.
| -rw-r--r-- | mastoapi.c | 29 | ||||
| -rw-r--r-- | snac.h | 4 |
2 files changed, 13 insertions, 20 deletions
| @@ -1036,7 +1036,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1036 | } | 1036 | } |
| 1037 | else | 1037 | else |
| 1038 | if (strcmp(cmd, "/v1/timelines/public") == 0) { | 1038 | if (strcmp(cmd, "/v1/timelines/public") == 0) { |
| 1039 | /* the public timeline (public timelines for all users) */ | 1039 | /* the instance public timeline (public timelines for all users) */ |
| 1040 | |||
| 1041 | /* NOTE: this api call needs no authorization; but, | ||
| 1042 | I need a logged-in user in mastoapi_status() for | ||
| 1043 | is_msg_public() and the liked/boosted flags, | ||
| 1044 | so it will silently fail for pure public access */ | ||
| 1040 | 1045 | ||
| 1041 | const char *limit_s = xs_dict_get(args, "limit"); | 1046 | const char *limit_s = xs_dict_get(args, "limit"); |
| 1042 | int limit = 0; | 1047 | int limit = 0; |
| @@ -1053,7 +1058,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1053 | xs_list *p = timeline; | 1058 | xs_list *p = timeline; |
| 1054 | xs_str *md5; | 1059 | xs_str *md5; |
| 1055 | 1060 | ||
| 1056 | while (xs_list_iter(&p, &md5) && cnt < limit) { | 1061 | while (logged_in && xs_list_iter(&p, &md5) && cnt < limit) { |
| 1057 | xs *msg = NULL; | 1062 | xs *msg = NULL; |
| 1058 | 1063 | ||
| 1059 | /* get the entry */ | 1064 | /* get the entry */ |
| @@ -1064,23 +1069,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1064 | if (strcmp(xs_dict_get(msg, "type"), "Note") != 0) | 1069 | if (strcmp(xs_dict_get(msg, "type"), "Note") != 0) |
| 1065 | continue; | 1070 | continue; |
| 1066 | 1071 | ||
| 1067 | /* get the uid */ | 1072 | /* convert the Note into a Mastodon status */ |
| 1068 | xs *l = xs_split(xs_dict_get(msg, "attributedTo"), "/"); | 1073 | xs *st = mastoapi_status(&snac1, msg); |
| 1069 | const char *uid = xs_list_get(l, -1); | ||
| 1070 | |||
| 1071 | if (!xs_is_null(uid)) { | ||
| 1072 | snac user; | ||
| 1073 | |||
| 1074 | if (user_open(&user, uid)) { | ||
| 1075 | /* convert the Note into a Mastodon status */ | ||
| 1076 | xs *st = mastoapi_status(&user, msg); | ||
| 1077 | |||
| 1078 | if (st != NULL) | ||
| 1079 | out = xs_list_append(out, st); | ||
| 1080 | |||
| 1081 | user_free(&user); | ||
| 1082 | } | ||
| 1083 | 1074 | ||
| 1075 | if (st != NULL) { | ||
| 1076 | out = xs_list_append(out, st); | ||
| 1084 | cnt++; | 1077 | cnt++; |
| 1085 | } | 1078 | } |
| 1086 | } | 1079 | } |
| @@ -127,8 +127,8 @@ int is_muted(snac *snac, const char *actor); | |||
| 127 | void hide(snac *snac, const char *id); | 127 | void hide(snac *snac, const char *id); |
| 128 | int is_hidden(snac *snac, const char *id); | 128 | int is_hidden(snac *snac, const char *id); |
| 129 | 129 | ||
| 130 | int actor_add(snac *snac, const char *actor, d_char *msg); | 130 | int actor_add(snac *snac, const char *actor, xs_dict *msg); |
| 131 | int actor_get(snac *snac, const char *actor, d_char **data); | 131 | int actor_get(snac *snac, const char *actor, xs_dict **data); |
| 132 | 132 | ||
| 133 | int static_get(snac *snac, const char *id, d_char **data, int *size); | 133 | int static_get(snac *snac, const char *id, d_char **data, int *size); |
| 134 | void static_put(snac *snac, const char *id, const char *data, int size); | 134 | void static_put(snac *snac, const char *id, const char *data, int size); |