forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
24 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ export class SecurityHeaderService { | |
const imgSrc = [ | ||
'\'self\'', 'data:', 'blob:', | ||
'https://xn--931a.moe/assets/', | ||
'https://cdn.jsdelivr.net/gh/jdecked/[email protected]/assets/', | ||
...(this.config.externalMediaProxyEnabled ? [mediaProxyOrigin] : []), | ||
...(this.config.contentSecurityPolicy?.imgAndMediaSrc ?? []), | ||
].join(' '); | ||
|
@@ -190,9 +191,12 @@ export class SecurityHeaderService { | |
case '/assets/*': | ||
case '/apple-touch-icon.png': | ||
case '/fluent-emoji/:path(.*)': | ||
reply.header('Content-Security-Policy', this.selfHostedMediaPolicy); | ||
break; | ||
|
||
case '/twemoji/:path(.*)': | ||
case '/twemoji-badge/:path(.*)': | ||
reply.header('Content-Security-Policy', this.selfHostedMediaPolicy); | ||
reply.header('Content-Security-Policy', this.strictestPolicy); | ||
break; | ||
|
||
case '/favicon.ico': | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ import { createBullBoard } from '@bull-board/api'; | |
import { BullMQAdapter } from '@bull-board/api/bullMQAdapter.js'; | ||
import { FastifyAdapter } from '@bull-board/fastify'; | ||
import ms from 'ms'; | ||
import sharp from 'sharp'; | ||
import pug from 'pug'; | ||
import { In, IsNull } from 'typeorm'; | ||
import fastifyStatic from '@fastify/static'; | ||
|
@@ -454,9 +453,9 @@ export class ClientServerService { | |
return; | ||
} | ||
|
||
return await reply.sendFile(path, `${_dirname}/../../../node_modules/@discordapp/twemoji/dist/svg/`, { | ||
maxAge: ms('30 days'), | ||
}); | ||
reply.header('Cache-Control', 'public, max-age=31536000, immutable'); | ||
|
||
return reply.redirect(`https://cdn.jsdelivr.net/gh/jdecked/[email protected]/assets/svg/${path}`, 301); | ||
}); | ||
|
||
fastify.get<{ Params: { path: string } }>('/twemoji-badge/:path(.*)', async (request, reply) => { | ||
|
@@ -467,38 +466,9 @@ export class ClientServerService { | |
return; | ||
} | ||
|
||
const mask = await sharp( | ||
`${_dirname}/../../../node_modules/@discordapp/twemoji/dist/svg/${path.replace('.png', '')}.svg`, | ||
{ density: 1000 }, | ||
) | ||
.resize(488, 488) | ||
.greyscale() | ||
.normalise() | ||
.linear(1.75, -(128 * 1.75) + 128) // 1.75x contrast | ||
.flatten({ background: '#000' }) | ||
.extend({ | ||
top: 12, | ||
bottom: 12, | ||
left: 12, | ||
right: 12, | ||
background: '#000', | ||
}) | ||
.toColorspace('b-w') | ||
.png() | ||
.toBuffer(); | ||
|
||
const buffer = await sharp({ | ||
create: { width: 512, height: 512, channels: 4, background: { r: 0, g: 0, b: 0, alpha: 0 } }, | ||
}) | ||
.pipelineColorspace('b-w') | ||
.boolean(mask, 'eor') | ||
.resize(96, 96) | ||
.png() | ||
.toBuffer(); | ||
|
||
reply.header('Cache-Control', 'max-age=2592000'); | ||
reply.header('Content-Type', 'image/png'); | ||
return buffer; | ||
reply.header('Cache-Control', 'public, max-age=31536000, immutable'); | ||
|
||
return reply.redirect(`https://cdn.jsdelivr.net/gh/jdecked/[email protected]/assets/72x72/${path}`, 301); | ||
}); | ||
|
||
// ServiceWorker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.