[mastodon-client] Add visibility checks for status.reblogged_by

This commit is contained in:
Laura Hausmann 2023-10-04 23:13:47 +02:00
parent 7f6ac71dd0
commit ad7c58b8d7
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
2 changed files with 4 additions and 2 deletions

View File

@ -243,7 +243,7 @@ export function setupEndpointsStatus(router: Router): void {
const cache = UserHelpers.getFreshAccountCache(); const cache = UserHelpers.getFreshAccountCache();
const args = normalizeUrlQuery(convertPaginationArgsIds(limitToInt(ctx.query as any))); 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); const users = await UserConverter.encodeMany(res.data, cache);
ctx.body = users.map(m => convertAccount(m)); ctx.body = users.map(m => convertAccount(m));
PaginationHelpers.appendLinkPaginationHeader(args, ctx, res, 40); PaginationHelpers.appendLinkPaginationHeader(args, ctx, res, 40);

View File

@ -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<LinkPaginationObject<User[]>> { public static async getNoteRebloggedBy(note: Note, user: ILocalUser | null, maxId: string | undefined, sinceId: string | undefined, minId: string | undefined, limit: number = 40): Promise<LinkPaginationObject<User[]>> {
if (limit > 80) limit = 80; if (limit > 80) limit = 80;
const query = PaginationHelpers.makePaginationQuery( const query = PaginationHelpers.makePaginationQuery(
Notes.createQueryBuilder("note"), Notes.createQueryBuilder("note"),
@ -212,6 +212,8 @@ export class NoteHelpers {
.andWhere("note.text IS NULL") // We don't want to count quotes as renotes .andWhere("note.text IS NULL") // We don't want to count quotes as renotes
.innerJoinAndSelect("note.user", "user"); .innerJoinAndSelect("note.user", "user");
generateVisibilityQuery(query, user);
return query.take(limit).getMany().then(async p => { return query.take(limit).getMany().then(async p => {
if (minId !== undefined) p = p.reverse(); if (minId !== undefined) p = p.reverse();
const users = p const users = p