diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/create.ts b/packages/backend/src/server/api/endpoints/messaging/messages/create.ts index f0916b7607..edc13c6810 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages/create.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages/create.ts @@ -29,7 +29,8 @@ export const meta = { res: { type: 'object', - optional: false, nullable: false, + optional: false, + nullable: false, ref: 'MessagingMessage', }, @@ -53,7 +54,7 @@ export const meta = { }, groupAccessDenied: { - message: 'You can not send messages to groups that you have not joined.', + message: 'You cannot send messages to groups that you have not joined.', code: 'GROUP_ACCESS_DENIED', id: 'd96b3cca-5ad1-438b-ad8b-02f931308fbd', }, @@ -111,8 +112,8 @@ export default class extends Endpoint { // eslint- private messagingService: MessagingService, ) { super(meta, paramDef, async (ps, me) => { - let recipientUser: MiUser | undefined = undefined; - let recipientGroup: MiUserGroup | undefined = undefined; + let recipientUser: MiUser; + let recipientGroup: MiUserGroup; if (ps.userId != null) { // Myself @@ -134,11 +135,11 @@ export default class extends Endpoint { // eslint- if (block) { throw new ApiError(meta.errors.youHaveBeenBlocked); } - } else if (ps.groupId != null) { + } else if (ps.groupId !== undefined) { // Fetch recipient (group) - recipientGroup = await this.userGroupsRepository.findOneBy({ id: ps.groupId! }); + recipientGroup = await this.userGroupsRepository.findOneBy({ id: ps.groupId }); - if (recipientGroup == null) { + if (!recipientGroup) { throw new ApiError(meta.errors.noSuchGroup); } @@ -148,7 +149,7 @@ export default class extends Endpoint { // eslint- userGroupId: recipientGroup.id, }); - if (joining == null) { + if (!joining) { throw new ApiError(meta.errors.groupAccessDenied); } }