fix(webhook): accept github int64 ids (#72)

This commit is contained in:
Hampus 2026-01-08 15:03:47 +01:00 committed by GitHub
parent b2514d19ff
commit d4c392cbf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 28 deletions

View File

@ -215,7 +215,8 @@ 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) => {
return z
.string() .string()
.transform(normalizeString) .transform(normalizeString)
.refine((value) => value.length >= 1 && value.length <= 2048, 'URL length must be between 1 and 2048 characters') .refine((value) => value.length >= 1 && value.length <= 2048, 'URL length must be between 1 and 2048 characters')
@ -234,10 +235,15 @@ export const URLType = z
(value) => (value) =>
validator.isURL(value, { validator.isURL(value, {
...URL_VALIDATOR_OPTIONS, ...URL_VALIDATOR_OPTIONS,
allow_fragments: allowFragments,
require_tld: Config.nodeEnv !== 'development', require_tld: Config.nodeEnv !== 'development',
}), }),
'Invalid URL format', 'Invalid URL format',
); );
};
export const URLType = createUrlSchema(false);
export const URLWithFragmentType = createUrlSchema(true);
export const AttachmentURLType = z export const AttachmentURLType = z
.string() .string()

View File

@ -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,