lint fix
This commit is contained in:
parent
4abecb2bc1
commit
57331536f2
12 changed files with 157 additions and 113 deletions
|
|
@ -16,10 +16,8 @@ import type { EmojisRepository, MiRole, MiUser } from '@/models/_.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { MemoryKVCache, RedisSingleCache } from '@/misc/cache.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { query } from '@/misc/prelude/url.js';
|
||||
import type { Serialized } from '@/types.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
|
||||
const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/;
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -31,12 +29,6 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
|
||||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.emojisRepository)
|
||||
private emojisRepository: EmojisRepository,
|
||||
|
||||
|
|
@ -119,7 +111,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||
license?: string | null;
|
||||
isSensitive?: boolean;
|
||||
localOnly?: boolean;
|
||||
draft: boolean;
|
||||
draft: boolean;
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
|
||||
}, moderator?: MiUser): Promise<void> {
|
||||
const emoji = await this.emojisRepository.findOneByOrFail({ id: id });
|
||||
|
|
@ -134,7 +126,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||
license: data.license,
|
||||
isSensitive: data.isSensitive,
|
||||
localOnly: data.localOnly,
|
||||
draft: data.draft,
|
||||
draft: data.draft,
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: data.roleIdsThatCanBeUsedThisEmojiAsReaction ?? undefined,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
|||
import { WebhookService } from '@/core/WebhookService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { FollowingsRepository, FollowRequestsRepository, InstancesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type {
|
||||
FollowingsRepository,
|
||||
FollowRequestsRepository,
|
||||
InstancesRepository,
|
||||
UserProfilesRepository,
|
||||
UsersRepository,
|
||||
} from '@/models/_.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
|
@ -51,25 +57,18 @@ export class UserFollowingService implements OnModuleInit {
|
|||
|
||||
constructor(
|
||||
private moduleRef: ModuleRef,
|
||||
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
||||
@Inject(DI.userProfilesRepository)
|
||||
private userProfilesRepository: UserProfilesRepository,
|
||||
|
||||
@Inject(DI.followingsRepository)
|
||||
private followingsRepository: FollowingsRepository,
|
||||
|
||||
@Inject(DI.followRequestsRepository)
|
||||
private followRequestsRepository: FollowRequestsRepository,
|
||||
|
||||
@Inject(DI.instancesRepository)
|
||||
private instancesRepository: InstancesRepository,
|
||||
|
||||
private cacheService: CacheService,
|
||||
private userEntityService: UserEntityService,
|
||||
private idService: IdService,
|
||||
|
|
@ -91,7 +90,9 @@ export class UserFollowingService implements OnModuleInit {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public async follow(_follower: { id: MiUser['id'] }, _followee: { id: MiUser['id'] }, requestId?: string, silent = false): Promise<void> {
|
||||
public async follow(_follower: { id: MiUser['id'] }, _followee: {
|
||||
id: MiUser['id']
|
||||
}, requestId?: string, silent = false): Promise<void> {
|
||||
const [follower, followee] = await Promise.all([
|
||||
this.usersRepository.findOneByOrFail({ id: _follower.id }),
|
||||
this.usersRepository.findOneByOrFail({ id: _followee.id }),
|
||||
|
|
@ -184,10 +185,18 @@ export class UserFollowingService implements OnModuleInit {
|
|||
@bindThis
|
||||
private async insertFollowingDoc(
|
||||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox']
|
||||
},
|
||||
follower: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox']
|
||||
},
|
||||
silent = false,
|
||||
): Promise<void> {
|
||||
|
|
@ -233,8 +242,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||
});
|
||||
|
||||
// 通知を作成
|
||||
this.notificationService.createNotification(follower.id, 'followRequestAccepted', {
|
||||
}, followee.id);
|
||||
this.notificationService.createNotification(follower.id, 'followRequestAccepted', {}, followee.id);
|
||||
}
|
||||
|
||||
if (alreadyFollowed) return;
|
||||
|
|
@ -306,18 +314,25 @@ export class UserFollowingService implements OnModuleInit {
|
|||
});
|
||||
|
||||
// 通知を作成
|
||||
this.notificationService.createNotification(followee.id, 'follow', {
|
||||
}, follower.id);
|
||||
this.notificationService.createNotification(followee.id, 'follow', {}, follower.id);
|
||||
}
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async unfollow(
|
||||
follower: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
silent = false,
|
||||
): Promise<void> {
|
||||
|
|
@ -446,10 +461,18 @@ export class UserFollowingService implements OnModuleInit {
|
|||
@bindThis
|
||||
public async createFollowRequest(
|
||||
follower: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
requestId?: string,
|
||||
): Promise<void> {
|
||||
|
|
@ -541,7 +564,11 @@ export class UserFollowingService implements OnModuleInit {
|
|||
@bindThis
|
||||
public async acceptFollowRequest(
|
||||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
follower: MiUser,
|
||||
): Promise<void> {
|
||||
|
|
@ -569,7 +596,11 @@ export class UserFollowingService implements OnModuleInit {
|
|||
@bindThis
|
||||
public async acceptAllFollowRequests(
|
||||
user: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
): Promise<void> {
|
||||
const requests = await this.followRequestsRepository.findBy({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import type { DriveFilesRepository } from '@/models/index.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import type { DriveFilesRepository } from '@/models/_.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
|
|
|
|||
|
|
@ -41,17 +41,21 @@ export const paramDef = {
|
|||
nullable: true,
|
||||
description: 'Use `null` to reset the category.',
|
||||
},
|
||||
aliases: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
aliases: {
|
||||
type: 'array', items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
license: { type: 'string', nullable: true },
|
||||
isSensitive: { type: 'boolean' },
|
||||
localOnly: { type: 'boolean' },
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: {
|
||||
type: 'array', items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['name','fileId', 'draft'],
|
||||
required: ['name', 'fileId', 'draft'],
|
||||
} as const;
|
||||
|
||||
// TODO: ロジックをサービスに切り出す
|
||||
|
|
@ -61,9 +65,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
constructor(
|
||||
@Inject(DI.driveFilesRepository)
|
||||
private driveFilesRepository: DriveFilesRepository,
|
||||
|
||||
private customEmojiService: CustomEmojiService,
|
||||
|
||||
private emojiEntityService: EmojiEntityService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
|
|
@ -82,7 +84,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
license: ps.license ?? null,
|
||||
isSensitive: ps.isSensitive ?? false,
|
||||
localOnly: ps.localOnly ?? false,
|
||||
draft: false,
|
||||
draft: false,
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [],
|
||||
}, me);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export const paramDef = {
|
|||
} },
|
||||
draft: { type: 'boolean' },
|
||||
},
|
||||
required: ['id', 'name', 'aliases'],
|
||||
required: ['id', 'name', 'draft', 'aliases'],
|
||||
} as const;
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -94,7 +94,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
isSensitive: ps.isSensitive,
|
||||
localOnly: ps.localOnly,
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction,
|
||||
draft: ps.draft,
|
||||
draft: ps.draft,
|
||||
}, me);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue