Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop
This commit is contained in:
		
						commit
						d2d77b5dc1
					
				
					 4 changed files with 18 additions and 13 deletions
				
			
		|  | @ -3,6 +3,7 @@ import { FILE_TYPE_BROWSERSAFE } from '@/const.js'; | ||||||
| const dictionary = { | const dictionary = { | ||||||
| 	'safe-file': FILE_TYPE_BROWSERSAFE, | 	'safe-file': FILE_TYPE_BROWSERSAFE, | ||||||
| 	'sharp-convertible-image': ['image/jpeg', 'image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng', 'image/webp', 'image/avif', 'image/svg+xml'], | 	'sharp-convertible-image': ['image/jpeg', 'image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng', 'image/webp', 'image/avif', 'image/svg+xml'], | ||||||
|  | 	'sharp-animation-convertible-image': ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/avif', 'image/svg+xml'], | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const isMimeImage = (mime: string, type: keyof typeof dictionary): boolean => dictionary[type].includes(mime); | export const isMimeImage = (mime: string, type: keyof typeof dictionary): boolean => dictionary[type].includes(mime); | ||||||
|  |  | ||||||
|  | @ -79,9 +79,17 @@ export class MediaProxyServerService { | ||||||
| 	 | 	 | ||||||
| 			const { mime, ext } = await this.fileInfoService.detectType(path); | 			const { mime, ext } = await this.fileInfoService.detectType(path); | ||||||
| 			const isConvertibleImage = isMimeImage(mime, 'sharp-convertible-image'); | 			const isConvertibleImage = isMimeImage(mime, 'sharp-convertible-image'); | ||||||
|  | 			const isAnimationConvertibleImage = isMimeImage(mime, 'sharp-animation-convertible-image'); | ||||||
| 	 | 	 | ||||||
| 			let image: IImage; | 			let image: IImage; | ||||||
| 			if ('emoji' in request.query && isConvertibleImage) { | 			if ('emoji' in request.query && isConvertibleImage) { | ||||||
|  | 				if (!isAnimationConvertibleImage && !('static' in request.query)) { | ||||||
|  | 					image = { | ||||||
|  | 						data: fs.readFileSync(path), | ||||||
|  | 						ext, | ||||||
|  | 						type: mime, | ||||||
|  | 					}; | ||||||
|  | 				} else { | ||||||
| 					const data = await sharp(path, { animated: !('static' in request.query) }) | 					const data = await sharp(path, { animated: !('static' in request.query) }) | ||||||
| 					.resize({ | 					.resize({ | ||||||
| 						height: 128, | 						height: 128, | ||||||
|  | @ -95,6 +103,7 @@ export class MediaProxyServerService { | ||||||
| 						ext: 'webp', | 						ext: 'webp', | ||||||
| 						type: 'image/webp', | 						type: 'image/webp', | ||||||
| 					}; | 					}; | ||||||
|  | 				} | ||||||
| 			} else if ('static' in request.query && isConvertibleImage) { | 			} else if ('static' in request.query && isConvertibleImage) { | ||||||
| 				image = await this.imageProcessingService.convertToWebp(path, 498, 280); | 				image = await this.imageProcessingService.convertToWebp(path, 498, 280); | ||||||
| 			} else if ('preview' in request.query && isConvertibleImage) { | 			} else if ('preview' in request.query && isConvertibleImage) { | ||||||
|  |  | ||||||
|  | @ -251,10 +251,6 @@ export class ClientServerService { | ||||||
| 
 | 
 | ||||||
| 			reply.header('Content-Security-Policy', 'default-src \'none\'; style-src \'unsafe-inline\''); | 			reply.header('Content-Security-Policy', 'default-src \'none\'; style-src \'unsafe-inline\''); | ||||||
| 
 | 
 | ||||||
| 			// || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ)
 |  | ||||||
| 			return await reply.redirect(301, emoji.publicUrl || emoji.originalUrl); |  | ||||||
| 
 |  | ||||||
| 			/* https://github.com/misskey-dev/misskey/pull/9431#issuecomment-1373006446 |  | ||||||
| 			const url = new URL('/proxy/emoji.webp', this.config.url); | 			const url = new URL('/proxy/emoji.webp', this.config.url); | ||||||
| 			// || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ)
 | 			// || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ)
 | ||||||
| 			url.searchParams.set('url', emoji.publicUrl || emoji.originalUrl); | 			url.searchParams.set('url', emoji.publicUrl || emoji.originalUrl); | ||||||
|  | @ -265,7 +261,6 @@ export class ClientServerService { | ||||||
| 				301, | 				301, | ||||||
| 				url.toString(), | 				url.toString(), | ||||||
| 			); | 			); | ||||||
| 			*/ |  | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		fastify.get<{ Params: { path: string } }>('/fluent-emoji/:path(.*)', async (request, reply) => { | 		fastify.get<{ Params: { path: string } }>('/fluent-emoji/:path(.*)', async (request, reply) => { | ||||||
|  | @ -362,7 +357,7 @@ export class ClientServerService { | ||||||
| 			const name = meta.name || 'Misskey'; | 			const name = meta.name || 'Misskey'; | ||||||
| 			let content = ''; | 			let content = ''; | ||||||
| 			content += '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">'; | 			content += '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">'; | ||||||
| 			content += `<ShortName>${name} Search</ShortName>`; | 			content += `<ShortName>${name}</ShortName>`; | ||||||
| 			content += `<Description>${name} Search</Description>`; | 			content += `<Description>${name} Search</Description>`; | ||||||
| 			content += '<InputEncoding>UTF-8</InputEncoding>'; | 			content += '<InputEncoding>UTF-8</InputEncoding>'; | ||||||
| 			content += `<Image width="16" height="16" type="image/x-icon">${this.config.url}/favicon.ico</Image>`; | 			content += `<Image width="16" height="16" type="image/x-icon">${this.config.url}/favicon.ico</Image>`; | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ html | ||||||
| 		link(rel='icon' href= icon || '/favicon.ico') | 		link(rel='icon' href= icon || '/favicon.ico') | ||||||
| 		link(rel='apple-touch-icon' href= icon || '/apple-touch-icon.png') | 		link(rel='apple-touch-icon' href= icon || '/apple-touch-icon.png') | ||||||
| 		link(rel='manifest' href='/manifest.json') | 		link(rel='manifest' href='/manifest.json') | ||||||
| 		link(rel='search' type='application/opensearchdescription+xml' title=((title || "Misskey") + " Search") href=`${url}/opensearch.xml`) | 		link(rel='search' type='application/opensearchdescription+xml' title=(title || "Misskey") href=`${url}/opensearch.xml`) | ||||||
| 		link(rel='prefetch' href='https://xn--931a.moe/assets/info.jpg') | 		link(rel='prefetch' href='https://xn--931a.moe/assets/info.jpg') | ||||||
| 		link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg') | 		link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg') | ||||||
| 		link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg') | 		link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg') | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue