Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed Sep 21, 2023
1 parent 869e89a commit 117e1b9
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const meta = {

res: {
type: 'object',
optional: false, nullable: false,
optional: false,
nullable: false,
ref: 'MessagingMessage',
},

Expand All @@ -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',
},
Expand Down Expand Up @@ -111,8 +112,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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
Expand All @@ -134,11 +135,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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);
}

Expand All @@ -148,7 +149,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
userGroupId: recipientGroup.id,
});

if (joining == null) {
if (!joining) {
throw new ApiError(meta.errors.groupAccessDenied);
}
}
Expand Down

0 comments on commit 117e1b9

Please sign in to comment.