mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix mime checks (#5118)

authored by samuel.fm and committed by

GitHub 0bd0146e ea4d8bc1

+28 -14
+9
src/lib/constants.ts
··· 136 136 `${GIF_SERVICE}/tenor/v2/featured?${params}` 137 137 138 138 export const MAX_LABELERS = 20 139 + 140 + export const SUPPORTED_MIME_TYPES = [ 141 + 'video/mp4', 142 + 'video/mpeg', 143 + 'video/webm', 144 + 'video/quicktime', 145 + ] as const 146 + 147 + export type SupportedMimeTypes = (typeof SUPPORTED_MIME_TYPES)[number]
+1 -1
src/lib/media/video/compress.ts
··· 30 30 31 31 const info = await getVideoMetaData(compressed) 32 32 33 - return {uri: compressed, size: info.size, mimeType: `video/${info.extension}`} 33 + return {uri: compressed, size: info.size, mimeType: `video/mp4`} 34 34 }
+5 -1
src/state/queries/video/util.ts
··· 1 1 import {useMemo} from 'react' 2 2 import {AtpAgent} from '@atproto/api' 3 3 4 + import {SupportedMimeTypes} from '#/lib/constants' 5 + 4 6 const UPLOAD_ENDPOINT = 'https://video.bsky.app/' 5 7 6 8 export const createVideoEndpointUrl = ( ··· 25 27 }, []) 26 28 } 27 29 28 - export function mimeToExt(mimeType: string) { 30 + export function mimeToExt(mimeType: SupportedMimeTypes | (string & {})) { 29 31 switch (mimeType) { 30 32 case 'video/mp4': 31 33 return 'mp4' ··· 33 35 return 'webm' 34 36 case 'video/mpeg': 35 37 return 'mpeg' 38 + case 'video/quicktime': 39 + return 'mov' 36 40 default: 37 41 throw new Error(`Unsupported mime type: ${mimeType}`) 38 42 }
+13 -12
src/state/queries/video/video.ts
··· 5 5 import {useLingui} from '@lingui/react' 6 6 import {QueryClient, useQuery, useQueryClient} from '@tanstack/react-query' 7 7 8 + import {SUPPORTED_MIME_TYPES, SupportedMimeTypes} from '#/lib/constants' 8 9 import {logger} from '#/logger' 9 10 import {isWeb} from '#/platform/detection' 10 11 import {ServerError, VideoTooLargeError} from 'lib/media/video/errors' ··· 175 176 }) 176 177 177 178 const selectVideo = (asset: ImagePickerAsset) => { 178 - switch (getMimeType(asset)) { 179 - case 'video/mp4': 180 - case 'video/mpeg': 181 - case 'video/webm': 182 - dispatch({ 183 - type: 'SetAsset', 184 - asset, 185 - }) 186 - onSelectVideo(asset) 187 - break 188 - default: 189 - throw new Error(_(msg`Unsupported video type: ${getMimeType(asset)}`)) 179 + // compression step on native converts to mp4, so no need to check there 180 + if (isWeb) { 181 + const mimeType = getMimeType(asset) 182 + if (!SUPPORTED_MIME_TYPES.includes(mimeType as SupportedMimeTypes)) { 183 + throw new Error(_(msg`Unsupported video type: ${mimeType}`)) 184 + } 190 185 } 186 + 187 + dispatch({ 188 + type: 'SetAsset', 189 + asset, 190 + }) 191 + onSelectVideo(asset) 191 192 } 192 193 193 194 const clearVideo = () => {