mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
refactor: remove dead code (#3337)
This commit is contained in:
1 parent
a19002652b
commit
93d1f8af46
1527 files changed
+21170
-73846
No files matched your search
@@ -5,10 +5,8 @@ import {
|
||||
formatAssetUploadExtensions,
|
||||
formatKnownAnimatedAssetExtensions,
|
||||
getAcceptString,
|
||||
getMimeWhitelist,
|
||||
getUploadExtensions,
|
||||
isExtensionAllowed,
|
||||
isMimeAllowed,
|
||||
} from '@fluxer/constants/src/AssetFormatPolicy';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
@@ -133,19 +131,6 @@ describe('AssetFormatPolicy', () => {
|
||||
expect(formatKnownAnimatedAssetExtensions('avatar')).toBe('GIF, APNG, WebP');
|
||||
});
|
||||
});
|
||||
describe('getMimeWhitelist', () => {
|
||||
it('returns the per-kind MIME list', () => {
|
||||
expect(getMimeWhitelist('sticker')).toEqual([
|
||||
'image/png',
|
||||
'image/jpeg',
|
||||
'image/apng',
|
||||
'image/gif',
|
||||
'image/webp',
|
||||
'image/avif',
|
||||
'image/svg+xml',
|
||||
]);
|
||||
});
|
||||
});
|
||||
describe('isExtensionAllowed', () => {
|
||||
it('accepts both raw and dot-prefixed extensions', () => {
|
||||
expect(isExtensionAllowed('avatar', 'png')).toBe(true);
|
||||
@@ -158,14 +143,4 @@ describe('AssetFormatPolicy', () => {
|
||||
expect(isExtensionAllowed('emoji', 'mp4' as never)).toBe(false);
|
||||
});
|
||||
});
|
||||
describe('isMimeAllowed', () => {
|
||||
it('matches MIMEs case-insensitively', () => {
|
||||
expect(isMimeAllowed('avatar', 'IMAGE/PNG')).toBe(true);
|
||||
expect(isMimeAllowed('avatar', 'image/heic')).toBe(true);
|
||||
});
|
||||
it('rejects MIMEs outside the policy', () => {
|
||||
expect(isMimeAllowed('emoji', 'application/pdf')).toBe(false);
|
||||
expect(isMimeAllowed('splash', 'image/gif')).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -185,11 +185,6 @@ export function getAcceptString(kind: AssetKind, options: AssetUploadExtensionOp
|
||||
return [...exts, ...mimes].join(',');
|
||||
}
|
||||
|
||||
export function getMimeWhitelist(kind: AssetKind): ReadonlyArray<string> {
|
||||
const policy = ASSET_FORMAT_POLICY[kind];
|
||||
return policy.upload.map((ext) => policy.mimes[ext]);
|
||||
}
|
||||
|
||||
export function getExtensionWhitelist(kind: AssetKind): ReadonlyArray<AssetExtension> {
|
||||
return ASSET_FORMAT_POLICY[kind].upload;
|
||||
}
|
||||
@@ -225,12 +220,3 @@ export function isExtensionAllowed(kind: AssetKind, ext: string): boolean {
|
||||
const normalized = (withoutDot === 'jpg' ? 'jpeg' : withoutDot) as AssetExtension;
|
||||
return ASSET_FORMAT_POLICY[kind].upload.includes(normalized);
|
||||
}
|
||||
|
||||
export function isMimeAllowed(kind: AssetKind, mime: string): boolean {
|
||||
const normalized = mime.toLowerCase();
|
||||
const policy = ASSET_FORMAT_POLICY[kind];
|
||||
for (const ext of policy.upload) {
|
||||
if (policy.mimes[ext] === normalized) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
ANNOUNCEMENT_CONVERTIBLE_CHANNEL_TYPES,
|
||||
CHANNEL_FOLLOW_TARGET_TYPES,
|
||||
ChannelTypes,
|
||||
CROSSPOST_SERVER_FLAGS,
|
||||
GUILD_TEXT_BASED_CHANNEL_TYPES,
|
||||
isMessageTypeDeletable,
|
||||
MessageFlags,
|
||||
@@ -37,10 +36,8 @@ describe('announcement channel constants', () => {
|
||||
});
|
||||
|
||||
it('keeps the crosspost flags out of the sendable flags', () => {
|
||||
expect(CROSSPOST_SERVER_FLAGS).toBe(
|
||||
MessageFlags.CROSSPOSTED | MessageFlags.IS_CROSSPOST | MessageFlags.SOURCE_MESSAGE_DELETED,
|
||||
);
|
||||
expect(CROSSPOST_SERVER_FLAGS & SENDABLE_MESSAGE_FLAGS).toBe(0);
|
||||
const crosspostFlags = MessageFlags.CROSSPOSTED | MessageFlags.IS_CROSSPOST | MessageFlags.SOURCE_MESSAGE_DELETED;
|
||||
expect(crosspostFlags & SENDABLE_MESSAGE_FLAGS).toBe(0);
|
||||
});
|
||||
|
||||
it('names both webhook types', () => {
|
||||
|
||||
@@ -131,8 +131,6 @@ export const MessageFlagsDescriptions: Record<keyof typeof MessageFlags, string>
|
||||
};
|
||||
export const SENDABLE_MESSAGE_FLAGS =
|
||||
MessageFlags.SUPPRESS_EMBEDS | MessageFlags.SUPPRESS_NOTIFICATIONS | MessageFlags.VOICE_MESSAGE;
|
||||
export const CROSSPOST_SERVER_FLAGS =
|
||||
MessageFlags.CROSSPOSTED | MessageFlags.IS_CROSSPOST | MessageFlags.SOURCE_MESSAGE_DELETED;
|
||||
export const MessageAttachmentFlags = {
|
||||
IS_SPOILER: 1 << 3,
|
||||
CONTAINS_EXPLICIT_MEDIA: 1 << 4,
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
export const CSRF_COOKIE_NAME = 'csrf_token';
|
||||
export const CSRF_HEADER_NAME = 'x-csrf-token';
|
||||
export const CSRF_FORM_FIELD = '_csrf';
|
||||
@@ -38,7 +38,6 @@ export const HttpStatus = {
|
||||
export const MimeType = {
|
||||
JSON: 'application/json',
|
||||
XML: 'application/xml',
|
||||
FORM_URLENCODED: 'application/x-www-form-urlencoded',
|
||||
OCTET_STREAM: 'application/octet-stream',
|
||||
PDF: 'application/pdf',
|
||||
PLAIN: 'text/plain',
|
||||
@@ -51,14 +50,9 @@ export const MimeType = {
|
||||
GIF: 'image/gif',
|
||||
WEBP: 'image/webp',
|
||||
SVG: 'image/svg+xml',
|
||||
ICO: 'image/x-icon',
|
||||
MP3: 'audio/mpeg',
|
||||
WAV: 'audio/wav',
|
||||
OGG_AUDIO: 'audio/ogg',
|
||||
MP4: 'video/mp4',
|
||||
WEBM: 'video/webm',
|
||||
OGG_VIDEO: 'video/ogg',
|
||||
MULTIPART_FORM_DATA: 'multipart/form-data',
|
||||
} as const;
|
||||
|
||||
export const REDIRECT_STATUS_CODES = [
|
||||
|
||||
@@ -36,7 +36,7 @@ const MEDIA_PROXY_IMAGE_SIZE_QUERY_VALUES = [
|
||||
'16384',
|
||||
] as const;
|
||||
|
||||
export type MediaProxyImageSizeQueryValue = (typeof MEDIA_PROXY_IMAGE_SIZE_QUERY_VALUES)[number];
|
||||
type MediaProxyImageSizeQueryValue = (typeof MEDIA_PROXY_IMAGE_SIZE_QUERY_VALUES)[number];
|
||||
type ParseNumericLiteral<T extends string> = T extends `${infer N extends number}` ? N : never;
|
||||
export type MediaProxyImageSize = ParseNumericLiteral<MediaProxyImageSizeQueryValue>;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ export const QuickSwitcherResultTypes = {
|
||||
GUILD: 'guild',
|
||||
VIRTUAL_GUILD: 'virtual_guild',
|
||||
SETTINGS: 'settings',
|
||||
QUICK_ACTION: 'quick_action',
|
||||
LINK: 'link',
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
formatRecoveryKey,
|
||||
formatRecoveryKeyInput,
|
||||
generateRecoveryKey,
|
||||
isValidRecoveryKey,
|
||||
normalizeRecoveryKey,
|
||||
RECOVERY_KEY_FORMATTED_LENGTH,
|
||||
RECOVERY_KEY_LENGTH,
|
||||
@@ -62,8 +61,6 @@ describe('normalizeRecoveryKey', () => {
|
||||
expect(normalizeRecoveryKey(`!${key.slice(1)}`)).toBeNull();
|
||||
expect(normalizeRecoveryKey(key.slice(1))).toBeNull();
|
||||
expect(normalizeRecoveryKey(`${key}0`)).toBeNull();
|
||||
expect(isValidRecoveryKey('')).toBe(false);
|
||||
expect(isValidRecoveryKey(key)).toBe(true);
|
||||
});
|
||||
|
||||
it('rejects characters whose uppercase form is two letters', () => {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
export const RECOVERY_KEY_ALPHABET = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
||||
const RECOVERY_KEY_ALPHABET = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
||||
export const RECOVERY_KEY_BYTE_LENGTH = 20;
|
||||
export const RECOVERY_KEY_LENGTH = 32;
|
||||
export const RECOVERY_KEY_GROUP_SIZE = 4;
|
||||
const RECOVERY_KEY_GROUP_SIZE = 4;
|
||||
export const RECOVERY_KEY_SEPARATOR = '-';
|
||||
export const RECOVERY_KEY_FORMATTED_LENGTH = RECOVERY_KEY_LENGTH + RECOVERY_KEY_LENGTH / RECOVERY_KEY_GROUP_SIZE - 1;
|
||||
|
||||
@@ -69,10 +69,6 @@ export function normalizeRecoveryKey(input: string): string | null {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function isValidRecoveryKey(input: string): boolean {
|
||||
return normalizeRecoveryKey(input) !== null;
|
||||
}
|
||||
|
||||
export function formatRecoveryKeyInput(input: string): string {
|
||||
let normalized = '';
|
||||
for (const character of input.replace(IGNORED_INPUT_CHARACTERS, '')) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
export const DEFAULT_MINIMUM_AGE = 13;
|
||||
const DEFAULT_MINIMUM_AGE = 13;
|
||||
|
||||
const REGIONAL_MINIMUM_AGE: Readonly<Record<string, number>> = {
|
||||
AT: 14,
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
export const SOUNDBOARD_SOUND_PATH_PREFIX = 'soundboard-sounds';
|
||||
Reference in new issue
Block a user