mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
fix(api): validate push and domain verification targets (#2346)
This commit is contained in:
1 parent
693aec2b4d
commit
1d84689b45
5 files changed
+75
-3
No files matched your search
@@ -11,6 +11,7 @@ import {
|
||||
Int32Type,
|
||||
withOpenApiType,
|
||||
} from '@fluxer/schema/src/primitives/SchemaPrimitives';
|
||||
import {HostnameType} from '@fluxer/schema/src/primitives/UrlValidators';
|
||||
import {z} from 'zod';
|
||||
|
||||
const ConnectionTypeSchema = withOpenApiType(
|
||||
@@ -62,7 +63,7 @@ export type VerifyAndCreateConnectionRequest = z.infer<typeof VerifyAndCreateCon
|
||||
|
||||
export const CreateConnectionRequest = z.object({
|
||||
type: ConnectionTypeSchema.describe('The type of connection to create'),
|
||||
identifier: z.string().min(1).max(253).describe('The connection identifier (handle or domain)'),
|
||||
identifier: HostnameType.describe('The connection identifier (handle or domain)'),
|
||||
visibility_flags: Int32Type.optional().describe('Bitfield controlling who can see this connection'),
|
||||
});
|
||||
|
||||
|
||||
@@ -514,6 +514,13 @@ export const RegisterMobileDeviceRequest = z
|
||||
})
|
||||
.superRefine((value, ctx) => {
|
||||
if (value.platform !== 'android_unified_push') return;
|
||||
if (!URLType.safeParse(value.token).success) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ['token'],
|
||||
message: 'UnifiedPush registrations require a valid endpoint URL',
|
||||
});
|
||||
}
|
||||
if (!value.encryption_key) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
|
||||
Reference in new issue
Block a user