From 28f7e48dc61164e574bf7e77012edd8319d33f14 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Jun 2021 23:33:50 +0900 Subject: [PATCH] improve type --- src/server/api/stream/channels/messaging.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/api/stream/channels/messaging.ts b/src/server/api/stream/channels/messaging.ts index 4c41dc820b..58427e2771 100644 --- a/src/server/api/stream/channels/messaging.ts +++ b/src/server/api/stream/channels/messaging.ts @@ -10,7 +10,7 @@ export default class extends Channel { public static requireCredential = true; private otherpartyId: string | null; - private otherparty?: User; + private otherparty: User | null; private groupId: string | null; private subCh: string; private typers: Record = {}; @@ -18,9 +18,9 @@ export default class extends Channel { @autobind public async init(params: any) { - this.otherpartyId = params.otherparty as string; - this.otherparty = await Users.findOne({ id: this.otherpartyId }); - this.groupId = params.group as string; + this.otherpartyId = params.otherparty; + this.otherparty = this.otherpartyId ? await Users.findOneOrFail({ id: this.otherpartyId }) : null; + this.groupId = params.group; // Check joining if (this.groupId) {