Merge tag '2024.3.1-io.2c' into host

This commit is contained in:
まっちゃとーにゅ 2024-03-22 09:11:54 +09:00
commit f0d9f7d093
No known key found for this signature in database
GPG key ID: 6AFBBF529601C1DB
40 changed files with 1697 additions and 1149 deletions

View file

@ -1,6 +1,12 @@
## Unreleased ## Unreleased
### Note
- コントロールパネル内にあるサマリープロキシの設定個所がセキュリティから全般へ変更となります。
### General ### General
- Enhance: URLプレビューの有効化・無効化を設定できるように #13569
- Enhance: アンテナでBotによるートを除外できるように
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/545)
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正 - Fix: Play作成時に設定した公開範囲が機能していない問題を修正
### Client ### Client
@ -23,6 +29,7 @@
### Server ### Server
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
- Enhance: misskey-dev/summaly@5.1.0の取り込み(プレビュー生成処理の効率化)
- Fix: フォローリクエストを作成する際に既存のものは削除するように - Fix: フォローリクエストを作成する際に既存のものは削除するように
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/440) (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/440)

View file

@ -1212,6 +1212,10 @@ useGroupedNotifications: "Display grouped notifications"
signupPendingError: "There was a problem verifying the email address. The link may have expired." signupPendingError: "There was a problem verifying the email address. The link may have expired."
cwNotationRequired: "If \"Hide content\" is enabled, a description must be provided." cwNotationRequired: "If \"Hide content\" is enabled, a description must be provided."
doReaction: "Add reaction" doReaction: "Add reaction"
wellKnownWebsites: "Well-known websites"
wellKnownWebsitesDescription: "Separate with spaces for AND, new lines for OR. Surround with slashes for regular expressions. Matching will allow redirection to external sites without a warning."
warningRedirectingExternalWebsiteTitle: "You are leaving our site!"
warningRedirectingExternalWebsiteDescription: "You are about to jump to another site.\nPlease make sure this link is reliable before proceeding.\n\n{url}"
code: "Code" code: "Code"
reloadRequiredToApplySettings: "Reloading is required to apply the settings." reloadRequiredToApplySettings: "Reloading is required to apply the settings."
remainingN: "Remaining: {n}" remainingN: "Remaining: {n}"

77
locales/index.d.ts vendored
View file

@ -4860,6 +4860,25 @@ export interface Locale extends ILocale {
* *
*/ */
"doReaction": string; "doReaction": string;
/**
*
*/
"wellKnownWebsites": string;
/**
* AND指定になりOR指定になります
*/
"wellKnownWebsitesDescription": string;
/**
*
*/
"warningRedirectingExternalWebsiteTitle": string;
/**
*
*
*
* {url}
*/
"warningRedirectingExternalWebsiteDescription": ParameterizedString<"url">;
/** /**
* URL * URL
*/ */
@ -4972,6 +4991,10 @@ export interface Locale extends ILocale {
* *
*/ */
"gameRetry": string; "gameRetry": string;
/**
* 使
*/
"notUsePleaseLeaveBlank": string;
/** /**
* *
*/ */
@ -10024,6 +10047,60 @@ export interface Locale extends ILocale {
*/ */
"header": string; "header": string;
}; };
"_urlPreviewSetting": {
/**
* URLプレビューの設定
*/
"title": string;
/**
* URLプレビューを有効にする
*/
"enable": string;
/**
* (ms)
*/
"timeout": string;
/**
*
*/
"timeoutDescription": string;
/**
* Content-Lengthの最大値(byte)
*/
"maximumContentLength": string;
/**
* Content-Lengthがこの値を超えた場合
*/
"maximumContentLengthDescription": string;
/**
* Content-Lengthが取得できた場合のみプレビューを生成
*/
"requireContentLength": string;
/**
* Content-Lengthを返さない場合
*/
"requireContentLengthDescription": string;
/**
* User-Agent
*/
"userAgent": string;
/**
* 使User-Agentを設定しますUser-Agentが使用されます
*/
"userAgentDescription": string;
/**
*
*/
"summaryProxy": string;
/**
* Misskey本体ではなく使
*/
"summaryProxyDescription": string;
/**
*
*/
"summaryProxyDescription2": string;
};
} }
declare const locales: { declare const locales: {
[lang: string]: Locale; [lang: string]: Locale;

View file

@ -1211,6 +1211,10 @@ useGroupedNotifications: "通知をグルーピングして表示する"
signupPendingError: "メールアドレスの確認中に問題が発生しました。リンクの有効期限が切れている可能性があります。" signupPendingError: "メールアドレスの確認中に問題が発生しました。リンクの有効期限が切れている可能性があります。"
cwNotationRequired: "「内容を隠す」がオンの場合は注釈の記述が必要です。" cwNotationRequired: "「内容を隠す」がオンの場合は注釈の記述が必要です。"
doReaction: "リアクションする" doReaction: "リアクションする"
wellKnownWebsites: "よく知られたウェブサイト"
wellKnownWebsitesDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります。スラッシュで囲むと正規表現になります。一致した場合、外部サイトへのリダイレクトの警告を省略させることができます。"
warningRedirectingExternalWebsiteTitle: "外部サイトへ移動します"
warningRedirectingExternalWebsiteDescription: "別のサイトにジャンプしようとしています。\nリンク先の安全性を十分に確認した上で進んでください。\n\n{url}"
urlPreviewDenyList: "サムネイルの表示を制限するURL" urlPreviewDenyList: "サムネイルの表示を制限するURL"
urlPreviewDenyListDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります。スラッシュで囲むと正規表現になります。一致した場合、サムネイルがぼかされて表示されます。" urlPreviewDenyListDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります。スラッシュで囲むと正規表現になります。一致した場合、サムネイルがぼかされて表示されます。"
code: "コード" code: "コード"
@ -1239,6 +1243,7 @@ enableHorizontalSwipe: "スワイプしてタブを切り替える"
loading: "読み込み中" loading: "読み込み中"
surrender: "やめる" surrender: "やめる"
gameRetry: "リトライ" gameRetry: "リトライ"
notUsePleaseLeaveBlank: "使用しない場合は空欄にしてください"
abuseReportCategory: "通報の種類" abuseReportCategory: "通報の種類"
selectCategory: "カテゴリを選択" selectCategory: "カテゴリを選択"
reportComplete: "通報完了" reportComplete: "通報完了"
@ -2671,3 +2676,17 @@ _offlineScreen:
title: "オフライン - サーバーに接続できません" title: "オフライン - サーバーに接続できません"
header: "サーバーに接続できません" header: "サーバーに接続できません"
_urlPreviewSetting:
title: "URLプレビューの設定"
enable: "URLプレビューを有効にする"
timeout: "プレビュー取得時のタイムアウト(ms)"
timeoutDescription: "プレビュー取得の所要時間がこの値を超えた場合、プレビューは生成されません。"
maximumContentLength: "Content-Lengthの最大値(byte)"
maximumContentLengthDescription: "Content-Lengthがこの値を超えた場合、プレビューは生成されません。"
requireContentLength: "Content-Lengthが取得できた場合のみプレビューを生成"
requireContentLengthDescription: "相手サーバがContent-Lengthを返さない場合、プレビューは生成されません。"
userAgent: "User-Agent"
userAgentDescription: "プレビュー取得時に使用されるUser-Agentを設定します。空欄の場合、デフォルトのUser-Agentが使用されます。"
summaryProxy: "プレビューを生成するプロキシのエンドポイント"
summaryProxyDescription: "Misskey本体ではなく、サマリープロキシを使用してプレビューを生成します。"
summaryProxyDescription2: "プロキシには下記パラメータがクエリ文字列として連携されます。プロキシ側がこれらをサポートしない場合、設定値は無視されます。"

View file

@ -1209,6 +1209,10 @@ useGroupedNotifications: "알림을 그룹화하고 표시"
signupPendingError: "메일 주소 확인중에 문제가 발생했습니다. 링크의 유효기간이 지났을 가능성이 있습니다." signupPendingError: "메일 주소 확인중에 문제가 발생했습니다. 링크의 유효기간이 지났을 가능성이 있습니다."
cwNotationRequired: "'내용을 숨기기'를 체크한 경우 주석을 써야 합니다." cwNotationRequired: "'내용을 숨기기'를 체크한 경우 주석을 써야 합니다."
doReaction: "리액션 추가" doReaction: "리액션 추가"
wellKnownWebsites: "잘 알려진 웹사이트"
wellKnownWebsitesDescription: "공백으로 구분하면 AND 지정이 되며, 개행으로 구분하면 OR 지정이 됩니다. 슬래시로 둘러싸면 정규 표현식이 됩니다. 일치하는 경우, 외부 사이트로의 리다이렉트 경고를 생략할 수 있습니다."
warningRedirectingExternalWebsiteTitle: "외부 사이트로 이동합니다"
warningRedirectingExternalWebsiteDescription: "다른 사이트로 이동하려고 합니다.\n링크가 안전한지 충분히 확인한 후 이동해주세요.\n\n{url}"
code: "문자열" code: "문자열"
reloadRequiredToApplySettings: "설정을 적용하려면 새로고침을 해야 합니다." reloadRequiredToApplySettings: "설정을 적용하려면 새로고침을 해야 합니다."
remainingN: "나머지: {n}" remainingN: "나머지: {n}"

View file

@ -1,6 +1,6 @@
{ {
"name": "misskey", "name": "misskey",
"version": "2024.3.1-host.2b", "version": "2024.3.1-host.2c",
"codename": "nasubi", "codename": "nasubi",
"repository": { "repository": {
"type": "git", "type": "git",
@ -52,19 +52,19 @@
"sharp": "0.33.2" "sharp": "0.33.2"
}, },
"dependencies": { "dependencies": {
"cssnano": "6.1.0", "cssnano": "6.1.1",
"execa": "8.0.1", "execa": "8.0.1",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"postcss": "8.4.37", "postcss": "8.4.38",
"terser": "5.29.2", "terser": "5.29.2",
"typescript": "5.4.2" "typescript": "5.4.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "20.11.30", "@types/node": "20.11.30",
"@typescript-eslint/eslint-plugin": "7.3.1", "@typescript-eslint/eslint-plugin": "7.3.1",
"@typescript-eslint/parser": "7.3.1", "@typescript-eslint/parser": "7.3.1",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"cypress": "13.7.0", "cypress": "13.7.1",
"eslint": "8.57.0", "eslint": "8.57.0",
"ncp": "2.0.0", "ncp": "2.0.0",
"start-server-and-test": "2.0.3" "start-server-and-test": "2.0.3"

View file

@ -0,0 +1,42 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class UrlPreviewMeta1710512074000 {
name = 'UrlPreviewMeta1710512074000'
async up(queryRunner) {
await queryRunner.query(`
alter table meta
rename column "summalyProxy" to "urlPreviewSummaryProxyUrl";
alter table meta
add "urlPreviewEnabled" boolean default true not null;
alter table meta
add "urlPreviewTimeout" integer default 10000 not null;
alter table meta
add "urlPreviewMaximumContentLength" bigint default 10485760 not null;
alter table meta
add "urlPreviewRequireContentLength" boolean default false not null;
alter table meta
add "urlPreviewUserAgent" varchar(1024) default null;
`);
}
async down(queryRunner) {
await queryRunner.query(`
alter table meta
rename column "urlPreviewSummaryProxyUrl" to "summalyProxy";
alter table meta
drop column "urlPreviewEnabled";
alter table meta
drop column "urlPreviewTimeout";
alter table meta
drop column "urlPreviewMaximumContentLength";
alter table meta
drop column "urlPreviewRequireContentLength";
alter table meta
drop column "urlPreviewUserAgent";
`);
}
}

View file

@ -0,0 +1,11 @@
export class ExternalWebsiteWarn1711008460816 {
name = 'ExternalWebsiteWarn1711008460816'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "wellKnownWebsites" character varying(3072) array NOT NULL DEFAULT '{}'`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "wellKnownWebsites"`);
}
}

View file

@ -78,7 +78,7 @@
"@fastify/express": "2.3.0", "@fastify/express": "2.3.0",
"@fastify/formbody": "7.4.0", "@fastify/formbody": "7.4.0",
"@fastify/http-proxy": "9.5.0", "@fastify/http-proxy": "9.5.0",
"@fastify/multipart": "8.1.0", "@fastify/multipart": "8.2.0",
"@fastify/static": "7.0.1", "@fastify/static": "7.0.1",
"@fastify/view": "9.0.0", "@fastify/view": "9.0.0",
"@misskey-dev/sharp-read-bmp": "1.2.0", "@misskey-dev/sharp-read-bmp": "1.2.0",
@ -100,7 +100,7 @@
"bcryptjs": "2.4.3", "bcryptjs": "2.4.3",
"blurhash": "2.0.5", "blurhash": "2.0.5",
"body-parser": "1.20.2", "body-parser": "1.20.2",
"bullmq": "5.4.3", "bullmq": "5.4.4",
"cacheable-lookup": "7.0.0", "cacheable-lookup": "7.0.0",
"cbor": "9.0.2", "cbor": "9.0.2",
"chalk": "5.3.0", "chalk": "5.3.0",
@ -144,7 +144,7 @@
"nested-property": "4.0.0", "nested-property": "4.0.0",
"node-fetch": "3.3.2", "node-fetch": "3.3.2",
"node-forge": "1.3.1", "node-forge": "1.3.1",
"nodemailer": "6.9.12", "nodemailer": "6.9.13",
"nsfwjs": "2.4.2", "nsfwjs": "2.4.2",
"oauth": "0.10.0", "oauth": "0.10.0",
"oauth2orize": "1.12.0", "oauth2orize": "1.12.0",
@ -154,7 +154,7 @@
"parse5": "7.1.2", "parse5": "7.1.2",
"pg": "8.11.3", "pg": "8.11.3",
"pino": "8.19.0", "pino": "8.19.0",
"pino-pretty": "10.3.1", "pino-pretty": "11.0.0",
"pkce-challenge": "4.1.0", "pkce-challenge": "4.1.0",
"probe-image-size": "7.2.3", "probe-image-size": "7.2.3",
"promise-limit": "2.7.0", "promise-limit": "2.7.0",
@ -171,7 +171,7 @@
"rss-parser": "3.13.0", "rss-parser": "3.13.0",
"rxjs": "7.8.1", "rxjs": "7.8.1",
"samlify": "2.8.11", "samlify": "2.8.11",
"sanitize-html": "2.12.1", "sanitize-html": "2.13.0",
"secure-json-parse": "2.7.0", "secure-json-parse": "2.7.0",
"sharp": "0.33.2", "sharp": "0.33.2",
"slacc": "0.0.10", "slacc": "0.0.10",
@ -183,7 +183,7 @@
"tsc-alias": "1.8.8", "tsc-alias": "1.8.8",
"tsconfig-paths": "4.2.0", "tsconfig-paths": "4.2.0",
"typeorm": "0.3.20", "typeorm": "0.3.20",
"typescript": "5.4.2", "typescript": "5.4.3",
"ulid": "2.3.0", "ulid": "2.3.0",
"vary": "1.1.2", "vary": "1.1.2",
"web-push": "3.6.7", "web-push": "3.6.7",
@ -219,7 +219,7 @@
"@types/oauth": "0.9.4", "@types/oauth": "0.9.4",
"@types/oauth2orize": "1.11.4", "@types/oauth2orize": "1.11.4",
"@types/oauth2orize-pkce": "0.1.2", "@types/oauth2orize-pkce": "0.1.2",
"@types/pg": "8.11.3", "@types/pg": "8.11.4",
"@types/pug": "2.0.10", "@types/pug": "2.0.10",
"@types/punycode": "2.1.4", "@types/punycode": "2.1.4",
"@types/qrcode": "1.5.5", "@types/qrcode": "1.5.5",

View file

@ -113,6 +113,8 @@ type Source = {
proxyRemoteFiles?: boolean; proxyRemoteFiles?: boolean;
videoThumbnailGenerator?: string; videoThumbnailGenerator?: string;
bypassRateLimit?: { header: string; value: string }[];
signToActivityPubGet?: boolean; signToActivityPubGet?: boolean;
perChannelMaxNoteCacheCount?: number; perChannelMaxNoteCacheCount?: number;
@ -205,6 +207,7 @@ export type Config = {
mediaProxy: string; mediaProxy: string;
externalMediaProxyEnabled: boolean; externalMediaProxyEnabled: boolean;
videoThumbnailGenerator: string | null; videoThumbnailGenerator: string | null;
bypassRateLimit: { header: string; value: string }[] | undefined;
redis: RedisOptions & RedisOptionsSource; redis: RedisOptions & RedisOptionsSource;
redisForPubsub: RedisOptions & RedisOptionsSource; redisForPubsub: RedisOptions & RedisOptionsSource;
redisForSystemQueue: RedisOptions & RedisOptionsSource; redisForSystemQueue: RedisOptions & RedisOptionsSource;
@ -319,6 +322,7 @@ export function loadConfig(): Config {
videoThumbnailGenerator: config.videoThumbnailGenerator ? videoThumbnailGenerator: config.videoThumbnailGenerator ?
config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator
: null, : null,
bypassRateLimit: config.bypassRateLimit,
userAgent: `Misskey/${version} (${config.url})`, userAgent: `Misskey/${version} (${config.url})`,
clientEntry: clientManifest['src/_boot_.ts'], clientEntry: clientManifest['src/_boot_.ts'],
clientManifestExists: clientManifestExists, clientManifestExists: clientManifestExists,

View file

@ -99,6 +99,7 @@ export class MetaEntityService {
imageUrl: ad.imageUrl, imageUrl: ad.imageUrl,
dayOfWeek: ad.dayOfWeek, dayOfWeek: ad.dayOfWeek,
})), })),
wellKnownWebsites: instance.wellKnownWebsites,
notesPerOneAd: instance.notesPerOneAd, notesPerOneAd: instance.notesPerOneAd,
enableEmail: instance.enableEmail, enableEmail: instance.enableEmail,
enableServiceWorker: instance.enableServiceWorker, enableServiceWorker: instance.enableServiceWorker,
@ -110,6 +111,7 @@ export class MetaEntityService {
policies: { ...DEFAULT_POLICIES, ...instance.policies }, policies: { ...DEFAULT_POLICIES, ...instance.policies },
mediaProxy: this.config.mediaProxy, mediaProxy: this.config.mediaProxy,
enableUrlPreview: instance.urlPreviewEnabled,
}; };
} }

View file

@ -272,12 +272,6 @@ export class MiMeta {
}) })
public enableSensitiveMediaDetectionForVideos: boolean; public enableSensitiveMediaDetectionForVideos: boolean;
@Column('varchar', {
length: 1024,
nullable: true,
})
public summalyProxy: string | null;
@Column('boolean', { @Column('boolean', {
default: false, default: false,
}) })
@ -512,6 +506,11 @@ export class MiMeta {
}) })
public notesPerOneAd: number; public notesPerOneAd: number;
@Column('varchar', {
length: 3072, array: true, default: '{}',
})
public wellKnownWebsites: string[];
@Column('varchar', { @Column('varchar', {
length: 3072, array: true, default: '{}', length: 3072, array: true, default: '{}',
}) })
@ -521,4 +520,36 @@ export class MiMeta {
length: 1024, array: true, default: '{}', length: 1024, array: true, default: '{}',
}) })
public featuredGameChannels: string[]; public featuredGameChannels: string[];
@Column('boolean', {
default: true,
})
public urlPreviewEnabled: boolean;
@Column('integer', {
default: 10000,
})
public urlPreviewTimeout: number;
@Column('bigint', {
default: 1024 * 1024 * 10,
})
public urlPreviewMaximumContentLength: number;
@Column('boolean', {
default: true,
})
public urlPreviewRequireContentLength: boolean;
@Column('varchar', {
length: 1024,
nullable: true,
})
public urlPreviewSummaryProxyUrl: string | null;
@Column('varchar', {
length: 1024,
nullable: true,
})
public urlPreviewUserAgent: string | null;
} }

View file

@ -183,6 +183,14 @@ export const packedMetaLiteSchema = {
}, },
}, },
}, },
wellKnownWebsites: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'string',
optional: false, nullable: false,
},
},
notesPerOneAd: { notesPerOneAd: {
type: 'number', type: 'number',
optional: false, nullable: false, optional: false, nullable: false,
@ -204,6 +212,10 @@ export const packedMetaLiteSchema = {
type: 'string', type: 'string',
optional: false, nullable: false, optional: false, nullable: false,
}, },
enableUrlPreview: {
type: 'boolean',
optional: false, nullable: false,
},
backgroundImageUrl: { backgroundImageUrl: {
type: 'string', type: 'string',
optional: false, nullable: true, optional: false, nullable: true,

View file

@ -18,6 +18,7 @@ import { createTemp } from '@/misc/create-temp.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { RoleService } from '@/core/RoleService.js'; import { RoleService } from '@/core/RoleService.js';
import { IdentifiableError } from '@/misc/identifiable-error.js'; import { IdentifiableError } from '@/misc/identifiable-error.js';
import type { Config } from '@/config.js';
import { ApiError } from './error.js'; import { ApiError } from './error.js';
import { RateLimiterService } from './RateLimiterService.js'; import { RateLimiterService } from './RateLimiterService.js';
import { ApiLoggerService } from './ApiLoggerService.js'; import { ApiLoggerService } from './ApiLoggerService.js';
@ -39,6 +40,8 @@ export class ApiCallService implements OnApplicationShutdown {
private userIpHistoriesClearIntervalId: NodeJS.Timeout; private userIpHistoriesClearIntervalId: NodeJS.Timeout;
constructor( constructor(
@Inject(DI.config)
private config: Config,
@Inject(DI.userIpsRepository) @Inject(DI.userIpsRepository)
private userIpsRepository: UserIpsRepository, private userIpsRepository: UserIpsRepository,
@ -243,7 +246,8 @@ export class ApiCallService implements OnApplicationShutdown {
throw new ApiError(accessDenied); throw new ApiError(accessDenied);
} }
if (ep.meta.limit) { const bypassRateLimit = this.config.bypassRateLimit?.some(({ header, value }) => request.headers[header] === value) ?? false;
if (ep.meta.limit && !bypassRateLimit) {
// koa will automatically load the `X-Forwarded-For` header if `proxy: true` is configured in the app. // koa will automatically load the `X-Forwarded-For` header if `proxy: true` is configured in the app.
let limitActor: string; let limitActor: string;
if (user) { if (user) {

View file

@ -325,9 +325,17 @@ export const meta = {
type: 'number', type: 'number',
optional: false, nullable: false, optional: false, nullable: false,
}, },
wellKnownWebsites: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'string',
optional: false, nullable: false,
},
},
urlPreviewDenyList: { urlPreviewDenyList: {
type: 'array', type: 'array',
optional: true, nullable: false, optional: false, nullable: false,
items: { items: {
type: 'string', type: 'string',
optional: false, nullable: false, optional: false, nullable: false,
@ -399,6 +407,8 @@ export const meta = {
summalyProxy: { summalyProxy: {
type: 'string', type: 'string',
optional: false, nullable: true, optional: false, nullable: true,
deprecated: true,
description: '[Deprecated] Use "urlPreviewSummaryProxyUrl" instead.',
}, },
themeColor: { themeColor: {
type: 'string', type: 'string',
@ -416,6 +426,30 @@ export const meta = {
type: 'string', type: 'string',
optional: false, nullable: false, optional: false, nullable: false,
}, },
urlPreviewEnabled: {
type: 'boolean',
optional: false, nullable: false,
},
urlPreviewTimeout: {
type: 'number',
optional: false, nullable: false,
},
urlPreviewMaximumContentLength: {
type: 'number',
optional: false, nullable: false,
},
urlPreviewRequireContentLength: {
type: 'boolean',
optional: false, nullable: false,
},
urlPreviewUserAgent: {
type: 'string',
optional: false, nullable: true,
},
urlPreviewSummaryProxyUrl: {
type: 'string',
optional: false, nullable: true,
},
}, },
}, },
} as const; } as const;
@ -497,7 +531,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
setSensitiveFlagAutomatically: instance.setSensitiveFlagAutomatically, setSensitiveFlagAutomatically: instance.setSensitiveFlagAutomatically,
enableSensitiveMediaDetectionForVideos: instance.enableSensitiveMediaDetectionForVideos, enableSensitiveMediaDetectionForVideos: instance.enableSensitiveMediaDetectionForVideos,
proxyAccountId: instance.proxyAccountId, proxyAccountId: instance.proxyAccountId,
summalyProxy: instance.summalyProxy,
email: instance.email, email: instance.email,
smtpSecure: instance.smtpSecure, smtpSecure: instance.smtpSecure,
smtpHost: instance.smtpHost, smtpHost: instance.smtpHost,
@ -527,9 +560,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
perRemoteUserUserTimelineCacheMax: instance.perRemoteUserUserTimelineCacheMax, perRemoteUserUserTimelineCacheMax: instance.perRemoteUserUserTimelineCacheMax,
perUserHomeTimelineCacheMax: instance.perUserHomeTimelineCacheMax, perUserHomeTimelineCacheMax: instance.perUserHomeTimelineCacheMax,
perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax, perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax,
wellKnownWebsites: instance.wellKnownWebsites,
notesPerOneAd: instance.notesPerOneAd, notesPerOneAd: instance.notesPerOneAd,
urlPreviewDenyList: instance.urlPreviewDenyList, urlPreviewDenyList: instance.urlPreviewDenyList,
featuredGameChannels: instance.featuredGameChannels, featuredGameChannels: instance.featuredGameChannels,
summalyProxy: instance.urlPreviewSummaryProxyUrl,
urlPreviewEnabled: instance.urlPreviewEnabled,
urlPreviewTimeout: instance.urlPreviewTimeout,
urlPreviewMaximumContentLength: instance.urlPreviewMaximumContentLength,
urlPreviewRequireContentLength: instance.urlPreviewRequireContentLength,
urlPreviewUserAgent: instance.urlPreviewUserAgent,
urlPreviewSummaryProxyUrl: instance.urlPreviewSummaryProxyUrl,
}; };
}); });
} }

View file

@ -88,7 +88,6 @@ export const paramDef = {
type: 'string', type: 'string',
}, },
}, },
summalyProxy: { type: 'string', nullable: true },
deeplAuthKey: { type: 'string', nullable: true }, deeplAuthKey: { type: 'string', nullable: true },
deeplIsPro: { type: 'boolean' }, deeplIsPro: { type: 'boolean' },
enableEmail: { type: 'boolean' }, enableEmail: { type: 'boolean' },
@ -140,6 +139,11 @@ export const paramDef = {
type: 'string', type: 'string',
}, },
}, },
wellKnownWebsites: {
type: 'array', nullable: true, items: {
type: 'string',
},
},
urlPreviewDenyList: { urlPreviewDenyList: {
type: 'array', nullable: true, items: { type: 'array', nullable: true, items: {
type: 'string', type: 'string',
@ -150,6 +154,16 @@ export const paramDef = {
type: 'string', type: 'string',
}, },
}, },
summalyProxy: {
type: 'string', nullable: true,
description: '[Deprecated] Use "urlPreviewSummaryProxyUrl" instead.',
},
urlPreviewEnabled: { type: 'boolean' },
urlPreviewTimeout: { type: 'integer' },
urlPreviewMaximumContentLength: { type: 'integer' },
urlPreviewRequireContentLength: { type: 'boolean' },
urlPreviewUserAgent: { type: 'string', nullable: true },
urlPreviewSummaryProxyUrl: { type: 'string', nullable: true },
}, },
required: [], required: [],
} as const; } as const;
@ -205,6 +219,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}).map(x => x.toLowerCase()); }).map(x => x.toLowerCase());
} }
if (Array.isArray(ps.wellKnownWebsites)) {
set.wellKnownWebsites = ps.wellKnownWebsites.filter(Boolean);
}
if (Array.isArray(ps.urlPreviewDenyList)) { if (Array.isArray(ps.urlPreviewDenyList)) {
set.urlPreviewDenyList = ps.urlPreviewDenyList.filter(Boolean); set.urlPreviewDenyList = ps.urlPreviewDenyList.filter(Boolean);
} }
@ -365,10 +383,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.langs = ps.langs.filter(Boolean); set.langs = ps.langs.filter(Boolean);
} }
if (ps.summalyProxy !== undefined) {
set.summalyProxy = ps.summalyProxy;
}
if (ps.enableEmail !== undefined) { if (ps.enableEmail !== undefined) {
set.enableEmail = ps.enableEmail; set.enableEmail = ps.enableEmail;
} }
@ -541,6 +555,32 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.bannedEmailDomains = ps.bannedEmailDomains; set.bannedEmailDomains = ps.bannedEmailDomains;
} }
if (ps.urlPreviewEnabled !== undefined) {
set.urlPreviewEnabled = ps.urlPreviewEnabled;
}
if (ps.urlPreviewTimeout !== undefined) {
set.urlPreviewTimeout = ps.urlPreviewTimeout;
}
if (ps.urlPreviewMaximumContentLength !== undefined) {
set.urlPreviewMaximumContentLength = ps.urlPreviewMaximumContentLength;
}
if (ps.urlPreviewRequireContentLength !== undefined) {
set.urlPreviewRequireContentLength = ps.urlPreviewRequireContentLength;
}
if (ps.urlPreviewUserAgent !== undefined) {
const value = (ps.urlPreviewUserAgent ?? '').trim();
set.urlPreviewUserAgent = value === '' ? null : ps.urlPreviewUserAgent;
}
if (ps.summalyProxy !== undefined || ps.urlPreviewSummaryProxyUrl !== undefined) {
const value = ((ps.urlPreviewSummaryProxyUrl ?? ps.summalyProxy) ?? '').trim();
set.urlPreviewSummaryProxyUrl = value === '' ? null : value;
}
const before = await this.metaService.fetch(true); const before = await this.metaService.fetch(true);
await this.metaService.update(set); await this.metaService.update(set);

View file

@ -172,7 +172,9 @@ export class JWTIdentifyProviderService {
const roles = await this.roleService.getUserRoles(user.id); const roles = await this.roleService.getUserRoles(user.id);
const payload: JWTPayload = { const payload: JWTPayload = {
name: user.name ?? user.username, name: user.name ? `${user.name} (@${user.username})` : `@${user.username}`,
given_name: user.name ?? undefined,
family_name: `@${user.username}`,
preferred_username: user.username, preferred_username: user.username,
profile: `${this.config.url}/@${user.username}`, profile: `${this.config.url}/@${user.username}`,
picture: user.avatarUrl ?? undefined, picture: user.avatarUrl ?? undefined,

View file

@ -492,20 +492,28 @@ export class SAMLIdentifyProviderService {
'#text': user.id, '#text': user.id,
}, },
}, },
{ ...(user.name ? [{
'@Name': 'displayname', '@Name': 'firstName',
'@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', '@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic',
'saml:AttributeValue': { 'saml:AttributeValue': {
'@xsi:type': 'xs:string', '@xsi:type': 'xs:string',
'#text': user.name ?? user.username, '#text': user.name,
},
}] : []),
{
'@Name': 'lastName',
'@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic',
'saml:AttributeValue': {
'@xsi:type': 'xs:string',
'#text': `@${user.username}`,
}, },
}, },
{ {
'@Name': 'name', '@Name': 'displayName',
'@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', '@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic',
'saml:AttributeValue': { 'saml:AttributeValue': {
'@xsi:type': 'xs:string', '@xsi:type': 'xs:string',
'#text': user.username, '#text': user.name ? `${user.name} (@${user.username})` : `@${user.username}`,
}, },
}, },
{ {

View file

@ -4,8 +4,9 @@
*/ */
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { summaly } from '@misskey-dev/summaly';
import RE2 from 're2'; import RE2 from 're2';
import { summaly } from '@misskey-dev/summaly';
import { SummalyResult } from '@misskey-dev/summaly/built/summary.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js'; import type { Config } from '@/config.js';
import { MetaService } from '@/core/MetaService.js'; import { MetaService } from '@/core/MetaService.js';
@ -15,6 +16,7 @@ import { query } from '@/misc/prelude/url.js';
import { LoggerService } from '@/core/LoggerService.js'; import { LoggerService } from '@/core/LoggerService.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
import { MiMeta } from '@/models/Meta.js';
import type { FastifyRequest, FastifyReply } from 'fastify'; import type { FastifyRequest, FastifyReply } from 'fastify';
@Injectable() @Injectable()
@ -63,24 +65,25 @@ export class UrlPreviewService {
const meta = await this.metaService.fetch(); const meta = await this.metaService.fetch();
this.logger.info(meta.summalyProxy if (!meta.urlPreviewEnabled) {
reply.code(403);
return {
error: new ApiError({
message: 'URL preview is disabled',
code: 'URL_PREVIEW_DISABLED',
id: '58b36e13-d2f5-0323-b0c6-76aa9dabefb8',
}),
};
}
this.logger.info(meta.urlPreviewSummaryProxyUrl
? `(Proxy) Getting preview of ${url}@${lang} ...` ? `(Proxy) Getting preview of ${url}@${lang} ...`
: `Getting preview of ${url}@${lang} ...`); : `Getting preview of ${url}@${lang} ...`);
try { try {
const summary = meta.summalyProxy ? const summary = meta.urlPreviewSummaryProxyUrl
await this.httpRequestService.getJson<ReturnType<typeof summaly>>(`${meta.summalyProxy}?${query({ ? await this.fetchSummaryFromProxy(url, meta, lang)
url: url, : await this.fetchSummary(url, meta, lang);
lang: lang ?? 'ja-JP',
})}`)
:
await summaly(url, {
followRedirects: false,
lang: lang ?? 'ja-JP',
agent: this.config.proxy ? {
http: this.httpRequestService.httpAgent,
https: this.httpRequestService.httpsAgent,
} : undefined,
});
this.logger.succ(`Got preview of ${url}: ${summary.title}`); this.logger.succ(`Got preview of ${url}: ${summary.title}`);
@ -118,6 +121,7 @@ export class UrlPreviewService {
return summary; return summary;
} catch (err) { } catch (err) {
this.logger.warn(`Failed to get preview of ${url}: ${err}`); this.logger.warn(`Failed to get preview of ${url}: ${err}`);
reply.code(422); reply.code(422);
reply.header('Cache-Control', 'max-age=86400, immutable'); reply.header('Cache-Control', 'max-age=86400, immutable');
return { return {
@ -129,4 +133,37 @@ export class UrlPreviewService {
}; };
} }
} }
private fetchSummary(url: string, meta: MiMeta, lang?: string): Promise<SummalyResult> {
const agent = this.config.proxy
? {
http: this.httpRequestService.httpAgent,
https: this.httpRequestService.httpsAgent,
}
: undefined;
return summaly(url, {
followRedirects: false,
lang: lang ?? 'ja-JP',
agent: agent,
userAgent: meta.urlPreviewUserAgent ?? undefined,
operationTimeout: meta.urlPreviewTimeout,
contentLengthLimit: meta.urlPreviewMaximumContentLength,
contentLengthRequired: meta.urlPreviewRequireContentLength,
});
}
private fetchSummaryFromProxy(url: string, meta: MiMeta, lang?: string): Promise<SummalyResult> {
const proxy = meta.urlPreviewSummaryProxyUrl!;
const queryStr = query({
url: url,
lang: lang ?? 'ja-JP',
userAgent: meta.urlPreviewUserAgent ?? undefined,
operationTimeout: meta.urlPreviewTimeout,
contentLengthLimit: meta.urlPreviewMaximumContentLength,
contentLengthRequired: meta.urlPreviewRequireContentLength,
});
return this.httpRequestService.getJson<SummalyResult>(`${proxy}?${queryStr}`);
}
} }

View file

@ -41,7 +41,7 @@
"chartjs-chart-matrix": "2.0.1", "chartjs-chart-matrix": "2.0.1",
"chartjs-plugin-gradient": "0.6.1", "chartjs-plugin-gradient": "0.6.1",
"chartjs-plugin-zoom": "2.0.1", "chartjs-plugin-zoom": "2.0.1",
"chromatic": "11.1.1", "chromatic": "11.2.0",
"compare-versions": "6.1.0", "compare-versions": "6.1.0",
"cropperjs": "2.0.0-beta.4", "cropperjs": "2.0.0-beta.4",
"date-fns": "3.6.0", "date-fns": "3.6.0",
@ -60,7 +60,7 @@
"photoswipe": "5.4.3", "photoswipe": "5.4.3",
"punycode": "2.3.1", "punycode": "2.3.1",
"rollup": "4.13.0", "rollup": "4.13.0",
"sanitize-html": "2.12.1", "sanitize-html": "2.13.0",
"sass": "1.72.0", "sass": "1.72.0",
"shiki": "1.2.0", "shiki": "1.2.0",
"strict-event-emitter-types": "2.0.0", "strict-event-emitter-types": "2.0.0",
@ -70,34 +70,34 @@
"tinycolor2": "1.6.0", "tinycolor2": "1.6.0",
"tsc-alias": "1.8.8", "tsc-alias": "1.8.8",
"tsconfig-paths": "4.2.0", "tsconfig-paths": "4.2.0",
"typescript": "5.4.2", "typescript": "5.4.3",
"uuid": "9.0.1", "uuid": "9.0.1",
"v-code-diff": "1.10.0", "v-code-diff": "1.11.0",
"vite": "5.1.6", "vite": "5.2.2",
"vue": "3.4.15", "vue": "3.4.15",
"vuedraggable": "next" "vuedraggable": "next"
}, },
"devDependencies": { "devDependencies": {
"@misskey-dev/eslint-plugin": "1.0.0", "@misskey-dev/eslint-plugin": "1.0.0",
"@misskey-dev/summaly": "5.1.0", "@misskey-dev/summaly": "5.1.0",
"@storybook/addon-actions": "8.0.2", "@storybook/addon-actions": "8.0.4",
"@storybook/addon-essentials": "8.0.2", "@storybook/addon-essentials": "8.0.4",
"@storybook/addon-interactions": "8.0.2", "@storybook/addon-interactions": "8.0.4",
"@storybook/addon-links": "8.0.2", "@storybook/addon-links": "8.0.4",
"@storybook/addon-mdx-gfm": "8.0.2", "@storybook/addon-mdx-gfm": "8.0.4",
"@storybook/addon-storysource": "8.0.2", "@storybook/addon-storysource": "8.0.4",
"@storybook/blocks": "8.0.2", "@storybook/blocks": "8.0.4",
"@storybook/components": "8.0.2", "@storybook/components": "8.0.4",
"@storybook/core-events": "8.0.2", "@storybook/core-events": "8.0.4",
"@storybook/manager-api": "8.0.2", "@storybook/manager-api": "8.0.4",
"@storybook/preview-api": "8.0.2", "@storybook/preview-api": "8.0.4",
"@storybook/react": "8.0.2", "@storybook/react": "8.0.4",
"@storybook/react-vite": "8.0.2", "@storybook/react-vite": "8.0.4",
"@storybook/test": "8.0.2", "@storybook/test": "8.0.4",
"@storybook/theming": "8.0.2", "@storybook/theming": "8.0.4",
"@storybook/types": "8.0.2", "@storybook/types": "8.0.4",
"@storybook/vue3": "8.0.2", "@storybook/vue3": "8.0.4",
"@storybook/vue3-vite": "8.0.2", "@storybook/vue3-vite": "8.0.4",
"@testing-library/vue": "8.0.3", "@testing-library/vue": "8.0.3",
"@types/escape-regexp": "0.0.3", "@types/escape-regexp": "0.0.3",
"@types/estree": "1.0.5", "@types/estree": "1.0.5",
@ -116,7 +116,7 @@
"@vue/runtime-core": "3.4.15", "@vue/runtime-core": "3.4.15",
"acorn": "8.11.3", "acorn": "8.11.3",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"cypress": "13.7.0", "cypress": "13.7.1",
"eslint": "8.57.0", "eslint": "8.57.0",
"eslint-plugin-import": "2.29.1", "eslint-plugin-import": "2.29.1",
"eslint-plugin-vue": "9.23.0", "eslint-plugin-vue": "9.23.0",
@ -131,13 +131,13 @@
"react": "18.2.0", "react": "18.2.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"start-server-and-test": "2.0.3", "start-server-and-test": "2.0.3",
"storybook": "8.0.2", "storybook": "8.0.4",
"storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme", "storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme",
"vite-plugin-turbosnap": "1.0.3", "vite-plugin-turbosnap": "1.0.3",
"vitest": "0.34.6", "vitest": "0.34.6",
"vitest-fetch-mock": "0.2.2", "vitest-fetch-mock": "0.2.2",
"vue-component-type-helpers": "2.0.6", "vue-component-type-helpers": "2.0.7",
"vue-eslint-parser": "9.4.2", "vue-eslint-parser": "9.4.2",
"vue-tsc": "2.0.6" "vue-tsc": "2.0.7"
} }
} }

View file

@ -5,8 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<component <component
:is="self ? 'MkA' : 'a'" ref="el" style="word-break: break-all;" class="_link" :[attr]="self ? url.substring(local.length) : url" :rel="rel ?? 'nofollow noopener'" :target="target" :is="self ? 'MkA' : 'a'"
ref="el"
style="word-break: break-all;"
class="_link"
:[attr]="self ? url.substring(local.length) : url"
:rel="rel ?? 'nofollow noopener'"
:target="target"
:title="url" :title="url"
@click="(ev: MouseEvent) => warningExternalWebsite(ev, url)"
> >
<slot></slot> <slot></slot>
<i v-if="target === '_blank'" class="ti ti-external-link" :class="$style.icon"></i> <i v-if="target === '_blank'" class="ti ti-external-link" :class="$style.icon"></i>
@ -17,7 +24,9 @@ SPDX-License-Identifier: AGPL-3.0-only
import { defineAsyncComponent, ref } from 'vue'; import { defineAsyncComponent, ref } from 'vue';
import { url as local } from '@/config.js'; import { url as local } from '@/config.js';
import { useTooltip } from '@/scripts/use-tooltip.js'; import { useTooltip } from '@/scripts/use-tooltip.js';
import { warningExternalWebsite } from '@/scripts/warning-external-website.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { isEnabledUrlPreview } from '@/instance.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
url: string; url: string;
@ -31,13 +40,15 @@ const target = self ? null : '_blank';
const el = ref<HTMLElement | { $el: HTMLElement }>(); const el = ref<HTMLElement | { $el: HTMLElement }>();
useTooltip(el, (showing) => { if (isEnabledUrlPreview.value) {
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), { useTooltip(el, (showing) => {
showing, os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
url: props.url, showing,
source: el.value instanceof HTMLElement ? el.value : el.value?.$el, url: props.url,
}, {}, 'closed'); source: el.value instanceof HTMLElement ? el.value : el.value?.$el,
}); }, {}, 'closed');
});
}
</script> </script>
<style lang="scss" module> <style lang="scss" module>

View file

@ -82,7 +82,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkMediaList :mediaList="appearNote.files"/> <MkMediaList :mediaList="appearNote.files"/>
</div> </div>
<MkPoll v-if="appearNote.poll" :noteId="appearNote.id" :poll="appearNote.poll" :class="$style.poll"/> <MkPoll v-if="appearNote.poll" :noteId="appearNote.id" :poll="appearNote.poll" :class="$style.poll"/>
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="false" :class="$style.urlPreview"/> <div v-if="isEnabledUrlPreview">
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="false" :class="$style.urlPreview"/>
</div>
<div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div> <div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
<button v-if="isLong && collapsed" :class="$style.collapsed" class="_button" @click="collapsed = false"> <button v-if="isLong && collapsed" :class="$style.collapsed" class="_button" @click="collapsed = false">
<span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span> <span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span>
@ -189,6 +191,7 @@ import { MenuItem } from '@/types/menu.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue'; import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { showMovedDialog } from '@/scripts/show-moved-dialog.js'; import { showMovedDialog } from '@/scripts/show-moved-dialog.js';
import { shouldCollapsed } from '@/scripts/collapsed.js'; import { shouldCollapsed } from '@/scripts/collapsed.js';
import { isEnabledUrlPreview } from '@/instance.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
note: Misskey.entities.Note; note: Misskey.entities.Note;

View file

@ -95,7 +95,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkMediaList :mediaList="appearNote.files"/> <MkMediaList :mediaList="appearNote.files"/>
</div> </div>
<MkPoll v-if="appearNote.poll" ref="pollViewer" :noteId="appearNote.id" :poll="appearNote.poll" :class="$style.poll"/> <MkPoll v-if="appearNote.poll" ref="pollViewer" :noteId="appearNote.id" :poll="appearNote.poll" :class="$style.poll"/>
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="true" style="margin-top: 6px;"/> <div v-if="isEnabledUrlPreview">
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="true" style="margin-top: 6px;"/>
</div>
<div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div> <div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
</div> </div>
<MkA v-if="appearNote.channel && !inChannel" :class="$style.channel" :to="`/channels/${appearNote.channel.id}`"><i class="ti ti-device-tv"></i> {{ appearNote.channel.name }}</MkA> <MkA v-if="appearNote.channel && !inChannel" :class="$style.channel" :to="`/channels/${appearNote.channel.id}`"><i class="ti ti-device-tv"></i> {{ appearNote.channel.name }}</MkA>
@ -229,6 +231,7 @@ import MkUserCardMini from '@/components/MkUserCardMini.vue';
import MkPagination, { type Paging } from '@/components/MkPagination.vue'; import MkPagination, { type Paging } from '@/components/MkPagination.vue';
import MkReactionIcon from '@/components/MkReactionIcon.vue'; import MkReactionIcon from '@/components/MkReactionIcon.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { isEnabledUrlPreview } from '@/instance.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
note: Misskey.entities.Note; note: Misskey.entities.Note;

View file

@ -44,7 +44,15 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
</template> </template>
<div v-else> <div v-else>
<component :is="self ? 'MkA' : 'a'" :class="[$style.link, { [$style.compact]: compact }]" :[attr]="self ? url.substring(local.length) : url" rel="nofollow noopener" :target="target" :title="url"> <component
:is="self ? 'MkA' : 'a'"
:class="[$style.link, { [$style.compact]: compact }]"
:[attr]="self ? url.substring(local.length) : url"
rel="nofollow noopener"
:target="target"
:title="url"
@click="(ev: MouseEvent) => warningExternalWebsite(ev, url)"
>
<div v-if="thumbnail" :class="[$style.thumbnail, { [$style.thumbnailBlur]: sensitive }]" :style="defaultStore.state.dataSaver.urlPreview ? '' : `background-image: url('${thumbnail}')`"> <div v-if="thumbnail" :class="[$style.thumbnail, { [$style.thumbnailBlur]: sensitive }]" :style="defaultStore.state.dataSaver.urlPreview ? '' : `background-image: url('${thumbnail}')`">
</div> </div>
<article :class="$style.body"> <article :class="$style.body">
@ -92,6 +100,7 @@ import { deviceKind } from '@/scripts/device-kind.js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { versatileLang } from '@/scripts/intl-const.js'; import { versatileLang } from '@/scripts/intl-const.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { warningExternalWebsite } from '@/scripts/warning-external-website.js';
type SummalyResult = Awaited<ReturnType<typeof summaly>>; type SummalyResult = Awaited<ReturnType<typeof summaly>>;
@ -152,15 +161,16 @@ requestUrl.hash = '';
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`) window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`)
.then(res => { .then(res => {
if (!res.ok) { if (!res.ok) {
fetching.value = false; if (_DEV_) {
unknownUrl.value = true; console.warn(`[HTTP${res.status}] Failed to fetch url preview`);
return; }
return null;
} }
return res.json(); return res.json();
}) })
.then((info: SummalyResult) => { .then((info: SummalyResult | null) => {
if (info.url == null) { if (!info || info.url == null) {
fetching.value = false; fetching.value = false;
unknownUrl.value = true; unknownUrl.value = true;
return; return;

View file

@ -5,7 +5,14 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<component <component
:is="self ? 'MkA' : 'a'" ref="el" :class="$style.root" class="_link" :[attr]="self ? props.url.substring(local.length) : props.url" :rel="rel ?? 'nofollow noopener'" :target="target" :is="self ? 'MkA' : 'a'"
ref="el"
:class="$style.root"
class="_link"
:[attr]="self ? props.url.substring(local.length) : props.url"
:rel="rel ?? 'nofollow noopener'"
:target="target"
@click="(ev: MouseEvent) => warningExternalWebsite(ev, props.url)"
@contextmenu.stop="() => {}" @contextmenu.stop="() => {}"
> >
<template v-if="!self"> <template v-if="!self">
@ -30,6 +37,8 @@ import { url as local } from '@/config.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { useTooltip } from '@/scripts/use-tooltip.js'; import { useTooltip } from '@/scripts/use-tooltip.js';
import { safeURIDecode } from '@/scripts/safe-uri-decode.js'; import { safeURIDecode } from '@/scripts/safe-uri-decode.js';
import { warningExternalWebsite } from '@/scripts/warning-external-website.js';
import { isEnabledUrlPreview } from '@/instance.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
url: string; url: string;
@ -44,7 +53,7 @@ const url = new URL(props.url);
if (!['http:', 'https:'].includes(url.protocol)) throw new Error('invalid url'); if (!['http:', 'https:'].includes(url.protocol)) throw new Error('invalid url');
const el = ref(); const el = ref();
if (props.showUrlPreview) { if (props.showUrlPreview && isEnabledUrlPreview.value) {
useTooltip(el, (showing) => { useTooltip(el, (showing) => {
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), { os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
showing, showing,

View file

@ -6,7 +6,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<div class="_gaps" :class="$style.textRoot"> <div class="_gaps" :class="$style.textRoot">
<Mfm :text="block.text ?? ''" :isNote="false"/> <Mfm :text="block.text ?? ''" :isNote="false"/>
<MkUrlPreview v-for="url in urls" :key="url" :url="url"/> <div v-if="isEnabledUrlPreview">
<MkUrlPreview v-for="url in urls" :key="url" :url="url"/>
</div>
</div> </div>
</template> </template>
@ -15,6 +17,7 @@ import { defineAsyncComponent } from 'vue';
import * as mfm from 'mfm-js'; import * as mfm from 'mfm-js';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js'; import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js';
import { isEnabledUrlPreview } from '@/instance.js';
const MkUrlPreview = defineAsyncComponent(() => import('@/components/MkUrlPreview.vue')); const MkUrlPreview = defineAsyncComponent(() => import('@/components/MkUrlPreview.vue'));

View file

@ -36,6 +36,8 @@ export const infoImageUrl = computed(() => instance.infoImageUrl ?? DEFAULT_INFO
export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL); export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL);
export const isEnabledUrlPreview = computed(() => instance.enableUrlPreview ?? true);
export async function fetchInstance(force = false): Promise<void> { export async function fetchInstance(force = false): Promise<void> {
if (!force) { if (!force) {
const cachedAt = miLocalStorage.getItem('instanceCachedAt') ? parseInt(miLocalStorage.getItem('instanceCachedAt')!) : 0; const cachedAt = miLocalStorage.getItem('instanceCachedAt') ? parseInt(miLocalStorage.getItem('instanceCachedAt')!) : 0;

View file

@ -46,7 +46,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #key>{{ i18n.ts.email }}</template> <template #key>{{ i18n.ts.email }}</template>
<template #value><span class="_monospace">{{ info.email }}</span></template> <template #value><span class="_monospace">{{ info.email }}</span></template>
</MkKeyValue> </MkKeyValue>
<MkKeyValue v-if="ips.length > 0" :copy="user.id" oneline> <MkKeyValue v-if="ips.length > 0" :copy="ips[0].ip" oneline>
<template #key>IP (recent)</template> <template #key>IP (recent)</template>
<template #value><span class="_monospace">{{ ips[0].ip }}</span></template> <template #value><span class="_monospace">{{ ips[0].ip }}</span></template>
</MkKeyValue> </MkKeyValue>

View file

@ -45,6 +45,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #caption>{{ i18n.ts.prohibitedWordsDescription }}<br>{{ i18n.ts.prohibitedWordsDescription2 }}</template> <template #caption>{{ i18n.ts.prohibitedWordsDescription }}<br>{{ i18n.ts.prohibitedWordsDescription2 }}</template>
</MkTextarea> </MkTextarea>
<MkTextarea v-model="wellKnownWebsites">
<template #label>{{ i18n.ts.wellKnownWebsites }}</template>
<template #caption>{{ i18n.ts.wellKnownWebsitesDescription }}</template>
</MkTextarea>
<MkTextarea v-model="urlPreviewDenyList"> <MkTextarea v-model="urlPreviewDenyList">
<template #label>{{ i18n.ts.urlPreviewDenyList }}</template> <template #label>{{ i18n.ts.urlPreviewDenyList }}</template>
<template #caption>{{ i18n.ts.urlPreviewDenyListDescription }}</template> <template #caption>{{ i18n.ts.urlPreviewDenyListDescription }}</template>
@ -91,7 +96,8 @@ const hiddenTags = ref<string>('');
const preservedUsernames = ref<string>(''); const preservedUsernames = ref<string>('');
const tosUrl = ref<string | null>(null); const tosUrl = ref<string | null>(null);
const privacyPolicyUrl = ref<string | null>(null); const privacyPolicyUrl = ref<string | null>(null);
const urlPreviewDenyList = ref<string | undefined>(''); const wellKnownWebsites = ref<string>('');
const urlPreviewDenyList = ref<string>('');
async function init() { async function init() {
const meta = await misskeyApi('admin/meta'); const meta = await misskeyApi('admin/meta');
@ -103,7 +109,8 @@ async function init() {
preservedUsernames.value = meta.preservedUsernames.join('\n'); preservedUsernames.value = meta.preservedUsernames.join('\n');
tosUrl.value = meta.tosUrl; tosUrl.value = meta.tosUrl;
privacyPolicyUrl.value = meta.privacyPolicyUrl; privacyPolicyUrl.value = meta.privacyPolicyUrl;
urlPreviewDenyList.value = meta.urlPreviewDenyList?.join('\n'); wellKnownWebsites.value = meta.wellKnownWebsites.join('\n');
urlPreviewDenyList.value = meta.urlPreviewDenyList.join('\n');
} }
function save() { function save() {
@ -116,7 +123,8 @@ function save() {
prohibitedWords: prohibitedWords.value.split('\n'), prohibitedWords: prohibitedWords.value.split('\n'),
hiddenTags: hiddenTags.value.split('\n'), hiddenTags: hiddenTags.value.split('\n'),
preservedUsernames: preservedUsernames.value.split('\n'), preservedUsernames: preservedUsernames.value.split('\n'),
urlPreviewDenyList: urlPreviewDenyList.value?.split('\n'), wellKnownWebsites: wellKnownWebsites.value.split('\n'),
urlPreviewDenyList: urlPreviewDenyList.value.split('\n'),
}).then(() => { }).then(() => {
fetchInstance(true); fetchInstance(true);
}); });

View file

@ -119,19 +119,6 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
</MkFolder> </MkFolder>
<MkFolder>
<template #label>Summaly Proxy</template>
<div class="_gaps_m">
<MkInput v-model="summalyProxy">
<template #prefix><i class="ti ti-link"></i></template>
<template #label>Summaly Proxy URL</template>
</MkInput>
<MkButton primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
</div>
</MkFolder>
<MkFolder> <MkFolder>
<template #label>IndieAuth Clients</template> <template #label>IndieAuth Clients</template>
@ -260,7 +247,6 @@ import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
const summalyProxy = ref<string | null>('');
const enableHcaptcha = ref<boolean>(false); const enableHcaptcha = ref<boolean>(false);
const enableMcaptcha = ref<boolean>(false); const enableMcaptcha = ref<boolean>(false);
const enableRecaptcha = ref<boolean>(false); const enableRecaptcha = ref<boolean>(false);
@ -288,7 +274,6 @@ const ssoServiceHasMore = ref(false);
async function init() { async function init() {
const meta = await misskeyApi('admin/meta'); const meta = await misskeyApi('admin/meta');
summalyProxy.value = meta.summalyProxy;
enableHcaptcha.value = meta.enableHcaptcha; enableHcaptcha.value = meta.enableHcaptcha;
enableMcaptcha.value = meta.enableMcaptcha; enableMcaptcha.value = meta.enableMcaptcha;
enableRecaptcha.value = meta.enableRecaptcha; enableRecaptcha.value = meta.enableRecaptcha;
@ -314,7 +299,6 @@ async function init() {
function save() { function save() {
os.apiWithDialog('admin/update-meta', { os.apiWithDialog('admin/update-meta', {
summalyProxy: summalyProxy.value === '' ? null : summalyProxy.value,
sensitiveMediaDetection: sensitiveMediaDetection.value as 'none' | 'all' | 'local' | 'remote', sensitiveMediaDetection: sensitiveMediaDetection.value as 'none' | 'all' | 'local' | 'remote',
sensitiveMediaDetectionSensitivity: sensitiveMediaDetectionSensitivity:
sensitiveMediaDetectionSensitivity.value === 0 ? 'veryLow' : sensitiveMediaDetectionSensitivity.value === 0 ? 'veryLow' :

View file

@ -120,6 +120,53 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
</div> </div>
</FormSection> </FormSection>
<FormSection>
<template #label>{{ i18n.ts._urlPreviewSetting.title }}</template>
<div class="_gaps_m">
<MkSwitch v-model="urlPreviewEnabled">
<template #label>{{ i18n.ts._urlPreviewSetting.enable }}</template>
</MkSwitch>
<MkSwitch v-model="urlPreviewRequireContentLength">
<template #label>{{ i18n.ts._urlPreviewSetting.requireContentLength }}</template>
<template #caption>{{ i18n.ts._urlPreviewSetting.requireContentLengthDescription }}</template>
</MkSwitch>
<MkInput v-model="urlPreviewMaximumContentLength" type="number">
<template #label>{{ i18n.ts._urlPreviewSetting.maximumContentLength }}</template>
<template #caption>{{ i18n.ts._urlPreviewSetting.maximumContentLengthDescription }}</template>
</MkInput>
<MkInput v-model="urlPreviewTimeout" type="number">
<template #label>{{ i18n.ts._urlPreviewSetting.timeout }}</template>
<template #caption>{{ i18n.ts._urlPreviewSetting.timeoutDescription }}</template>
</MkInput>
<MkInput v-model="urlPreviewUserAgent" type="text">
<template #label>{{ i18n.ts._urlPreviewSetting.userAgent }}</template>
<template #caption>{{ i18n.ts._urlPreviewSetting.userAgentDescription }}</template>
</MkInput>
<div>
<MkInput v-model="urlPreviewSummaryProxyUrl" type="text">
<template #label>{{ i18n.ts._urlPreviewSetting.summaryProxy }}</template>
<template #caption>[{{ i18n.ts.notUsePleaseLeaveBlank }}] {{ i18n.ts._urlPreviewSetting.summaryProxyDescription }}</template>
</MkInput>
<div :class="$style.subCaption">
{{ i18n.ts._urlPreviewSetting.summaryProxyDescription2 }}
<ul style="padding-left: 20px; margin: 4px 0">
<li>{{ i18n.ts._urlPreviewSetting.timeout }} / key:timeout</li>
<li>{{ i18n.ts._urlPreviewSetting.maximumContentLength }} / key:contentLengthLimit</li>
<li>{{ i18n.ts._urlPreviewSetting.requireContentLength }} / key:contentLengthRequired</li>
<li>{{ i18n.ts._urlPreviewSetting.userAgent }} / key:userAgent</li>
</ul>
</div>
</div>
</div>
</FormSection>
</div> </div>
</FormSuspense> </FormSuspense>
</MkSpacer> </MkSpacer>
@ -137,10 +184,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import XHeader from './_header_.vue'; import XHeader from './_header_.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import MkInput from '@/components/MkInput.vue';
import MkButton from '@/components/MkButton.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import FormSection from '@/components/form/section.vue'; import FormSection from '@/components/form/section.vue';
import FormSplit from '@/components/form/split.vue'; import FormSplit from '@/components/form/split.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
@ -149,7 +197,6 @@ import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkButton from '@/components/MkButton.vue';
const name = ref<string | null>(null); const name = ref<string | null>(null);
const shortName = ref<string | null>(null); const shortName = ref<string | null>(null);
@ -169,6 +216,12 @@ const perRemoteUserUserTimelineCacheMax = ref<number>(0);
const perUserHomeTimelineCacheMax = ref<number>(0); const perUserHomeTimelineCacheMax = ref<number>(0);
const perUserListTimelineCacheMax = ref<number>(0); const perUserListTimelineCacheMax = ref<number>(0);
const notesPerOneAd = ref<number>(0); const notesPerOneAd = ref<number>(0);
const urlPreviewEnabled = ref<boolean>(true);
const urlPreviewTimeout = ref<number>(10000);
const urlPreviewMaximumContentLength = ref<number>(1024 * 1024 * 10);
const urlPreviewRequireContentLength = ref<boolean>(true);
const urlPreviewUserAgent = ref<string | null>(null);
const urlPreviewSummaryProxyUrl = ref<string | null>(null);
async function init(): Promise<void> { async function init(): Promise<void> {
const meta = await misskeyApi('admin/meta'); const meta = await misskeyApi('admin/meta');
@ -190,9 +243,15 @@ async function init(): Promise<void> {
perUserHomeTimelineCacheMax.value = meta.perUserHomeTimelineCacheMax; perUserHomeTimelineCacheMax.value = meta.perUserHomeTimelineCacheMax;
perUserListTimelineCacheMax.value = meta.perUserListTimelineCacheMax; perUserListTimelineCacheMax.value = meta.perUserListTimelineCacheMax;
notesPerOneAd.value = meta.notesPerOneAd; notesPerOneAd.value = meta.notesPerOneAd;
urlPreviewEnabled.value = meta.urlPreviewEnabled;
urlPreviewTimeout.value = meta.urlPreviewTimeout;
urlPreviewMaximumContentLength.value = meta.urlPreviewMaximumContentLength;
urlPreviewRequireContentLength.value = meta.urlPreviewRequireContentLength;
urlPreviewUserAgent.value = meta.urlPreviewUserAgent;
urlPreviewSummaryProxyUrl.value = meta.urlPreviewSummaryProxyUrl;
} }
async function save(): void { async function save() {
await os.apiWithDialog('admin/update-meta', { await os.apiWithDialog('admin/update-meta', {
name: name.value, name: name.value,
shortName: shortName.value === '' ? null : shortName.value, shortName: shortName.value === '' ? null : shortName.value,
@ -212,6 +271,12 @@ async function save(): void {
perUserHomeTimelineCacheMax: perUserHomeTimelineCacheMax.value, perUserHomeTimelineCacheMax: perUserHomeTimelineCacheMax.value,
perUserListTimelineCacheMax: perUserListTimelineCacheMax.value, perUserListTimelineCacheMax: perUserListTimelineCacheMax.value,
notesPerOneAd: notesPerOneAd.value, notesPerOneAd: notesPerOneAd.value,
urlPreviewEnabled: urlPreviewEnabled.value,
urlPreviewTimeout: urlPreviewTimeout.value,
urlPreviewMaximumContentLength: urlPreviewMaximumContentLength.value,
urlPreviewRequireContentLength: urlPreviewRequireContentLength.value,
urlPreviewUserAgent: urlPreviewUserAgent.value,
urlPreviewSummaryProxyUrl: urlPreviewSummaryProxyUrl.value,
}); });
fetchInstance(true); fetchInstance(true);
@ -230,4 +295,9 @@ definePageMetadata(() => ({
-webkit-backdrop-filter: var(--blur, blur(15px)); -webkit-backdrop-filter: var(--blur, blur(15px));
backdrop-filter: var(--blur, blur(15px)); backdrop-filter: var(--blur, blur(15px));
} }
.subCaption {
font-size: 0.85em;
color: var(--fgTransparentWeak);
}
</style> </style>

View file

@ -6,10 +6,10 @@
import type { SoundStore } from '@/store.js'; import type { SoundStore } from '@/store.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { $i } from '@/account.js'; import { $i } from '@/account.js';
import { RateLimiter } from '@/scripts/rate-limiter.js';
let ctx: AudioContext; let ctx: AudioContext;
const cache = new Map<string, AudioBuffer>(); const cache = new Map<string, AudioBuffer>();
let canPlay = true;
export const soundsTypes = [ export const soundsTypes = [
// 音声なし // 音声なし
@ -127,17 +127,13 @@ export async function loadAudio(url: string, options?: { useCache?: boolean; })
*/ */
export function playMisskeySfx(operationType: OperationType) { export function playMisskeySfx(operationType: OperationType) {
const sound = defaultStore.state[`sound_${operationType}`]; const sound = defaultStore.state[`sound_${operationType}`];
if (sound.type == null || !canPlay || ('userActivation' in navigator && !navigator.userActivation.hasBeenActive)) return; if (sound.type == null || ('userActivation' in navigator && !navigator.userActivation.hasBeenActive)) return;
canPlay = false; playMisskeySfxFile(sound);
playMisskeySfxFile(sound).finally(() => {
// ごく短時間に音が重複しないように
setTimeout(() => {
canPlay = true;
}, 25);
});
} }
const rateLimiter = new RateLimiter<string>({ duration: 50, max: 1 });
/** /**
* *
* @param soundStore * @param soundStore
@ -152,7 +148,7 @@ export async function playMisskeySfxFile(soundStore: SoundStore) {
} }
const url = soundStore.type === '_driveFile_' ? soundStore.fileUrl : `/client-assets/sounds/${soundStore.type}.mp3`; const url = soundStore.type === '_driveFile_' ? soundStore.fileUrl : `/client-assets/sounds/${soundStore.type}.mp3`;
const buffer = await loadAudio(url); const buffer = await loadAudio(url);
if (!buffer) return; if (!buffer || !rateLimiter.hit(url)) return;
const volume = soundStore.volume * masterVolume; const volume = soundStore.volume * masterVolume;
createSourceNode(buffer, { volume }).soundSource.start(); createSourceNode(buffer, { volume }).soundSource.start();
} }

View file

@ -0,0 +1,33 @@
import { url as local } from '@/config.js';
import { instance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import * as os from '@/os.js';
const isRegExp = /^\/(.+)\/(.*)$/;
export async function warningExternalWebsite(ev: MouseEvent, url: string) {
const self = url.startsWith(local);
const isWellKnownWebsite = self || instance.wellKnownWebsites.some(expression => {
const r = isRegExp.exec(expression);
if (r) {
return new RegExp(r[1], r[2]).test(url);
} else return expression.split(' ').every(keyword => url.includes(keyword));
});
if (!self && !isWellKnownWebsite) {
ev.preventDefault();
ev.stopPropagation();
const confirm = await os.confirm({
type: 'warning',
title: i18n.ts.warningRedirectingExternalWebsiteTitle,
text: i18n.tsx.warningRedirectingExternalWebsiteDescription({ url }),
});
if (confirm.canceled) return false;
window.open(url, '_blank', 'noopener');
}
return true;
}

View file

@ -32,7 +32,7 @@
"@typescript-eslint/parser": "7.3.1", "@typescript-eslint/parser": "7.3.1",
"eslint": "8.57.0", "eslint": "8.57.0",
"nodemon": "3.1.0", "nodemon": "3.1.0",
"typescript": "5.4.2" "typescript": "5.4.3"
}, },
"files": [ "files": [
"built" "built"

View file

@ -17,7 +17,7 @@
"openapi-typescript": "6.7.5", "openapi-typescript": "6.7.5",
"ts-case-convert": "2.0.7", "ts-case-convert": "2.0.7",
"tsx": "4.7.1", "tsx": "4.7.1",
"typescript": "5.4.2" "typescript": "5.4.3"
}, },
"files": [ "files": [
"built" "built"

View file

@ -1,7 +1,7 @@
{ {
"type": "module", "type": "module",
"name": "misskey-js", "name": "misskey-js",
"version": "2024.3.1-host.2b", "version": "2024.3.1-host.2c",
"description": "Misskey SDK for JavaScript", "description": "Misskey SDK for JavaScript",
"types": "./built/dts/index.d.ts", "types": "./built/dts/index.d.ts",
"exports": { "exports": {
@ -50,7 +50,7 @@
"ncp": "2.0.0", "ncp": "2.0.0",
"nodemon": "3.1.0", "nodemon": "3.1.0",
"tsd": "0.30.7", "tsd": "0.30.7",
"typescript": "5.4.2" "typescript": "5.4.3"
}, },
"files": [ "files": [
"built", "built",

View file

@ -4991,12 +4991,14 @@ export type components = {
imageUrl: string; imageUrl: string;
dayOfWeek: number; dayOfWeek: number;
})[]; })[];
wellKnownWebsites: string[];
/** @default 0 */ /** @default 0 */
notesPerOneAd: number; notesPerOneAd: number;
enableEmail: boolean; enableEmail: boolean;
enableServiceWorker: boolean; enableServiceWorker: boolean;
translatorAvailable: boolean; translatorAvailable: boolean;
mediaProxy: string; mediaProxy: string;
enableUrlPreview: boolean;
backgroundImageUrl: string | null; backgroundImageUrl: string | null;
impressumUrl: string | null; impressumUrl: string | null;
logoImageUrl: string | null; logoImageUrl: string | null;
@ -5167,7 +5169,8 @@ export type operations = {
perUserHomeTimelineCacheMax: number; perUserHomeTimelineCacheMax: number;
perUserListTimelineCacheMax: number; perUserListTimelineCacheMax: number;
notesPerOneAd: number; notesPerOneAd: number;
urlPreviewDenyList?: string[]; wellKnownWebsites: string[];
urlPreviewDenyList: string[];
featuredGameChannels: string[]; featuredGameChannels: string[];
backgroundImageUrl: string | null; backgroundImageUrl: string | null;
deeplAuthKey: string | null; deeplAuthKey: string | null;
@ -5183,11 +5186,21 @@ export type operations = {
shortName: string | null; shortName: string | null;
privacyPolicyUrl: string | null; privacyPolicyUrl: string | null;
repositoryUrl: string | null; repositoryUrl: string | null;
/**
* @deprecated
* @description [Deprecated] Use "urlPreviewSummaryProxyUrl" instead.
*/
summalyProxy: string | null; summalyProxy: string | null;
themeColor: string | null; themeColor: string | null;
tosUrl: string | null; tosUrl: string | null;
uri: string; uri: string;
version: string; version: string;
urlPreviewEnabled: boolean;
urlPreviewTimeout: number;
urlPreviewMaximumContentLength: number;
urlPreviewRequireContentLength: boolean;
urlPreviewUserAgent: string | null;
urlPreviewSummaryProxyUrl: string | null;
}; };
}; };
}; };
@ -9585,7 +9598,6 @@ export type operations = {
maintainerName?: string | null; maintainerName?: string | null;
maintainerEmail?: string | null; maintainerEmail?: string | null;
langs?: string[]; langs?: string[];
summalyProxy?: string | null;
deeplAuthKey?: string | null; deeplAuthKey?: string | null;
deeplIsPro?: boolean; deeplIsPro?: boolean;
enableEmail?: boolean; enableEmail?: boolean;
@ -9627,8 +9639,17 @@ export type operations = {
notesPerOneAd?: number; notesPerOneAd?: number;
silencedHosts?: string[] | null; silencedHosts?: string[] | null;
sensitiveMediaHosts?: string[] | null; sensitiveMediaHosts?: string[] | null;
wellKnownWebsites?: string[] | null;
urlPreviewDenyList?: string[] | null; urlPreviewDenyList?: string[] | null;
featuredGameChannels?: string[] | null; featuredGameChannels?: string[] | null;
/** @description [Deprecated] Use "urlPreviewSummaryProxyUrl" instead. */
summalyProxy?: string | null;
urlPreviewEnabled?: boolean;
urlPreviewTimeout?: number;
urlPreviewMaximumContentLength?: number;
urlPreviewRequireContentLength?: boolean;
urlPreviewUserAgent?: string | null;
urlPreviewSummaryProxyUrl?: string | null;
}; };
}; };
}; };

View file

@ -30,7 +30,7 @@
"@typescript-eslint/parser": "7.3.1", "@typescript-eslint/parser": "7.3.1",
"eslint": "8.57.0", "eslint": "8.57.0",
"nodemon": "3.1.0", "nodemon": "3.1.0",
"typescript": "5.4.2" "typescript": "5.4.3"
}, },
"dependencies": { "dependencies": {
"crc-32": "1.2.2", "crc-32": "1.2.2",

View file

@ -20,7 +20,7 @@
"eslint": "8.57.0", "eslint": "8.57.0",
"eslint-plugin-import": "2.29.1", "eslint-plugin-import": "2.29.1",
"nodemon": "3.1.0", "nodemon": "3.1.0",
"typescript": "5.4.2" "typescript": "5.4.3"
}, },
"type": "module" "type": "module"
} }

2074
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff