Skip to content

Commit

Permalink
wellKnownWebsites -> trustedLinkUrlPatterns
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Mar 24, 2024
1 parent ce04e88 commit 9114c55
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4815,11 +4815,11 @@ export interface Locale extends ILocale {
/**
* よく知られたウェブサイト
*/
"wellKnownWebsites": string;
"trustedLinkUrlPatterns": string;
/**
* スペースで区切るとAND指定になり、改行で区切るとOR指定になります。スラッシュで囲むと正規表現になります。一致した場合、外部サイトへのリダイレクトの警告を省略させることができます。
*/
"wellKnownWebsitesDescription": string;
"trustedLinkUrlPatternsDescription": string;
/**
* コード
*/
Expand Down
4 changes: 2 additions & 2 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1199,8 +1199,8 @@ useGroupedNotifications: "通知をグルーピングして表示する"
signupPendingError: "メールアドレスの確認中に問題が発生しました。リンクの有効期限が切れている可能性があります。"
cwNotationRequired: "「内容を隠す」がオンの場合は注釈の記述が必要です。"
doReaction: "リアクションする"
wellKnownWebsites: "よく知られたウェブサイト"
wellKnownWebsitesDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります。スラッシュで囲むと正規表現になります。ドメイン名だけ書くと後方一致になります。一致した場合、外部サイトへのリダイレクトの警告を省略させることができます"
trustedLinkUrlPatterns: "外部サイトへのリンク警告 除外リスト"
trustedLinkUrlPatternsDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります。スラッシュで囲むと正規表現になります。ドメイン名だけ書くと後方一致になります。"
code: "コード"
reloadRequiredToApplySettings: "設定の反映にはリロードが必要です。"
remainingN: "残り: {n}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export class ExternalWebsiteWarn1711008460816 {
name = 'ExternalWebsiteWarn1711008460816'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "wellKnownWebsites" character varying(3072) array NOT NULL DEFAULT '{}'`);
await queryRunner.query(`ALTER TABLE "meta" ADD "trustedLinkUrlPatterns" character varying(3072) array NOT NULL DEFAULT '{}'`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "wellKnownWebsites"`);
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "trustedLinkUrlPatterns"`);
}
}
2 changes: 1 addition & 1 deletion packages/backend/src/core/entities/MetaEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class MetaEntityService {
imageUrl: ad.imageUrl,
dayOfWeek: ad.dayOfWeek,
})),
wellKnownWebsites: instance.wellKnownWebsites,
trustedLinkUrlPatterns: instance.trustedLinkUrlPatterns,
notesPerOneAd: instance.notesPerOneAd,
enableEmail: instance.enableEmail,
enableServiceWorker: instance.enableServiceWorker,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ export class MiMeta {
default: '{}',
comment: 'An array of URL strings or regex that can be used to omit warnings about redirects to external sites. Separate them with spaces to specify AND, and enclose them with slashes to specify regular expressions. Each item is regarded as an OR.',
})
public wellKnownWebsites: string[];
public trustedLinkUrlPatterns: string[];

@Column('varchar', {
length: 1024,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/models/json-schema/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const packedMetaLiteSchema = {
},
},
},
wellKnownWebsites: {
trustedLinkUrlPatterns: {
type: 'array',
optional: false, nullable: false,
items: {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export const meta = {
type: 'number',
optional: false, nullable: false,
},
wellKnownWebsites: {
trustedLinkUrlPatterns: {
type: 'array',
optional: false, nullable: false,
items: {
Expand Down Expand Up @@ -609,7 +609,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
perRemoteUserUserTimelineCacheMax: instance.perRemoteUserUserTimelineCacheMax,
perUserHomeTimelineCacheMax: instance.perUserHomeTimelineCacheMax,
perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax,
wellKnownWebsites: instance.wellKnownWebsites,
trustedLinkUrlPatterns: instance.trustedLinkUrlPatterns,
notesPerOneAd: instance.notesPerOneAd,
summalyProxy: instance.urlPreviewSummaryProxyUrl,
urlPreviewEnabled: instance.urlPreviewEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const paramDef = {
type: 'string', nullable: true,
description: '[Deprecated] Use "urlPreviewSummaryProxyUrl" instead.',
},
wellKnownWebsites: {
trustedLinkUrlPatterns: {
type: 'array', nullable: true, items: {
type: 'string',
},
Expand Down Expand Up @@ -208,8 +208,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
});
}

if (Array.isArray(ps.wellKnownWebsites)) {
set.wellKnownWebsites = ps.wellKnownWebsites.filter(Boolean);
if (Array.isArray(ps.trustedLinkUrlPatterns)) {
set.trustedLinkUrlPatterns = ps.trustedLinkUrlPatterns.filter(Boolean);
}

if (ps.themeColor !== undefined) {
Expand Down
12 changes: 6 additions & 6 deletions packages/frontend/src/pages/admin/moderation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #caption>{{ i18n.ts.prohibitedWordsDescription }}<br>{{ i18n.ts.prohibitedWordsDescription2 }}</template>
</MkTextarea>

<MkTextarea v-model="wellKnownWebsites">
<template #label>{{ i18n.ts.wellKnownWebsites }}</template>
<template #caption>{{ i18n.ts.wellKnownWebsitesDescription }}</template>
<MkTextarea v-model="trustedLinkUrlPatterns">
<template #label>{{ i18n.ts.trustedLinkUrlPatterns }}</template>
<template #caption>{{ i18n.ts.trustedLinkUrlPatternsDescription }}</template>
</MkTextarea>

<MkTextarea v-model="hiddenTags">
Expand Down Expand Up @@ -91,7 +91,7 @@ const hiddenTags = ref<string>('');
const preservedUsernames = ref<string>('');
const tosUrl = ref<string | null>(null);
const privacyPolicyUrl = ref<string | null>(null);
const wellKnownWebsites = ref<string>('');
const trustedLinkUrlPatterns = ref<string>('');
async function init() {
const meta = await misskeyApi('admin/meta');
Expand All @@ -103,7 +103,7 @@ async function init() {
preservedUsernames.value = meta.preservedUsernames.join('\n');
tosUrl.value = meta.tosUrl;
privacyPolicyUrl.value = meta.privacyPolicyUrl;
wellKnownWebsites.value = meta.wellKnownWebsites.join('\n');
trustedLinkUrlPatterns.value = meta.trustedLinkUrlPatterns.join('\n');
}
function save() {
Expand All @@ -116,7 +116,7 @@ function save() {
prohibitedWords: prohibitedWords.value.split('\n'),
hiddenTags: hiddenTags.value.split('\n'),
preservedUsernames: preservedUsernames.value.split('\n'),
wellKnownWebsites: wellKnownWebsites.value.split('\n'),
trustedLinkUrlPatterns: trustedLinkUrlPatterns.value.split('\n'),
}).then(() => {
fetchInstance(true);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/scripts/warning-external-website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const isRegExp = /^\/(.+)\/(.*)$/;
export async function warningExternalWebsite(ev: MouseEvent, url: string) {
const domain = extractDomain.exec(url)?.[4];
const self = !domain || url.startsWith(local);
const isWellKnownWebsite = self || instance.wellKnownWebsites.some(expression => {
const isTrustedByInstance = self || instance.trustedLinkUrlPatterns.some(expression => {
const r = isRegExp.exec(expression);
if (r) {
return new RegExp(r[1], r[2]).test(url);
Expand All @@ -24,7 +24,7 @@ export async function warningExternalWebsite(ev: MouseEvent, url: string) {
});
const isTrustedByUser = defaultStore.reactiveState.trustedDomains.value.includes(domain);

if (!self && !isWellKnownWebsite && !isTrustedByUser) {
if (!self && !isTrustedByInstance && !isTrustedByUser) {
ev.preventDefault();
ev.stopPropagation();

Expand Down
6 changes: 3 additions & 3 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4804,7 +4804,7 @@ export type components = {
imageUrl: string;
dayOfWeek: number;
}[];
wellKnownWebsites: string[];
trustedLinkUrlPatterns: string[];
/** @default 0 */
notesPerOneAd: number;
enableEmail: boolean;
Expand Down Expand Up @@ -4949,7 +4949,7 @@ export type operations = {
perUserHomeTimelineCacheMax: number;
perUserListTimelineCacheMax: number;
notesPerOneAd: number;
wellKnownWebsites: string[];
trustedLinkUrlPatterns: string[];
backgroundImageUrl: string | null;
deeplAuthKey: string | null;
deeplIsPro: boolean;
Expand Down Expand Up @@ -8930,7 +8930,7 @@ export type operations = {
silencedHosts?: string[] | null;
/** @description [Deprecated] Use "urlPreviewSummaryProxyUrl" instead. */
summalyProxy?: string | null;
wellKnownWebsites?: string[] | null;
trustedLinkUrlPatterns?: string[] | null;
urlPreviewEnabled?: boolean;
urlPreviewTimeout?: number;
urlPreviewMaximumContentLength?: number;
Expand Down

0 comments on commit 9114c55

Please sign in to comment.