merge: upstream
This commit is contained in:
commit
4dd23a3793
217 changed files with 6773 additions and 2275 deletions
|
@ -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万件程度を目安に分割して実行するようにする
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue