diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-05-12 12:41:53 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-12 12:41:53 +0900 |
| commit | de6348e8a00a72c2410a8907d59a9bd29142a200 (patch) | |
| tree | f163329a67ac5c6dc1c33845b4fc131a8c59a39b /packages/backend/src/core | |
| parent | Merge pull request #10814 from misskey-dev/develop (diff) | |
| parent | fix(frontend): fix retention rate heatmap rendering (diff) | |
| download | misskey-de6348e8a00a72c2410a8907d59a9bd29142a200.tar.gz misskey-de6348e8a00a72c2410a8907d59a9bd29142a200.tar.bz2 misskey-de6348e8a00a72c2410a8907d59a9bd29142a200.zip | |
Merge pull request #10833 from misskey-dev/develop
* refactor(frontend): use css modules
* feat: 投稿したコンテンツのAIによる学習を軽減するオプションを追加
Resolve #10819
* enhance(backend): publicReactionsをデフォルトtrueに
* 念のためnoimageaiもつける
* add X-Robots-Tag: noai
* Update ja-JP.yml
* fix(frontend): ブラーエフェクトを有効にしている状態で高負荷になる問題を修正
* enhance(backend): graceful shutdown for job queue and refactor
* fix(backend): テスト時は一部のサービスを停止
* fix test
* New Crowdin updates (#10815)
* New translations ja-JP.yml (English)
* New translations ja-JP.yml (German)
* New translations ja-JP.yml (Korean)
* New translations ja-JP.yml (Chinese Traditional)
* New translations ja-JP.yml (Chinese Traditional)
* refactor
* bump
* refactor(frontend): use css module
* refactor(frontend): use css module
* delete unused component
* センシティブワードを正規表現、CWにも適用するように (#10688)
* cwにセンシティブが効いてない
* CWが無いときにTextを見るように
* 比較演算子間違えた
* とりあえずチェック
* 正規表現対応
* /test/giにも対応
* matchでしなくてもいいのでは感
* レビュー修正
* Update packages/backend/src/core/NoteCreateService.ts
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
* Update packages/backend/src/core/NoteCreateService.ts
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
* 修正
* wipかも
* wordsでスペース区切りのものできたかも
* なんか動いたかも
* test作成
* 文言の修正
* 修正
* note参照
---------
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
* Update CHANGELOG.md
* New Crowdin updates (#10823)
* New translations ja-JP.yml (English)
* New translations ja-JP.yml (German)
* ci: fix typo
* fix(frontend): より明確な説明にしたのとtypo修正
* fix typo
* fix(frontend): カラーバーがリプライには表示されないのを修正
* fix(frontend): チャンネル内の検索ボックスが挙動不審な問題を修正
Fix #10793
* enhance(backend): ノートのハッシュタグもMeilisearchに突っ込むように
今後ハッシュタグ検索とか実装するときのため
* feat(frontend): ユーザー指定ノート検索
* fix(frontend): fix retention chart rendering
* Update about-misskey.vue
* meta: Remove @rinsuki from reviewer-lottery (#10830)
* New Crowdin updates (#10824)
* New translations ja-JP.yml (English)
* New translations ja-JP.yml (German)
* New translations ja-JP.yml (Chinese Traditional)
* New translations ja-JP.yml (English)
* New translations ja-JP.yml (Chinese Traditional)
* New translations ja-JP.yml (German)
* New translations ja-JP.yml (English)
* New translations ja-JP.yml (Chinese Traditional)
* New translations ja-JP.yml (French)
* New translations ja-JP.yml (German)
* New translations ja-JP.yml (English)
* New translations ja-JP.yml (Japanese, Kansai)
* New translations ja-JP.yml (Chinese Traditional)
* New translations ja-JP.yml (Spanish)
* New translations ja-JP.yml (German)
* New translations ja-JP.yml (Italian)
* New translations ja-JP.yml (Korean)
* New translations ja-JP.yml (Norwegian)
* New translations ja-JP.yml (Russian)
* New translations ja-JP.yml (Chinese Simplified)
* New translations ja-JP.yml (Indonesian)
* New translations ja-JP.yml (Thai)
* enhance(frontend): アカウント初期設定ウィザードにプライバシー設定を追加
* Update CHANGELOG.md
* fix(backend): ひとつのMeilisearchサーバーを複数のMisskeyサーバーで使えない問題を修正
* fix MkUserSetupDialog.Privacy.vue
* ci: skip non-Japanese locale on TurboSnap
* ci: notify on changes for push events
* ci: fix missing branch
* Update basic.cy.js
* [ci skip] New Crowdin updates (#10834)
* New translations ja-JP.yml (English)
* New translations ja-JP.yml (Arabic)
* New translations ja-JP.yml (German)
* New translations ja-JP.yml (Chinese Simplified)
* New translations ja-JP.yml (Japanese, Kansai)
* New translations ja-JP.yml (Arabic)
* :art:
* :art:
* enhance(frontend): add retention line chart
* update deps
* refactor
* fix(frontend): Pageにおいて画像ブロックに画像を設定できない問題を修正
Fix #10837
---------
Co-authored-by: nenohi <kimutipartylove@gmail.com>
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Co-authored-by: rinsuki <428rinsuki+git@gmail.com>
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/NoteCreateService.ts | 29 | ||||
| -rw-r--r-- | packages/backend/src/core/QueueModule.ts | 41 | ||||
| -rw-r--r-- | packages/backend/src/core/SearchService.ts | 4 | ||||
| -rw-r--r-- | packages/backend/src/core/entities/UserEntityService.ts | 1 |
4 files changed, 69 insertions, 6 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 364976e4a7..977c9052c0 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -3,6 +3,7 @@ import * as mfm from 'mfm-js'; import { In, DataSource } from 'typeorm'; import * as Redis from 'ioredis'; import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common'; +import RE2 from 're2'; import { extractMentions } from '@/misc/extract-mentions.js'; import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mfm.js'; import { extractHashtags } from '@/misc/extract-hashtags.js'; @@ -238,7 +239,8 @@ export class NoteCreateService implements OnApplicationShutdown { if (data.channel != null) data.localOnly = true; if (data.visibility === 'public' && data.channel == null) { - if ((data.text != null) && (await this.metaService.fetch()).sensitiveWords.some(w => data.text!.includes(w))) { + const sensitiveWords = (await this.metaService.fetch()).sensitiveWords; + if (this.isSensitive(data, sensitiveWords)) { data.visibility = 'home'; } else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) { data.visibility = 'home'; @@ -670,6 +672,31 @@ export class NoteCreateService implements OnApplicationShutdown { // Register to search database this.index(note); } + + @bindThis + private isSensitive(note: Option, sensitiveWord: string[]): boolean { + if (sensitiveWord.length > 0) { + const text = note.cw ?? note.text ?? ''; + if (text === '') return false; + const matched = sensitiveWord.some(filter => { + // represents RegExp + const regexp = filter.match(/^\/(.+)\/(.*)$/); + // This should never happen due to input sanitisation. + if (!regexp) { + const words = filter.split(' '); + return words.every(keyword => text.includes(keyword)); + } + try { + return new RE2(regexp[1], regexp[2]).test(text); + } catch (err) { + // This should never happen due to input sanitisation. + return false; + } + }); + if (matched) return true; + } + return false; + } @bindThis private incRenoteCount(renote: Note) { diff --git a/packages/backend/src/core/QueueModule.ts b/packages/backend/src/core/QueueModule.ts index d4905a5f88..1d73947776 100644 --- a/packages/backend/src/core/QueueModule.ts +++ b/packages/backend/src/core/QueueModule.ts @@ -1,4 +1,5 @@ -import { Module } from '@nestjs/common'; +import { setTimeout } from 'node:timers/promises'; +import { Inject, Module, OnApplicationShutdown } from '@nestjs/common'; import Bull from 'bull'; import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; @@ -41,9 +42,9 @@ export type SystemQueue = Bull.Queue<Record<string, unknown>>; export type EndedPollNotificationQueue = Bull.Queue<EndedPollNotificationJobData>; export type DeliverQueue = Bull.Queue<DeliverJobData>; export type InboxQueue = Bull.Queue<InboxJobData>; -export type DbQueue = Bull.Queue<DbJobData<keyof DbJobMap>>; +export type DbQueue = Bull.Queue; export type RelationshipQueue = Bull.Queue<RelationshipJobData>; -export type ObjectStorageQueue = Bull.Queue<ObjectStorageJobData>; +export type ObjectStorageQueue = Bull.Queue; export type WebhookDeliverQueue = Bull.Queue<WebhookDeliverJobData>; const $system: Provider = { @@ -118,4 +119,36 @@ const $webhookDeliver: Provider = { $webhookDeliver, ], }) -export class QueueModule {} +export class QueueModule implements OnApplicationShutdown { + constructor( + @Inject('queue:system') public systemQueue: SystemQueue, + @Inject('queue:endedPollNotification') public endedPollNotificationQueue: EndedPollNotificationQueue, + @Inject('queue:deliver') public deliverQueue: DeliverQueue, + @Inject('queue:inbox') public inboxQueue: InboxQueue, + @Inject('queue:db') public dbQueue: DbQueue, + @Inject('queue:relationship') public relationshipQueue: RelationshipQueue, + @Inject('queue:objectStorage') public objectStorageQueue: ObjectStorageQueue, + @Inject('queue:webhookDeliver') public webhookDeliverQueue: WebhookDeliverQueue, + ) {} + + async onApplicationShutdown(signal: string): Promise<void> { + if (process.env.NODE_ENV === 'test') { + // XXX: + // Shutting down the existing connections causes errors on Jest as + // Misskey has asynchronous postgres/redis connections that are not + // awaited. + // Let's wait for some random time for them to finish. + await setTimeout(5000); + } + await Promise.all([ + this.systemQueue.close(), + this.endedPollNotificationQueue.close(), + this.deliverQueue.close(), + this.inboxQueue.close(), + this.dbQueue.close(), + this.relationshipQueue.close(), + this.objectStorageQueue.close(), + this.webhookDeliverQueue.close(), + ]); + } +} diff --git a/packages/backend/src/core/SearchService.ts b/packages/backend/src/core/SearchService.ts index e68fde088d..9502afcc9b 100644 --- a/packages/backend/src/core/SearchService.ts +++ b/packages/backend/src/core/SearchService.ts @@ -68,7 +68,7 @@ export class SearchService { private idService: IdService, ) { if (meilisearch) { - this.meilisearchNoteIndex = meilisearch.index('notes'); + this.meilisearchNoteIndex = meilisearch.index(`${config.meilisearch!.index}---notes`); this.meilisearchNoteIndex.updateSettings({ searchableAttributes: [ 'text', @@ -82,6 +82,7 @@ export class SearchService { 'userId', 'userHost', 'channelId', + 'tags', ], typoTolerance: { enabled: false, @@ -107,6 +108,7 @@ export class SearchService { channelId: note.channelId, cw: note.cw, text: note.text, + tags: note.tags, }], { primaryKey: 'id', }); diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index 453c1473dd..7f61e1d6f3 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -445,6 +445,7 @@ export class UserEntityService implements OnModuleInit { carefulBot: profile!.carefulBot, autoAcceptFollowed: profile!.autoAcceptFollowed, noCrawle: profile!.noCrawle, + preventAiLearning: profile!.preventAiLearning, isExplorable: user.isExplorable, isDeleted: user.isDeleted, hideOnlineStatus: user.hideOnlineStatus, |