Skip to content

Commit

Permalink
Merge pull request #385
Browse files Browse the repository at this point in the history
fix(backend): lint
  • Loading branch information
noridev authored Oct 19, 2023
2 parents 75c8632 + 26bd0b0 commit 51b82f7
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 55 deletions.
30 changes: 30 additions & 0 deletions packages/backend/migration/1697737204579-deleteCreatedAt.js
Original file line number Diff line number Diff line change
@@ -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") `);
}

}
7 changes: 7 additions & 0 deletions packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/AnnouncementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
8 changes: 2 additions & 6 deletions packages/backend/src/core/MessagingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ 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 {
constructor(
@Inject(DI.messagingMessagesRepository)
private messagingMessagesRepository: MessagingMessagesRepository,

private idService: IdService,
private userEntityService: UserEntityService,
private userGroupEntityService: UserGroupEntityService,
private driveFileEntityService: DriveFileEntityService,
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/core/entities/UserGroupEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -18,6 +19,8 @@ export class UserGroupEntityService {

@Inject(DI.userGroupJoiningsRepository)
private userGroupJoiningsRepository: UserGroupJoiningsRepository,

private idService: IdService,
) {
}

Expand All @@ -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),
Expand Down
6 changes: 0 additions & 6 deletions packages/backend/src/models/AbuseReportResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 0 additions & 6 deletions packages/backend/src/models/MessagingMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 0 additions & 6 deletions packages/backend/src/models/UserGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
5 changes: 0 additions & 5 deletions packages/backend/src/models/UserGroupInvitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
5 changes: 0 additions & 5 deletions packages/backend/src/models/UserGroupJoining.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions packages/backend/src/server/api/endpoints/admin/emoji/adds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}

0 comments on commit 51b82f7

Please sign in to comment.