1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-01 00:08:31 +09:00

refactor: use structuredClone for deep clone

This commit is contained in:
syuilo 2022-04-23 12:38:02 +09:00
parent 70958a9f77
commit 84b183a9f6
3 changed files with 8 additions and 8 deletions

View File

@ -29,7 +29,7 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({
getPublicProperties(file: DriveFile): DriveFile['properties'] {
if (file.properties.orientation != null) {
const properties = JSON.parse(JSON.stringify(file.properties));
const properties = structuredClone(file.properties);
if (file.properties.orientation >= 5) {
[properties.width, properties.height] = [properties.height, properties.width];
}

View File

@ -1,16 +1,16 @@
import Koa from 'koa';
import manifest from './manifest.json' assert { type: 'json' };
import { fetchMeta } from '@/misc/fetch-meta.js';
import manifest from './manifest.json' assert { type: 'json' };
export const manifestHandler = async (ctx: Koa.Context) => {
const json = JSON.parse(JSON.stringify(manifest));
const res = structuredClone(manifest);
const instance = await fetchMeta(true);
json.short_name = instance.name || 'Misskey';
json.name = instance.name || 'Misskey';
if (instance.themeColor) json.theme_color = instance.themeColor;
res.short_name = instance.name || 'Misskey';
res.name = instance.name || 'Misskey';
if (instance.themeColor) res.theme_color = instance.themeColor;
ctx.set('Cache-Control', 'max-age=300');
ctx.body = json;
ctx.body = res;
};

View File

@ -88,7 +88,7 @@ export async function deliverToRelays(user: { id: User['id']; host: null; }, act
}));
if (relays.length === 0) return;
const copy = JSON.parse(JSON.stringify(activity));
const copy = structuredClone(activity);
if (!copy.to) copy.to = ['https://www.w3.org/ns/activitystreams#Public'];
const signed = await attachLdSignature(copy, user);