Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop
This commit is contained in:
commit
23753ec75a
20 changed files with 311 additions and 207 deletions
|
|
@ -13,6 +13,7 @@ import { downloadUrl } from '@/misc/download-url';
|
|||
import { detectType } from '@/misc/get-file-info';
|
||||
import { convertToJpeg, convertToPngOrJpeg } from '@/services/drive/image-processor';
|
||||
import { GenerateVideoThumbnail } from '@/services/drive/generate-video-thumbnail';
|
||||
import { StatusError } from '@/misc/fetch';
|
||||
|
||||
//const _filename = fileURLToPath(import.meta.url);
|
||||
const _filename = __filename;
|
||||
|
|
@ -83,9 +84,9 @@ export default async function(ctx: Koa.Context) {
|
|||
ctx.set('Content-Type', image.type);
|
||||
ctx.set('Cache-Control', 'max-age=31536000, immutable');
|
||||
} catch (e) {
|
||||
serverLogger.error(e.statusCode);
|
||||
serverLogger.error(`${e}`);
|
||||
|
||||
if (typeof e.statusCode === 'number' && e.statusCode >= 400 && e.statusCode < 500) {
|
||||
if (e instanceof StatusError && e.isClientError) {
|
||||
ctx.status = e.statusCode;
|
||||
ctx.set('Cache-Control', 'max-age=86400');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { IImage, convertToPng, convertToJpeg } from '@/services/drive/image-proc
|
|||
import { createTemp } from '@/misc/create-temp';
|
||||
import { downloadUrl } from '@/misc/download-url';
|
||||
import { detectType } from '@/misc/get-file-info';
|
||||
import { StatusError } from '@/misc/fetch';
|
||||
|
||||
export async function proxyMedia(ctx: Koa.Context) {
|
||||
const url = 'url' in ctx.query ? ctx.query.url : 'https://' + ctx.params.url;
|
||||
|
|
@ -37,9 +38,9 @@ export async function proxyMedia(ctx: Koa.Context) {
|
|||
ctx.set('Cache-Control', 'max-age=31536000, immutable');
|
||||
ctx.body = image.data;
|
||||
} catch (e) {
|
||||
serverLogger.error(e);
|
||||
serverLogger.error(`${e}`);
|
||||
|
||||
if (typeof e.statusCode === 'number' && e.statusCode >= 400 && e.statusCode < 500) {
|
||||
if (e instanceof StatusError && e.isClientError) {
|
||||
ctx.status = e.statusCode;
|
||||
} else {
|
||||
ctx.status = 500;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue