refactor constants

Also added more standard media formats
This commit is contained in:
cutestnekoaqua 2023-01-14 18:21:35 +01:00
parent 98f1c17991
commit c0da8910a4
No known key found for this signature in database
GPG key ID: 6BF0964A5069C1E0

View file

@ -1,31 +1,32 @@
import config from "@/config/index.js"; import config from "@/config/index.js";
export const MAX_NOTE_TEXT_LENGTH = export const MAX_NOTE_TEXT_LENGTH =
config.maxNoteLength != null ? config.maxNoteLength : 3000; config.maxNoteLength != null ? config.maxNoteLength : 3000; // <- should we increase this?
export const SECOND = 1000; export const SECOND = 1000;
export const SEC = 1000; export const SEC = 1000; // why do we need this duplicate here?
export const MINUTE = 60 * SEC; export const MINUTE = 60 * SEC;
export const MIN = 60 * SEC; export const MIN = 60 * SEC; // why do we need this duplicate here?
export const HOUR = 60 * MIN; export const HOUR = 60 * MIN;
export const DAY = 24 * HOUR; export const DAY = 24 * HOUR;
export const USER_ONLINE_THRESHOLD = 1000 * 60 * 10; // 10min export const USER_ONLINE_THRESHOLD = 10 * MINUTE;
export const USER_ACTIVE_THRESHOLD = 1000 * 60 * 60 * 24 * 3; // 3days export const USER_ACTIVE_THRESHOLD = 3 * DAY;
// ブラウザで直接表示することを許可するファイルの種類のリスト // List of file types allowed to be viewed directly in the browser
// ここに含まれないものは application/octet-stream としてレスポンスされる // Anything not included here will be responded as application/octet-stream
// SVGはXSSを生むので許可しない // SVG is not allowed because it generates XSS <- we need to fix this and later allow it to be viewed directly
export const FILE_TYPE_BROWSERSAFE = [ export const FILE_TYPE_BROWSERSAFE = [
// Images // Images
"image/png", "image/png",
"image/gif", "image/gif", // TODO: deprecated, but still used by old notes, new gifs should be converted to webp in the future
"image/jpeg", "image/jpeg",
"image/webp", "image/webp", // TODO: make this the default image format
"image/apng", "image/apng",
"image/bmp", "image/bmp",
"image/tiff", "image/tiff",
"image/x-icon", "image/x-icon",
"image/avif", // not as good supported now, but its good to introduce initial support for the future
// OggS // OggS
"audio/opus", "audio/opus",
@ -35,12 +36,17 @@ export const FILE_TYPE_BROWSERSAFE = [
// ISO/IEC base media file format // ISO/IEC base media file format
"video/quicktime", "video/quicktime",
"video/mp4", "video/mp4", // TODO: we need to check for av1 later
"video/vnd.avi", // also av1
"audio/mp4", "audio/mp4",
"video/x-m4v", "video/x-m4v",
"audio/x-m4a", "audio/x-m4a",
"video/3gpp", "video/3gpp",
"video/3gpp2", "video/3gpp2",
"video/3gp2",
"audio/3gpp",
"audio/3gpp2",
"audio/3gp2",
"video/mpeg", "video/mpeg",
"audio/mpeg", "audio/mpeg",
@ -50,6 +56,7 @@ export const FILE_TYPE_BROWSERSAFE = [
"audio/aac", "audio/aac",
"audio/x-flac", "audio/x-flac",
"audio/flac",
"audio/vnd.wave", "audio/vnd.wave",
]; ];
/* /*