mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 04:54:32 +00:00
fix backend type errors
This commit is contained in:
parent
7ff15816d1
commit
383633873d
9 changed files with 32 additions and 28 deletions
|
@ -243,7 +243,7 @@ export class WebhookTestService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'edited': {
|
case 'edited': {
|
||||||
send('edited', { note: toPackedNote(dummyNote1) });
|
send('edited', { note: await this.toPackedNote(dummyNote1) });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'follow': {
|
case 'follow': {
|
||||||
|
@ -426,6 +426,7 @@ export class WebhookTestService {
|
||||||
@bindThis
|
@bindThis
|
||||||
private async toPackedUserLite(user: MiUser, override?: Packed<'UserLite'>): Promise<Packed<'UserLite'>> {
|
private async toPackedUserLite(user: MiUser, override?: Packed<'UserLite'>): Promise<Packed<'UserLite'>> {
|
||||||
return {
|
return {
|
||||||
|
...user,
|
||||||
id: user.id,
|
id: user.id,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
username: user.username,
|
username: user.username,
|
||||||
|
@ -445,6 +446,9 @@ export class WebhookTestService {
|
||||||
emojis: await this.customEmojiService.populateEmojis(user.emojis, user.host),
|
emojis: await this.customEmojiService.populateEmojis(user.emojis, user.host),
|
||||||
onlineStatus: 'active',
|
onlineStatus: 'active',
|
||||||
badgeRoles: [],
|
badgeRoles: [],
|
||||||
|
isAdmin: false,
|
||||||
|
isModerator: false,
|
||||||
|
isSystem: false,
|
||||||
...override,
|
...override,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -462,6 +466,9 @@ export class WebhookTestService {
|
||||||
lastFetchedAt: user.lastFetchedAt?.toISOString() ?? null,
|
lastFetchedAt: user.lastFetchedAt?.toISOString() ?? null,
|
||||||
bannerUrl: user.bannerUrl,
|
bannerUrl: user.bannerUrl,
|
||||||
bannerBlurhash: user.bannerBlurhash,
|
bannerBlurhash: user.bannerBlurhash,
|
||||||
|
backgroundUrl: user.backgroundUrl,
|
||||||
|
backgroundBlurhash: user.backgroundBlurhash,
|
||||||
|
listenbrainz: null,
|
||||||
isLocked: user.isLocked,
|
isLocked: user.isLocked,
|
||||||
isSilenced: false,
|
isSilenced: false,
|
||||||
isSuspended: user.isSuspended,
|
isSuspended: user.isSuspended,
|
||||||
|
|
|
@ -7,8 +7,8 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { ApiError } from '../../error.js';
|
|
||||||
import { CacheService } from '@/core/CacheService.js';
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
|
import { ApiError } from '../../error.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['notes'],
|
tags: ['notes'],
|
||||||
|
@ -93,8 +93,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
if (me) {
|
if (me) {
|
||||||
this.queryService.generateMutedUserQuery(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQuery(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,8 +144,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respect blocks and mutes
|
// Respect blocks and mutes
|
||||||
this.queryService.generateBlockedUserQuery(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateMutedUserQuery(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
|
|
||||||
// Support pagination
|
// Support pagination
|
||||||
this.queryService
|
this.queryService
|
||||||
|
|
|
@ -80,8 +80,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
query.andWhere('reaction.reaction = :type', { type });
|
query.andWhere('reaction.reaction = :type', { type });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me) this.queryService.generateMutedUserQuery(query, me);
|
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
if (me) this.queryService.generateBlockedUserQuery(query, me);
|
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
||||||
const reactions = await query.limit(ps.limit).getMany();
|
const reactions = await query.limit(ps.limit).getMany();
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
if (me) {
|
if (me) {
|
||||||
this.queryService.generateBlockedUserQuery(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
}
|
}
|
||||||
|
|
||||||
const note = await query.getOne();
|
const note = await query.getOne();
|
||||||
|
|
|
@ -56,7 +56,7 @@ export class MastodonDataService {
|
||||||
// Restrict visibility
|
// Restrict visibility
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
if (me) {
|
if (me) {
|
||||||
this.queryService.generateBlockedUserQuery(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await query.getOne();
|
return await query.getOne();
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IsNull } from 'typeorm';
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
|
import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { DI } from '@/di-symbols.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 { MastodonConverters } from '@/server/api/mastodon/MastodonConverters.js';
|
||||||
import { MastodonClientService } from '@/server/api/mastodon/MastodonClientService.js';
|
import { MastodonClientService } from '@/server/api/mastodon/MastodonClientService.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
@ -21,9 +20,6 @@ export class ApiInstanceMastodon {
|
||||||
@Inject(DI.meta)
|
@Inject(DI.meta)
|
||||||
private readonly meta: MiMeta,
|
private readonly meta: MiMeta,
|
||||||
|
|
||||||
@Inject(DI.usersRepository)
|
|
||||||
private readonly usersRepository: UsersRepository,
|
|
||||||
|
|
||||||
@Inject(DI.config)
|
@Inject(DI.config)
|
||||||
private readonly config: Config,
|
private readonly config: Config,
|
||||||
|
|
||||||
|
@ -36,19 +32,12 @@ export class ApiInstanceMastodon {
|
||||||
fastify.get('/v1/instance', async (_request, reply) => {
|
fastify.get('/v1/instance', async (_request, reply) => {
|
||||||
const { client, me } = await this.clientService.getAuthClient(_request);
|
const { client, me } = await this.clientService.getAuthClient(_request);
|
||||||
const data = await client.getInstance();
|
const data = await client.getInstance();
|
||||||
const instance = data.data;
|
const contact = this.meta.rootUser != null
|
||||||
const admin = await this.usersRepository.findOne({
|
? await this.mastoConverters.convertAccount(this.meta.rootUser)
|
||||||
where: {
|
: null;
|
||||||
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 roles = await this.roleService.getUserPolicies(me?.id ?? null);
|
const roles = await this.roleService.getUserPolicies(me?.id ?? null);
|
||||||
|
|
||||||
|
const instance = data.data;
|
||||||
const response: MastodonEntity.Instance = {
|
const response: MastodonEntity.Instance = {
|
||||||
uri: this.config.url,
|
uri: this.config.url,
|
||||||
title: this.meta.name || 'Sharkey',
|
title: this.meta.name || 'Sharkey',
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { bindThis } from '@/decorators.js';
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
import type { JsonObject } from '@/misc/json-value.js';
|
import type { JsonObject } from '@/misc/json-value.js';
|
||||||
import { ChatService } from '@/core/ChatService.js';
|
import { ChatService } from '@/core/ChatService.js';
|
||||||
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class ChatRoomChannel extends Channel {
|
class ChatRoomChannel extends Channel {
|
||||||
|
@ -22,8 +23,9 @@ class ChatRoomChannel extends Channel {
|
||||||
|
|
||||||
id: string,
|
id: string,
|
||||||
connection: Channel['connection'],
|
connection: Channel['connection'],
|
||||||
|
noteEntityService: NoteEntityService,
|
||||||
) {
|
) {
|
||||||
super(id, connection);
|
super(id, connection, noteEntityService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -64,6 +66,7 @@ export class ChatRoomChannelService implements MiChannelService<true> {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private chatService: ChatService,
|
private chatService: ChatService,
|
||||||
|
private readonly noteEntityService: NoteEntityService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +76,7 @@ export class ChatRoomChannelService implements MiChannelService<true> {
|
||||||
this.chatService,
|
this.chatService,
|
||||||
id,
|
id,
|
||||||
connection,
|
connection,
|
||||||
|
this.noteEntityService,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { bindThis } from '@/decorators.js';
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
import type { JsonObject } from '@/misc/json-value.js';
|
import type { JsonObject } from '@/misc/json-value.js';
|
||||||
import { ChatService } from '@/core/ChatService.js';
|
import { ChatService } from '@/core/ChatService.js';
|
||||||
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class ChatUserChannel extends Channel {
|
class ChatUserChannel extends Channel {
|
||||||
|
@ -22,8 +23,9 @@ class ChatUserChannel extends Channel {
|
||||||
|
|
||||||
id: string,
|
id: string,
|
||||||
connection: Channel['connection'],
|
connection: Channel['connection'],
|
||||||
|
noteEntityService: NoteEntityService,
|
||||||
) {
|
) {
|
||||||
super(id, connection);
|
super(id, connection, noteEntityService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -64,6 +66,7 @@ export class ChatUserChannelService implements MiChannelService<true> {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private chatService: ChatService,
|
private chatService: ChatService,
|
||||||
|
private readonly noteEntityService: NoteEntityService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +76,7 @@ export class ChatUserChannelService implements MiChannelService<true> {
|
||||||
this.chatService,
|
this.chatService,
|
||||||
id,
|
id,
|
||||||
connection,
|
connection,
|
||||||
|
this.noteEntityService,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue