fix: allow POST /users/@me/channels with recipient_id 0 (#1160)

This commit is contained in:
dogbonewish authored and GitHub committed 2026-06-24 23:11:29 +01:00
1 parent a45693f581
commit 41ec2544cf
4 files changed
+50 -4

No files matched your search

@@ -79,4 +79,11 @@ describe('CreatePrivateChannelRequest', () => {
);
expect(CreatePrivateChannelRequest.safeParse({recipients}).success).toBe(false);
});
it('allows DM requests to the system user id 0', () => {
const parsed = CreatePrivateChannelRequest.safeParse({recipient_id: '0'});
expect(parsed.success).toBe(true);
if (parsed.success) {
expect(parsed.data.recipient_id).toBe(0n);
}
});
});
@@ -272,9 +272,13 @@ export const CreatePrivateChannelRequest = z
.optional()
.describe(`Array of user IDs for creating a group DM (max ${MAX_GROUP_DM_OTHER_RECIPIENTS})`),
})
.refine((data) => (data.recipient_id && !data.recipients) || (!data.recipient_id && data.recipients), {
message: 'Either recipient_id or recipients must be provided, but not both',
});
.refine(
(data) =>
(data.recipient_id != null && data.recipients == null) || (data.recipient_id == null && data.recipients != null),
{
message: 'Either recipient_id or recipients must be provided, but not both',
},
);
export type CreatePrivateChannelRequest = z.infer<typeof CreatePrivateChannelRequest>;