アニメーションを自動再生しないオプション (#4131)

* Refactor

* settings

* Media Proxy

* Replace API response
This commit is contained in:
MeiMei
2019-02-05 03:01:36 +09:00
committed by syuilo
parent 00b2d89f1a
commit f014b7ae0e
14 changed files with 404 additions and 170 deletions

20
src/misc/wrap-url.ts Normal file
View File

@ -0,0 +1,20 @@
import { URL } from 'url';
import config from '../config';
/**
* avatar, thumbnail, custom-emoji 等のURLをクライアント設定等によって置き換える
*/
export default function(url: string, me: any) {
if (url == null) return url;
// アニメーション再生無効
if (me && me.clientSettings && me.clientSettings.doNotAutoplayAnimation) {
const u = new URL(url);
const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので
let result = `${config.url}/proxy/${dummy}?url=${encodeURI(u.href)}`;
result += '&static=1';
return result;
}
return url;
}