mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 11:27:31 -07:00
[mastodon-client] Fix GET /accounts/:id/statuses
This commit is contained in:
parent
81b08bebd0
commit
16c10f55a3
2 changed files with 7 additions and 6 deletions
|
@ -161,8 +161,9 @@ export function apiAccountMastodon(router: Router): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
const userId = convertId(ctx.params.id, IdType.IceshrimpId);
|
const userId = convertId(ctx.params.id, IdType.IceshrimpId);
|
||||||
|
const query = await getUser(userId);
|
||||||
const args = normalizeUrlQuery(convertTimelinesArgsId(argsToBools(limitToInt(ctx.query))));
|
const args = normalizeUrlQuery(convertTimelinesArgsId(argsToBools(limitToInt(ctx.query))));
|
||||||
const tl = await UserHelpers.getUserStatuses(userId, user, args.max_id, args.since_id, args.min_id, args.limit, args.only_media, args.exclude_replies, args.exclude_reblogs, args.pinned, args.tagged)
|
const tl = await UserHelpers.getUserStatuses(query, user, args.max_id, args.since_id, args.min_id, args.limit, args.only_media, args.exclude_replies, args.exclude_reblogs, args.pinned, args.tagged)
|
||||||
.then(n => NoteConverter.encodeMany(n, user));
|
.then(n => NoteConverter.encodeMany(n, user));
|
||||||
|
|
||||||
ctx.body = tl.map(s => convertStatus(s));
|
ctx.body = tl.map(s => convertStatus(s));
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Note } from "@/models/entities/note.js";
|
import { Note } from "@/models/entities/note.js";
|
||||||
|
import { User } from "@/models/entities/user.js";
|
||||||
import { ILocalUser } from "@/models/entities/user.js";
|
import { ILocalUser } from "@/models/entities/user.js";
|
||||||
import { Followings, Notes } from "@/models/index.js";
|
import { Followings, Notes } from "@/models/index.js";
|
||||||
import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js";
|
import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js";
|
||||||
|
@ -16,7 +17,7 @@ import { meta } from "@/server/api/endpoints/notes/global-timeline.js";
|
||||||
import { NoteHelpers } from "@/server/api/mastodon/helpers/note.js";
|
import { NoteHelpers } from "@/server/api/mastodon/helpers/note.js";
|
||||||
|
|
||||||
export class UserHelpers {
|
export class UserHelpers {
|
||||||
public static async getUserStatuses(userId: string, localUser: ILocalUser | null, maxId: string | undefined, sinceId: string | undefined, minId: string | undefined, limit: number = 20, onlyMedia: boolean = false, excludeReplies: boolean = false, excludeReblogs: boolean = false, pinned: boolean = false, tagged: string | undefined): Promise<Note[]> {
|
public static async getUserStatuses(user: User, localUser: ILocalUser | null, maxId: string | undefined, sinceId: string | undefined, minId: string | undefined, limit: number = 20, onlyMedia: boolean = false, excludeReplies: boolean = false, excludeReblogs: boolean = false, pinned: boolean = false, tagged: string | undefined): Promise<Note[]> {
|
||||||
if (limit > 40) limit = 40;
|
if (limit > 40) limit = 40;
|
||||||
|
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
|
@ -35,7 +36,7 @@ export class UserHelpers {
|
||||||
sinceId ?? minId,
|
sinceId ?? minId,
|
||||||
maxId,
|
maxId,
|
||||||
)
|
)
|
||||||
.andWhere("note.userId = :userId", { userId });
|
.andWhere("note.userId = :userId", { userId: user.id });
|
||||||
|
|
||||||
if (excludeReblogs) query.andWhere("(note.renoteId IS NOT NULL) OR (note.text IS NOT NULL)");
|
if (excludeReblogs) query.andWhere("(note.renoteId IS NOT NULL) OR (note.text IS NOT NULL)");
|
||||||
|
|
||||||
|
@ -52,13 +53,12 @@ export class UserHelpers {
|
||||||
.leftJoinAndSelect("renoteUser.avatar", "renoteUserAvatar")
|
.leftJoinAndSelect("renoteUser.avatar", "renoteUserAvatar")
|
||||||
.leftJoinAndSelect("renoteUser.banner", "renoteUserBanner");
|
.leftJoinAndSelect("renoteUser.banner", "renoteUserBanner");
|
||||||
|
|
||||||
|
//FIXME this doesn't exclude replies to your own reply to someone else's post
|
||||||
generateRepliesQuery(query, !excludeReplies, localUser);
|
generateRepliesQuery(query, !excludeReplies, localUser);
|
||||||
generateVisibilityQuery(query, localUser);
|
generateVisibilityQuery(query, localUser);
|
||||||
if (localUser) {
|
if (localUser) {
|
||||||
generateMutedUserQuery(query, localUser);
|
generateMutedUserQuery(query, localUser, user);
|
||||||
generateMutedNoteQuery(query, localUser);
|
|
||||||
generateBlockedUserQuery(query, localUser);
|
generateBlockedUserQuery(query, localUser);
|
||||||
generateMutedUserRenotesQueryForNotes(query, localUser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onlyMedia) query.andWhere("note.fileIds != '{}'");
|
if (onlyMedia) query.andWhere("note.fileIds != '{}'");
|
||||||
|
|
Loading…
Reference in a new issue