fix(webhook): accept github int64 ids (#72)
This commit is contained in:
parent
b2514d19ff
commit
d4c392cbf8
@ -215,29 +215,35 @@ export const GlobalNameType = z
|
|||||||
return !lowerValue.includes('system message');
|
return !lowerValue.includes('system message');
|
||||||
}, 'Global name cannot contain "system message"');
|
}, 'Global name cannot contain "system message"');
|
||||||
|
|
||||||
export const URLType = z
|
const createUrlSchema = (allowFragments: boolean) => {
|
||||||
.string()
|
return z
|
||||||
.transform(normalizeString)
|
.string()
|
||||||
.refine((value) => value.length >= 1 && value.length <= 2048, 'URL length must be between 1 and 2048 characters')
|
.transform(normalizeString)
|
||||||
.refine((value) => {
|
.refine((value) => value.length >= 1 && value.length <= 2048, 'URL length must be between 1 and 2048 characters')
|
||||||
if (!value.startsWith('http://') && !value.startsWith('https://')) {
|
.refine((value) => {
|
||||||
return false;
|
if (!value.startsWith('http://') && !value.startsWith('https://')) {
|
||||||
}
|
return false;
|
||||||
try {
|
}
|
||||||
const url = new URL(value);
|
try {
|
||||||
return PROTOCOLS.includes(url.protocol.slice(0, -1));
|
const url = new URL(value);
|
||||||
} catch {
|
return PROTOCOLS.includes(url.protocol.slice(0, -1));
|
||||||
return false;
|
} catch {
|
||||||
}
|
return false;
|
||||||
}, 'Invalid URL format')
|
}
|
||||||
.refine(
|
}, 'Invalid URL format')
|
||||||
(value) =>
|
.refine(
|
||||||
validator.isURL(value, {
|
(value) =>
|
||||||
...URL_VALIDATOR_OPTIONS,
|
validator.isURL(value, {
|
||||||
require_tld: Config.nodeEnv !== 'development',
|
...URL_VALIDATOR_OPTIONS,
|
||||||
}),
|
allow_fragments: allowFragments,
|
||||||
'Invalid URL format',
|
require_tld: Config.nodeEnv !== 'development',
|
||||||
);
|
}),
|
||||||
|
'Invalid URL format',
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const URLType = createUrlSchema(false);
|
||||||
|
export const URLWithFragmentType = createUrlSchema(true);
|
||||||
|
|
||||||
export const AttachmentURLType = z
|
export const AttachmentURLType = z
|
||||||
.string()
|
.string()
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {createStringType, Int32Type, URLType, z} from '~/Schema';
|
import {createStringType, Int32Type, Int64Type, URLType, URLWithFragmentType, z} from '~/Schema';
|
||||||
|
|
||||||
const GitHubUser = z.object({
|
const GitHubUser = z.object({
|
||||||
id: Int32Type,
|
id: Int32Type,
|
||||||
@ -63,8 +63,8 @@ const GitHubCheckRun = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const GitHubComment = z.object({
|
const GitHubComment = z.object({
|
||||||
id: Int32Type,
|
id: Int64Type,
|
||||||
html_url: URLType,
|
html_url: URLWithFragmentType,
|
||||||
user: GitHubUser,
|
user: GitHubUser,
|
||||||
commit_id: createStringType(0, 152133).nullish(),
|
commit_id: createStringType(0, 152133).nullish(),
|
||||||
body: createStringType(0, 152133),
|
body: createStringType(0, 152133),
|
||||||
@ -81,13 +81,13 @@ const GitHubDiscussion = z.object({
|
|||||||
title: createStringType(0, 152133),
|
title: createStringType(0, 152133),
|
||||||
number: Int32Type,
|
number: Int32Type,
|
||||||
html_url: URLType,
|
html_url: URLType,
|
||||||
answer_html_url: URLType.nullish(),
|
answer_html_url: URLWithFragmentType.nullish(),
|
||||||
body: createStringType(0, 152133).nullish(),
|
body: createStringType(0, 152133).nullish(),
|
||||||
user: GitHubUser,
|
user: GitHubUser,
|
||||||
});
|
});
|
||||||
|
|
||||||
const GitHubIssue = z.object({
|
const GitHubIssue = z.object({
|
||||||
id: Int32Type,
|
id: Int64Type,
|
||||||
number: Int32Type,
|
number: Int32Type,
|
||||||
html_url: URLType,
|
html_url: URLType,
|
||||||
user: GitHubUser,
|
user: GitHubUser,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user