feat(federation): 特定の連合サーバーのメディアを全てセンシティブとして設定する機能を追加 (MisskeyIO#340)

This commit is contained in:
まっちゃとーにゅ
2024-01-07 19:51:07 +09:00
committed by GitHub
parent ce58adce22
commit d4a8e9a499
15 changed files with 105 additions and 5 deletions

View File

@@ -116,6 +116,16 @@ export const meta = {
nullable: false,
},
},
sensitiveMediaHosts: {
type: 'array',
optional: true,
nullable: false,
items: {
type: 'string',
optional: false,
nullable: false,
},
},
pinnedUsers: {
type: 'array',
optional: false, nullable: false,
@@ -491,6 +501,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
hiddenTags: instance.hiddenTags,
blockedHosts: instance.blockedHosts,
silencedHosts: instance.silencedHosts,
sensitiveMediaHosts: instance.sensitiveMediaHosts,
sensitiveWords: instance.sensitiveWords,
preservedUsernames: instance.preservedUsernames,
hcaptchaSecretKey: instance.hcaptchaSecretKey,

View File

@@ -138,6 +138,11 @@ export const paramDef = {
type: 'string',
},
},
sensitiveMediaHosts: {
type: 'array', nullable: true, items: {
type: 'string',
},
},
urlPreviewDenyList: { type: 'array', nullable: true, items: {
type: 'string',
} },
@@ -173,13 +178,23 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (Array.isArray(ps.sensitiveWords)) {
set.sensitiveWords = ps.sensitiveWords.filter(Boolean);
}
if (Array.isArray(ps.silencedHosts)) {
let lastValue = '';
set.silencedHosts = ps.silencedHosts.sort().filter((h) => {
const lv = lastValue;
lastValue = h;
return h !== '' && h !== lv && !set.blockedHosts?.includes(h);
});
}).map(x => x.toLowerCase());
}
if (Array.isArray(ps.sensitiveMediaHosts)) {
let lastValue = '';
set.sensitiveMediaHosts = ps.sensitiveMediaHosts.sort().filter((h) => {
const lv = lastValue;
lastValue = h;
return h !== '' && h !== lv && !set.blockedHosts?.includes(h);
}).map(x => x.toLowerCase());
}
if (Array.isArray(ps.urlPreviewDenyList)) {