From ad7c58b8d75c053a31e108706c2f01eeec51c405 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 4 Oct 2023 23:13:47 +0200 Subject: [PATCH] [mastodon-client] Add visibility checks for status.reblogged_by --- packages/backend/src/server/api/mastodon/endpoints/status.ts | 2 +- packages/backend/src/server/api/mastodon/helpers/note.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/endpoints/status.ts b/packages/backend/src/server/api/mastodon/endpoints/status.ts index 63ba88fa8..4d0eb8bcd 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/status.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/status.ts @@ -243,7 +243,7 @@ export function setupEndpointsStatus(router: Router): void { const cache = UserHelpers.getFreshAccountCache(); const args = normalizeUrlQuery(convertPaginationArgsIds(limitToInt(ctx.query as any))); - const res = await NoteHelpers.getNoteRebloggedBy(note, args.max_id, args.since_id, args.min_id, args.limit); + const res = await NoteHelpers.getNoteRebloggedBy(note, user, args.max_id, args.since_id, args.min_id, args.limit); const users = await UserConverter.encodeMany(res.data, cache); ctx.body = users.map(m => convertAccount(m)); PaginationHelpers.appendLinkPaginationHeader(args, ctx, res, 40); diff --git a/packages/backend/src/server/api/mastodon/helpers/note.ts b/packages/backend/src/server/api/mastodon/helpers/note.ts index c3360f2a9..340846743 100644 --- a/packages/backend/src/server/api/mastodon/helpers/note.ts +++ b/packages/backend/src/server/api/mastodon/helpers/note.ts @@ -200,7 +200,7 @@ export class NoteHelpers { } } - public static async getNoteRebloggedBy(note: Note, maxId: string | undefined, sinceId: string | undefined, minId: string | undefined, limit: number = 40): Promise> { + public static async getNoteRebloggedBy(note: Note, user: ILocalUser | null, maxId: string | undefined, sinceId: string | undefined, minId: string | undefined, limit: number = 40): Promise> { if (limit > 80) limit = 80; const query = PaginationHelpers.makePaginationQuery( Notes.createQueryBuilder("note"), @@ -212,6 +212,8 @@ export class NoteHelpers { .andWhere("note.text IS NULL") // We don't want to count quotes as renotes .innerJoinAndSelect("note.user", "user"); + generateVisibilityQuery(query, user); + return query.take(limit).getMany().then(async p => { if (minId !== undefined) p = p.reverse(); const users = p