Skip to content

Commit

Permalink
cache emoji response
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Dec 31, 2022
1 parent 6f648fc commit 51d8d2a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/backend/src/server/web/ClientServerService.ts
Expand Up @@ -228,6 +228,8 @@ export class ClientServerService {
return;
}

reply.header('Cache-Control', 'public, max-age=3600');

const name = path.split('@')[0].replace('.webp', '');
const host = path.split('@')[1]?.replace('.webp', '');

Expand All @@ -244,7 +246,7 @@ export class ClientServerService {

reply.header('Content-Security-Policy', 'default-src \'none\'; style-src \'unsafe-inline\'');

const url = new URL("/proxy/emoji.webp", this.config.url);
const url = new URL('/proxy/emoji.webp', this.config.url);
// || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ)
url.searchParams.set('url', emoji.publicUrl || emoji.originalUrl);
url.searchParams.set('emoji', '1');
Expand Down Expand Up @@ -347,15 +349,15 @@ export class ClientServerService {
fastify.get('/opensearch.xml', async (request, reply) => {
const meta = await this.metaService.fetch();

const name = meta.name || "Misskey";
let content = "";
content += `<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">`;
const name = meta.name || 'Misskey';
let content = '';
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 += `<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 += `<Url type="text/html" template="${this.config.url}/search?q={searchTerms}"/>`;
content += `</OpenSearchDescription>`;
content += '</OpenSearchDescription>';

reply.header('Content-Type', 'application/opensearchdescription+xml');
return await reply.send(content);
Expand Down

0 comments on commit 51d8d2a

Please sign in to comment.