fix backend type errors

This commit is contained in:
Hazelnoot 2025-04-01 10:12:59 -04:00
parent 7ff15816d1
commit 383633873d
9 changed files with 32 additions and 28 deletions

View file

@ -243,7 +243,7 @@ export class WebhookTestService {
break;
}
case 'edited': {
send('edited', { note: toPackedNote(dummyNote1) });
send('edited', { note: await this.toPackedNote(dummyNote1) });
break;
}
case 'follow': {
@ -426,6 +426,7 @@ export class WebhookTestService {
@bindThis
private async toPackedUserLite(user: MiUser, override?: Packed<'UserLite'>): Promise<Packed<'UserLite'>> {
return {
...user,
id: user.id,
name: user.name,
username: user.username,
@ -445,6 +446,9 @@ export class WebhookTestService {
emojis: await this.customEmojiService.populateEmojis(user.emojis, user.host),
onlineStatus: 'active',
badgeRoles: [],
isAdmin: false,
isModerator: false,
isSystem: false,
...override,
};
}
@ -462,6 +466,9 @@ export class WebhookTestService {
lastFetchedAt: user.lastFetchedAt?.toISOString() ?? null,
bannerUrl: user.bannerUrl,
bannerBlurhash: user.bannerBlurhash,
backgroundUrl: user.backgroundUrl,
backgroundBlurhash: user.backgroundBlurhash,
listenbrainz: null,
isLocked: user.isLocked,
isSilenced: false,
isSuspended: user.isSuspended,

View file

@ -7,8 +7,8 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
import { DI } from '@/di-symbols.js';
import { RoleService } from '@/core/RoleService.js';
import { ApiError } from '../../error.js';
import { CacheService } from '@/core/CacheService.js';
import { ApiError } from '../../error.js';
export const meta = {
tags: ['notes'],
@ -93,8 +93,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('renote.user', 'renoteUser');
if (me) {
this.queryService.generateMutedUserQuery(query, me);
this.queryService.generateBlockedUserQuery(query, me);
this.queryService.generateMutedUserQueryForNotes(query, me);
this.queryService.generateBlockedUserQueryForNotes(query, me);
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
}

View file

@ -144,8 +144,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
// Respect blocks and mutes
this.queryService.generateBlockedUserQuery(query, me);
this.queryService.generateMutedUserQuery(query, me);
this.queryService.generateBlockedUserQueryForNotes(query, me);
this.queryService.generateMutedUserQueryForNotes(query, me);
// Support pagination
this.queryService

View file

@ -80,8 +80,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
query.andWhere('reaction.reaction = :type', { type });
}
if (me) this.queryService.generateMutedUserQuery(query, me);
if (me) this.queryService.generateBlockedUserQuery(query, me);
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
const reactions = await query.limit(ps.limit).getMany();

View file

@ -67,7 +67,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
this.queryService.generateVisibilityQuery(query, me);
if (me) {
this.queryService.generateBlockedUserQuery(query, me);
this.queryService.generateBlockedUserQueryForNotes(query, me);
}
const note = await query.getOne();

View file

@ -56,7 +56,7 @@ export class MastodonDataService {
// Restrict visibility
this.queryService.generateVisibilityQuery(query, me);
if (me) {
this.queryService.generateBlockedUserQuery(query, me);
this.queryService.generateBlockedUserQueryForNotes(query, me);
}
return await query.getOne();

View file

@ -3,12 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { IsNull } from 'typeorm';
import { Inject, Injectable } from '@nestjs/common';
import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
import type { Config } from '@/config.js';
import { DI } from '@/di-symbols.js';
import type { MiMeta, UsersRepository } from '@/models/_.js';
import type { MiMeta } from '@/models/_.js';
import { MastodonConverters } from '@/server/api/mastodon/MastodonConverters.js';
import { MastodonClientService } from '@/server/api/mastodon/MastodonClientService.js';
import { RoleService } from '@/core/RoleService.js';
@ -21,9 +20,6 @@ export class ApiInstanceMastodon {
@Inject(DI.meta)
private readonly meta: MiMeta,
@Inject(DI.usersRepository)
private readonly usersRepository: UsersRepository,
@Inject(DI.config)
private readonly config: Config,
@ -36,19 +32,12 @@ export class ApiInstanceMastodon {
fastify.get('/v1/instance', async (_request, reply) => {
const { client, me } = await this.clientService.getAuthClient(_request);
const data = await client.getInstance();
const instance = data.data;
const admin = await this.usersRepository.findOne({
where: {
host: IsNull(),
isRoot: true,
isDeleted: false,
isSuspended: false,
},
order: { id: 'ASC' },
});
const contact = admin == null ? null : await this.mastoConverters.convertAccount((await client.getAccount(admin.id)).data);
const contact = this.meta.rootUser != null
? await this.mastoConverters.convertAccount(this.meta.rootUser)
: null;
const roles = await this.roleService.getUserPolicies(me?.id ?? null);
const instance = data.data;
const response: MastodonEntity.Instance = {
uri: this.config.url,
title: this.meta.name || 'Sharkey',

View file

@ -8,6 +8,7 @@ import { bindThis } from '@/decorators.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js';
import type { JsonObject } from '@/misc/json-value.js';
import { ChatService } from '@/core/ChatService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import Channel, { type MiChannelService } from '../channel.js';
class ChatRoomChannel extends Channel {
@ -22,8 +23,9 @@ class ChatRoomChannel extends Channel {
id: string,
connection: Channel['connection'],
noteEntityService: NoteEntityService,
) {
super(id, connection);
super(id, connection, noteEntityService);
}
@bindThis
@ -64,6 +66,7 @@ export class ChatRoomChannelService implements MiChannelService<true> {
constructor(
private chatService: ChatService,
private readonly noteEntityService: NoteEntityService,
) {
}
@ -73,6 +76,7 @@ export class ChatRoomChannelService implements MiChannelService<true> {
this.chatService,
id,
connection,
this.noteEntityService,
);
}
}

View file

@ -8,6 +8,7 @@ import { bindThis } from '@/decorators.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js';
import type { JsonObject } from '@/misc/json-value.js';
import { ChatService } from '@/core/ChatService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import Channel, { type MiChannelService } from '../channel.js';
class ChatUserChannel extends Channel {
@ -22,8 +23,9 @@ class ChatUserChannel extends Channel {
id: string,
connection: Channel['connection'],
noteEntityService: NoteEntityService,
) {
super(id, connection);
super(id, connection, noteEntityService);
}
@bindThis
@ -64,6 +66,7 @@ export class ChatUserChannelService implements MiChannelService<true> {
constructor(
private chatService: ChatService,
private readonly noteEntityService: NoteEntityService,
) {
}
@ -73,6 +76,7 @@ export class ChatUserChannelService implements MiChannelService<true> {
this.chatService,
id,
connection,
this.noteEntityService,
);
}
}