diff options
| author | Marie <marie@kaifa.ch> | 2023-10-31 21:31:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-31 21:31:41 +0100 |
| commit | c44b261bef0b6dee8933b6b789a5bc177367dada (patch) | |
| tree | a08e581d071bed1526996cc796c876750d542aeb /packages/backend/src/core/NoteCreateService.ts | |
| parent | merge: fix file sorting on user notes (#122) (diff) | |
| parent | merge: locales (diff) | |
| download | sharkey-c44b261bef0b6dee8933b6b789a5bc177367dada.tar.gz sharkey-c44b261bef0b6dee8933b6b789a5bc177367dada.tar.bz2 sharkey-c44b261bef0b6dee8933b6b789a5bc177367dada.zip | |
merge: upstream changes (#123)
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
| -rw-r--r-- | packages/backend/src/core/NoteCreateService.ts | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 029891c610..34c8d4f8b1 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -55,8 +55,8 @@ import { MetaService } from '@/core/MetaService.js'; import { SearchService } from '@/core/SearchService.js'; import { FeaturedService } from '@/core/FeaturedService.js'; import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; -import { nyaize } from '@/misc/nyaize.js'; import { UtilityService } from '@/core/UtilityService.js'; +import { UserBlockingService } from '@/core/UserBlockingService.js'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -217,6 +217,7 @@ export class NoteCreateService implements OnApplicationShutdown { private activeUsersChart: ActiveUsersChart, private instanceChart: InstanceChart, private utilityService: UtilityService, + private userBlockingService: UserBlockingService, ) { } @bindThis @@ -228,8 +229,6 @@ export class NoteCreateService implements OnApplicationShutdown { isCat: MiUser['isCat']; speakAsCat: MiUser['speakAsCat']; }, data: Option, silent = false): Promise<MiNote> { - let patsedText: mfm.MfmNode[] | null = null; - // チャンネル外にリプライしたら対象のスコープに合わせる // (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで) if (data.reply && data.channel && data.reply.channelId !== data.channel.id) { @@ -296,6 +295,18 @@ export class NoteCreateService implements OnApplicationShutdown { } } + // Check blocking + if (data.renote && data.text == null && data.poll == null && (data.files == null || data.files.length === 0)) { + if (data.renote.userHost === null) { + if (data.renote.userId !== user.id) { + const blocked = await this.userBlockingService.checkBlocked(data.renote.userId, user.id); + if (blocked) { + throw new Error('blocked'); + } + } + } + } + // 返信対象がpublicではないならhomeにする if (data.reply && data.reply.visibility !== 'public' && data.visibility === 'public') { data.visibility = 'home'; @@ -316,25 +327,6 @@ export class NoteCreateService implements OnApplicationShutdown { data.text = data.text.slice(0, DB_MAX_NOTE_TEXT_LENGTH); } data.text = data.text.trim(); - - if (user.isCat && user.speakAsCat) { - patsedText = mfm.parse(data.text); - function nyaizeNode(node: mfm.MfmNode) { - if (node.type === 'quote') return; - if (node.type === 'text') { - node.props.text = nyaize(node.props.text); - } - if (node.children) { - for (const child of node.children) { - nyaizeNode(child); - } - } - } - for (const node of patsedText) { - nyaizeNode(node); - } - data.text = mfm.toString(patsedText); - } } else { data.text = null; } @@ -345,7 +337,7 @@ export class NoteCreateService implements OnApplicationShutdown { // Parse MFM if needed if (!tags || !emojis || !mentionedUsers) { - const tokens = patsedText ?? (data.text ? mfm.parse(data.text)! : []); + const tokens = (data.text ? mfm.parse(data.text)! : []); const cwTokens = data.cw ? mfm.parse(data.cw)! : []; const choiceTokens = data.poll && data.poll.choices ? concat(data.poll.choices.map(choice => mfm.parse(choice)!)) @@ -598,7 +590,7 @@ export class NoteCreateService implements OnApplicationShutdown { } // Pack the note - const noteObj = await this.noteEntityService.pack(note, null, { skipHide: true }); + const noteObj = await this.noteEntityService.pack(note, null, { skipHide: true, withReactionAndUserPairCache: true }); this.globalEventService.publishNotesStream(noteObj); @@ -861,6 +853,7 @@ export class NoteCreateService implements OnApplicationShutdown { @bindThis private async pushToTl(note: MiNote, user: { id: MiUser['id']; host: MiUser['host']; }) { const meta = await this.metaService.fetch(); + if (!meta.enableFanoutTimeline) return; const r = this.redisForTimelines.pipeline(); @@ -904,7 +897,7 @@ export class NoteCreateService implements OnApplicationShutdown { if (note.visibility === 'followers') { // TODO: 重そうだから何とかしたい Set 使う? - userListMemberships = userListMemberships.filter(x => followings.some(f => f.followerId === x.userListUserId)); + userListMemberships = userListMemberships.filter(x => x.userListUserId === user.id || followings.some(f => f.followerId === x.userListUserId)); } // TODO: あまりにも数が多いと redisPipeline.exec に失敗する(理由は不明)ため、3万件程度を目安に分割して実行するようにする |