Merge pull request #385

fix(backend): lint
This commit is contained in:
NoriDev 2023-10-20 04:33:48 +09:00 committed by GitHub
commit 51b82f7a34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 55 additions and 55 deletions

View file

@ -0,0 +1,30 @@
export class DeleteCreatedAt1697737204579 {
name = 'DeleteCreatedAt1697737204579'
async up(queryRunner) {
await queryRunner.query(`DROP INDEX "public"."IDX_e21cd3646e52ef9c94aaf17c2e"`);
await queryRunner.query(`DROP INDEX "public"."IDX_20e30aa35180e317e133d75316"`);
await queryRunner.query(`DROP INDEX "public"."IDX_20e30aa35180e317e133d75316"`);
await queryRunner.query(`DROP INDEX "public"."IDX_fdd74ab625ed0f6a30c47b00e0"`);
await queryRunner.query(`ALTER TABLE "messaging_message" DROP COLUMN "createdAt"`);
await queryRunner.query(`ALTER TABLE "user_group" DROP COLUMN "createdAt"`);
await queryRunner.query(`ALTER TABLE "user_group_invitation" DROP COLUMN "createdAt"`);
await queryRunner.query(`ALTER TABLE "user_group_invite" DROP COLUMN "createdAt"`);
await queryRunner.query(`ALTER TABLE "user_group_joining" DROP COLUMN "createdAt"`);
await queryRunner.query(`ALTER TABLE "abuse_report_resolver" DROP COLUMN "createdAt"`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "abuse_report_resolver" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_group_joining" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_group_invite" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_group_invitation" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_group" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`);
await queryRunner.query(`ALTER TABLE "messaging_message" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`);
await queryRunner.query(`CREATE INDEX "IDX_fdd74ab625ed0f6a30c47b00e0" ON "abuse_report_resolver" ("createdAt") `);
await queryRunner.query(`CREATE INDEX "IDX_20e30aa35180e317e133d75316" ON "user_group" ("createdAt") `);
await queryRunner.query(`CREATE INDEX "IDX_e21cd3646e52ef9c94aaf17c2e" ON "messaging_message" ("createdAt") `);
}
}

View file

@ -149,6 +149,13 @@ export type Config = {
relashionshipJobPerSec: number | undefined;
deliverJobMaxAttempts: number | undefined;
inboxJobMaxAttempts: number | undefined;
cloudLogging?: {
projectId: string;
saKeyPath: string;
logName?: string;
}
apFileBaseUrl: string | undefined;
proxyRemoteFiles: boolean | undefined;
signToActivityPubGet: boolean | undefined;

View file

@ -80,8 +80,8 @@ export class AnnouncementService {
const packed = (await this.packMany([announcement]))[0];
if (announcement.isActive) {
if (announcement.userId) {
this.globalEventService.publishMainStream(announcement.userId, 'announcementCreated', {
if (values.userId) {
this.globalEventService.publishMainStream(values.userId, 'announcementCreated', {
announcement: packed,
});

View file

@ -56,11 +56,8 @@ export class MessagingService {
@bindThis
public async createMessage(user: { id: MiUser['id']; host: MiUser['host']; }, recipientUser: MiUser | null, recipientGroup: MiUserGroup | null, text: string | null | undefined, file: MiDriveFile | null, uri?: string) {
const data = new Date();
const message = {
id: this.idService.genId(data),
createdAt: data,
id: this.idService.gen(Date.now()),
fileId: file ? file.id : null,
recipientId: recipientUser ? recipientUser.id : null,
groupId: recipientGroup ? recipientGroup.id : null,
@ -135,7 +132,6 @@ export class MessagingService {
const note = {
id: message.id,
createdAt: message.createdAt,
fileIds: message.fileId ? [message.fileId] : [],
text: message.text,
userId: message.userId,
@ -298,7 +294,7 @@ export class MessagingService {
.where('message.groupId = :groupId', { groupId: groupId })
.andWhere('message.userId != :userId', { userId: userId })
.andWhere('NOT (:userId = ANY(message.reads))', { userId: userId })
.andWhere('message.createdAt > :joinedAt', { joinedAt: joining.createdAt }) // 自分が加入する前の会話については、未読扱いしない
.andWhere('message.createdAt > :joinedAt', { joinedAt: this.idService.parse(joining.id) }) // 自分が加入する前の会話については、未読扱いしない
.getOne().then(x => x != null);
if (!unreadExist) {

View file

@ -13,6 +13,7 @@ import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
import { DriveFileEntityService } from './DriveFileEntityService.js';
import { UserGroupEntityService } from './UserGroupEntityService.js';
import { IdService } from '@/core/IdService.js';
@Injectable()
export class MessagingMessageEntityService {
@ -20,6 +21,7 @@ export class MessagingMessageEntityService {
@Inject(DI.messagingMessagesRepository)
private messagingMessagesRepository: MessagingMessagesRepository,
private idService: IdService,
private userEntityService: UserEntityService,
private userGroupEntityService: UserGroupEntityService,
private driveFileEntityService: DriveFileEntityService,
@ -44,7 +46,7 @@ export class MessagingMessageEntityService {
return {
id: message.id,
createdAt: message.createdAt.toISOString(),
createdAt: this.idService.parse(message.id).date.toISOString(),
text: message.text,
userId: message.userId,
user: await this.userEntityService.pack(message.user ?? message.userId, me),

View file

@ -233,7 +233,7 @@ export class UserEntityService implements OnModuleInit {
.where('message.groupId = :groupId', { groupId: j.userGroupId })
.andWhere('message.userId != :userId', { userId: userId })
.andWhere('NOT (:userId = ANY(message.reads))', { userId: userId })
.andWhere('message.createdAt > :joinedAt', { joinedAt: j.createdAt }) // 自分が加入する前の会話については、未読扱いしない
.andWhere('message.createdAt > :joinedAt', { joinedAt: this.idService.parse(j.id) }) // 自分が加入する前の会話については、未読扱いしない
.getOne().then(x => x != null)));
const [withUser, withGroups] = await Promise.all([

View file

@ -9,6 +9,7 @@ import type { UserGroupJoiningsRepository, UserGroupsRepository } from '@/models
import type { Packed } from '@/misc/json-schema.js';
import type { MiUserGroup } from '@/models/UserGroup.js';
import { bindThis } from '@/decorators.js';
import { IdService } from '@/core/IdService.js';
@Injectable()
export class UserGroupEntityService {
@ -18,6 +19,8 @@ export class UserGroupEntityService {
@Inject(DI.userGroupJoiningsRepository)
private userGroupJoiningsRepository: UserGroupJoiningsRepository,
private idService: IdService,
) {
}
@ -33,7 +36,7 @@ export class UserGroupEntityService {
return {
id: userGroup.id,
createdAt: userGroup.createdAt.toISOString(),
createdAt: this.idService.parse(userGroup.id).date.toISOString(),
name: userGroup.name,
ownerId: userGroup.userId,
userIds: users.map((x: { userId: any; }) => x.userId),

View file

@ -11,12 +11,6 @@ export class MiAbuseReportResolver {
@PrimaryColumn(id())
public id: string;
@Index()
@Column('timestamp with time zone', {
comment: 'The created date of AbuseReportResolver',
})
public createdAt: Date;
@Index()
@Column('timestamp with time zone', {
comment: 'The updated date of AbuseReportResolver',

View file

@ -14,12 +14,6 @@ export class MiMessagingMessage {
@PrimaryColumn(id())
public id: string;
@Index()
@Column('timestamp with time zone', {
comment: 'The created date of the MessagingMessage.',
})
public createdAt: Date;
@Index()
@Column({
...id(),

View file

@ -12,12 +12,6 @@ export class MiUserGroup {
@PrimaryColumn(id())
public id: string;
@Index()
@Column('timestamp with time zone', {
comment: 'The created date of the UserGroup.',
})
public createdAt: Date;
@Column('varchar', {
length: 256,
})

View file

@ -14,11 +14,6 @@ export class MiUserGroupInvitation {
@PrimaryColumn(id())
public id: string;
@Column('timestamp with time zone', {
comment: 'The created date of the UserGroupInvitation.',
})
public createdAt: Date;
@Index()
@Column({
...id(),

View file

@ -14,11 +14,6 @@ export class MiUserGroupJoining {
@PrimaryColumn(id())
public id: string;
@Column('timestamp with time zone', {
comment: 'The created date of the UserGroupJoining.',
})
public createdAt: Date;
@Index()
@Column({
...id(),

View file

@ -124,8 +124,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + 1); } : function () { expirationDate = null; })();
return await this.abuseReportResolverRepository.insert({
id: this.idService.genId(),
createdAt: now,
id: this.idService.gen(),
updatedAt: now,
name: ps.name,
targetUserPattern: ps.targetUserPattern,

View file

@ -82,10 +82,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [],
});
this.moderationLogService.insertModerationLog(me, 'addEmoji', {
emojiId: emoji.id,
});
return this.emojiEntityService.packDetailed(emoji);
});
}

View file

@ -56,16 +56,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
) {
super(meta, paramDef, async (ps, me) => {
const userGroup = await this.userGroupsRepository.insert({
id: this.idService.genId(),
createdAt: new Date(),
id: this.idService.gen(),
userId: me.id,
name: ps.name,
} as MiUserGroup).then(x => this.userGroupsRepository.findOneByOrFail(x.identifiers[0]));
// Push the owner
await this.userGroupJoiningsRepository.insert({
id: this.idService.genId(),
createdAt: new Date(),
id: this.idService.gen(),
userId: me.id,
userGroupId: userGroup.id,
} as MiUserGroupJoining);

View file

@ -62,8 +62,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
// Push the user
await this.userGroupJoiningsRepository.insert({
id: this.idService.genId(),
createdAt: new Date(),
id: this.idService.gen(),
userId: me.id,
userGroupId: invitation.userGroupId,
} as MiUserGroupJoining);

View file

@ -110,17 +110,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
const invitation = await this.userGroupInvitationsRepository.insert({
id: this.idService.genId(),
createdAt: new Date(),
id: this.idService.gen(),
userId: user.id,
userGroupId: userGroup.id,
} as MiUserGroupInvitation).then(x => this.userGroupInvitationsRepository.findOneByOrFail(x.identifiers[0]));
// 通知を作成
this.notificationService.createNotification(user.id, 'groupInvited', {
notifierId: me.id,
userGroupInvitationId: invitation.id,
});
}, me.id);
});
}
}