mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 08:23:08 +02:00
カスタム絵文字をproxyに通すように (#7526)
This commit is contained in:
parent
ae2267220b
commit
466c083233
2 changed files with 11 additions and 1 deletions
|
@ -3,6 +3,11 @@ import * as url from '../../prelude/url';
|
||||||
|
|
||||||
export function getStaticImageUrl(baseUrl: string): string {
|
export function getStaticImageUrl(baseUrl: string): string {
|
||||||
const u = new URL(baseUrl);
|
const u = new URL(baseUrl);
|
||||||
|
if (u.href.startsWith(`${instanceUrl}/proxy/`)) {
|
||||||
|
// もう既にproxyっぽそうだったらsearchParams付けるだけ
|
||||||
|
u.searchParams.set('static', '1');
|
||||||
|
return u.href;
|
||||||
|
}
|
||||||
const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので
|
const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので
|
||||||
return `${instanceUrl}/proxy/${dummy}?${url.query({
|
return `${instanceUrl}/proxy/${dummy}?${url.query({
|
||||||
url: u.href,
|
url: u.href,
|
||||||
|
|
|
@ -5,6 +5,8 @@ import { Note } from '../models/entities/note';
|
||||||
import { Cache } from './cache';
|
import { Cache } from './cache';
|
||||||
import { isSelfHost, toPunyNullable } from './convert-host';
|
import { isSelfHost, toPunyNullable } from './convert-host';
|
||||||
import { decodeReaction } from './reaction-lib';
|
import { decodeReaction } from './reaction-lib';
|
||||||
|
import config from '@/config';
|
||||||
|
import { query } from '@/prelude/url';
|
||||||
|
|
||||||
const cache = new Cache<Emoji | null>(1000 * 60 * 60 * 12);
|
const cache = new Cache<Emoji | null>(1000 * 60 * 60 * 12);
|
||||||
|
|
||||||
|
@ -59,9 +61,12 @@ export async function populateEmoji(emojiName: string, noteUserHost: string | nu
|
||||||
|
|
||||||
if (emoji == null) return null;
|
if (emoji == null) return null;
|
||||||
|
|
||||||
|
const isLocal = emojiName.endsWith('@.');
|
||||||
|
const url = isLocal ? emoji.url : `${config.url}/proxy/image.png?${query({url: emoji.url})}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: emojiName,
|
name: emojiName,
|
||||||
url: emoji.url,
|
url,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue