Skip to content

Commit

Permalink
Merge branch 'develop' into fix/fix-slowed-build-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
samunohito committed Mar 21, 2024
2 parents 7f5898d + 831c74a commit 5ab9118
Show file tree
Hide file tree
Showing 35 changed files with 485 additions and 68 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
## Unreleased

### Note
- コントロールパネル内にあるサマリープロキシの設定個所がセキュリティから全般へ変更となります。

### General
- Enhance: URLプレビューの有効化・無効化を設定できるように #13569
- Enhance: アンテナでBotによるノートを除外できるように
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/545)
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正

### Client
Expand All @@ -23,6 +29,7 @@

### Server
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
- Enhance: misskey-dev/[email protected]の取り込み(プレビュー生成処理の効率化)
- Fix: フォローリクエストを作成する際に既存のものは削除するように
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/440)

Expand Down
62 changes: 62 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,10 @@ export interface Locale extends ILocale {
* 除外キーワード
*/
"antennaExcludeKeywords": string;
/**
* Botアカウントを除外
*/
"antennaExcludeBots": string;
/**
* スペースで区切るとAND指定になり、改行で区切るとOR指定になります
*/
Expand Down Expand Up @@ -4912,6 +4916,10 @@ export interface Locale extends ILocale {
* リトライ
*/
"gameRetry": string;
/**
* 使用しない場合は空欄にしてください
*/
"notUsePleaseLeaveBlank": string;
"_bubbleGame": {
/**
* 遊び方
Expand Down Expand Up @@ -9764,6 +9772,60 @@ export interface Locale extends ILocale {
*/
"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: {
[lang: string]: Locale;
Expand Down
16 changes: 16 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ name: "名前"
antennaSource: "受信ソース"
antennaKeywords: "受信キーワード"
antennaExcludeKeywords: "除外キーワード"
antennaExcludeBots: "Botアカウントを除外"
antennaKeywordsDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります"
notifyAntenna: "新しいノートを通知する"
withFileAntenna: "ファイルが添付されたノートのみ"
Expand Down Expand Up @@ -1224,6 +1225,7 @@ enableHorizontalSwipe: "スワイプしてタブを切り替える"
loading: "読み込み中"
surrender: "やめる"
gameRetry: "リトライ"
notUsePleaseLeaveBlank: "使用しない場合は空欄にしてください"

_bubbleGame:
howToPlay: "遊び方"
Expand Down Expand Up @@ -2601,3 +2603,17 @@ _offlineScreen:
title: "オフライン - サーバーに接続できません"
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: "プロキシには下記パラメータがクエリ文字列として連携されます。プロキシ側がこれらをサポートしない場合、設定値は無視されます。"
42 changes: 42 additions & 0 deletions packages/backend/migration/1710512074000-url-preview-meta.js
Original file line number Diff line number Diff line change
@@ -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";
`);
}
}
16 changes: 16 additions & 0 deletions packages/backend/migration/1710919614510-antenna-exclude-bots.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/

export class AntennaExcludeBots1710919614510 {
name = 'AntennaExcludeBots1710919614510'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "antenna" ADD "excludeBots" boolean NOT NULL DEFAULT false`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "antenna" DROP COLUMN "excludeBots"`);
}
}
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@fastify/static": "6.12.0",
"@fastify/view": "8.2.0",
"@misskey-dev/sharp-read-bmp": "1.2.0",
"@misskey-dev/summaly": "5.0.3",
"@misskey-dev/summaly": "5.1.0",
"@nestjs/common": "10.3.3",
"@nestjs/core": "10.3.3",
"@nestjs/testing": "10.3.3",
Expand Down
6 changes: 4 additions & 2 deletions packages/backend/src/core/AntennaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AntennaService implements OnApplicationShutdown {
}

@bindThis
public async addNoteToAntennas(note: MiNote, noteUser: { id: MiUser['id']; username: string; host: string | null; }): Promise<void> {
public async addNoteToAntennas(note: MiNote, noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<void> {
const antennas = await this.getAntennas();
const antennasWithMatchResult = await Promise.all(antennas.map(antenna => this.checkHitAntenna(antenna, note, noteUser).then(hit => [antenna, hit] as const)));
const matchedAntennas = antennasWithMatchResult.filter(([, hit]) => hit).map(([antenna]) => antenna);
Expand All @@ -110,10 +110,12 @@ export class AntennaService implements OnApplicationShutdown {
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている

@bindThis
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; }): Promise<boolean> {
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<boolean> {
if (note.visibility === 'specified') return false;
if (note.visibility === 'followers') return false;

if (antenna.excludeBots && noteUser.isBot) return false;

if (antenna.localOnly && noteUser.host != null) return false;

if (!antenna.withReplies && note.replyId != null) return false;
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/core/entities/AntennaEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class AntennaEntityService {
caseSensitive: antenna.caseSensitive,
localOnly: antenna.localOnly,
notify: antenna.notify,
excludeBots: antenna.excludeBots,
withReplies: antenna.withReplies,
withFile: antenna.withFile,
isActive: antenna.isActive,
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/core/entities/MetaEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class MetaEntityService {
policies: { ...DEFAULT_POLICIES, ...instance.policies },

mediaProxy: this.config.mediaProxy,
enableUrlPreview: instance.urlPreviewEnabled,
};

return packed;
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/models/Antenna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export class MiAntenna {
})
public caseSensitive: boolean;

@Column('boolean', {
default: false,
})
public excludeBots: boolean;

@Column('boolean', {
default: false,
})
Expand Down
38 changes: 32 additions & 6 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,6 @@ export class MiMeta {
})
public enableSensitiveMediaDetectionForVideos: boolean;

@Column('varchar', {
length: 1024,
nullable: true,
})
public summalyProxy: string | null;

@Column('boolean', {
default: false,
})
Expand Down Expand Up @@ -588,4 +582,36 @@ export class MiMeta {
default: 0,
})
public notesPerOneAd: number;

@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;
}
5 changes: 5 additions & 0 deletions packages/backend/src/models/json-schema/antenna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export const packedAntennaSchema = {
type: 'boolean',
optional: false, nullable: false,
},
excludeBots: {
type: 'boolean',
optional: false, nullable: false,
default: false,
},
withReplies: {
type: 'boolean',
optional: false, nullable: false,
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/models/json-schema/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export const packedMetaLiteSchema = {
type: 'string',
optional: false, nullable: false,
},
enableUrlPreview: {
type: 'boolean',
optional: false, nullable: false,
},
backgroundImageUrl: {
type: 'string',
optional: false, nullable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class ExportAntennasProcessorService {
}) : null,
caseSensitive: antenna.caseSensitive,
localOnly: antenna.localOnly,
excludeBots: antenna.excludeBots,
withReplies: antenna.withReplies,
withFile: antenna.withFile,
notify: antenna.notify,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const validate = new Ajv().compile({
} },
caseSensitive: { type: 'boolean' },
localOnly: { type: 'boolean' },
excludeBots: { type: 'boolean' },
withReplies: { type: 'boolean' },
withFile: { type: 'boolean' },
notify: { type: 'boolean' },
Expand Down Expand Up @@ -88,6 +89,7 @@ export class ImportAntennasProcessorService {
users: (antenna.src === 'list' && antenna.userListAccts !== null ? antenna.userListAccts : antenna.users).filter(Boolean),
caseSensitive: antenna.caseSensitive,
localOnly: antenna.localOnly,
excludeBots: antenna.excludeBots,
withReplies: antenna.withReplies,
withFile: antenna.withFile,
notify: antenna.notify,
Expand Down
Loading

0 comments on commit 5ab9118

Please sign in to comment.