feat(frontend/MkUrlPreview): oEmbedのサポート (#10306)
* feat(frontend/MkUrlPreview): oEmbedのサポート * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * playerとoEmbedの統合 * Update CHANGELOG.md * loading=lazyはここでは不要 * border: 0 * プレビュー直後にautoplayできる機能の復旧 * add test * refactor test * explain about cache * expandPreviewはもう使わない * summaly v4 * update summaly * scrolling=no to fix pixiv --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp>
This commit is contained in:
		 Kagami Sascha Rosylight
					Kagami Sascha Rosylight
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							4d73080da1
						
					
				
				
					commit
					c091d9e6d5
				
			| @@ -19,9 +19,6 @@ export class UrlPreviewService { | ||||
| 		@Inject(DI.config) | ||||
| 		private config: Config, | ||||
|  | ||||
| 		@Inject(DI.usersRepository) | ||||
| 		private usersRepository: UsersRepository, | ||||
|  | ||||
| 		private metaService: MetaService, | ||||
| 		private httpRequestService: HttpRequestService, | ||||
| 		private loggerService: LoggerService, | ||||
| @@ -51,15 +48,15 @@ export class UrlPreviewService { | ||||
| 			reply.code(400); | ||||
| 			return; | ||||
| 		} | ||||
| 	 | ||||
|  | ||||
| 		const lang = request.query.lang; | ||||
| 		if (Array.isArray(lang)) { | ||||
| 			reply.code(400); | ||||
| 			return; | ||||
| 		} | ||||
| 	 | ||||
|  | ||||
| 		const meta = await this.metaService.fetch(); | ||||
| 	 | ||||
|  | ||||
| 		this.logger.info(meta.summalyProxy | ||||
| 			? `(Proxy) Getting preview of ${url}@${lang} ...` | ||||
| 			: `Getting preview of ${url}@${lang} ...`); | ||||
| @@ -85,16 +82,16 @@ export class UrlPreviewService { | ||||
| 				throw new Error('unsupported schema included'); | ||||
| 			} | ||||
|  | ||||
| 			if (summary.player?.url && !(summary.player.url.startsWith('http://') || summary.player.url.startsWith('https://'))) { | ||||
| 			if (summary.player.url && !(summary.player.url.startsWith('http://') || summary.player.url.startsWith('https://'))) { | ||||
| 				throw new Error('unsupported schema included'); | ||||
| 			} | ||||
| 	 | ||||
|  | ||||
| 			summary.icon = this.wrap(summary.icon); | ||||
| 			summary.thumbnail = this.wrap(summary.thumbnail); | ||||
| 	 | ||||
|  | ||||
| 			// Cache 7days | ||||
| 			reply.header('Cache-Control', 'max-age=604800, immutable'); | ||||
| 	 | ||||
|  | ||||
| 			return summary; | ||||
| 		} catch (err) { | ||||
| 			this.logger.warn(`Failed to get preview of ${url}: ${err}`); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user