remove mandatory CW logic from NoteCreateService and NoteEditService

This commit is contained in:
Hazelnoot 2025-02-12 13:59:49 -05:00
parent d5e9be318b
commit 7814c6e54e
2 changed files with 3 additions and 24 deletions

View file

@ -234,7 +234,6 @@ export class NoteCreateService implements OnApplicationShutdown {
host: MiUser['host'];
isBot: MiUser['isBot'];
noindex: MiUser['noindex'];
mandatoryCW: MiUser['mandatoryCW'];
}, data: Option, silent = false): Promise<MiNote> {
// チャンネル外にリプライしたら対象のスコープに合わせる
// (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで)
@ -369,15 +368,6 @@ export class NoteCreateService implements OnApplicationShutdown {
data.cw = null;
}
// Apply mandatory CW, if applicable
if (user.mandatoryCW) {
if (!data.cw) {
data.cw = user.mandatoryCW;
} else if (!data.cw.includes(user.mandatoryCW)) {
data.cw += `, ${user.mandatoryCW}`;
}
}
let tags = data.apHashtags;
let emojis = data.apEmojis;
let mentionedUsers = data.apMentions;
@ -451,7 +441,6 @@ export class NoteCreateService implements OnApplicationShutdown {
host: MiUser['host'];
isBot: MiUser['isBot'];
noindex: MiUser['noindex'];
mandatoryCW: MiUser['mandatoryCW'];
}, data: Option): Promise<MiNote> {
return this.create(user, data, true);
}
@ -764,7 +753,7 @@ export class NoteCreateService implements OnApplicationShutdown {
//#region AP deliver
if (!data.localOnly && this.userEntityService.isLocalUser(user)) {
(async () => {
const noteActivity = await this.renderNoteOrRenoteActivity(data, note);
const noteActivity = await this.renderNoteOrRenoteActivity(data, note, user);
const dm = this.apDeliverManagerService.createDeliverManager(user, noteActivity);
// メンションされたリモートユーザーに配送
@ -910,12 +899,12 @@ export class NoteCreateService implements OnApplicationShutdown {
}
@bindThis
private async renderNoteOrRenoteActivity(data: Option, note: MiNote) {
private async renderNoteOrRenoteActivity(data: Option, note: MiNote, user: MiUser) {
if (data.localOnly) return null;
const content = this.isRenote(data) && !this.isQuote(data)
? this.apRendererService.renderAnnounce(data.renote.uri ? data.renote.uri : `${this.config.url}/notes/${data.renote.id}`, note)
: this.apRendererService.renderCreate(await this.apRendererService.renderNote(note, false), note);
: this.apRendererService.renderCreate(await this.apRendererService.renderNote(note, user, false), note);
return this.apRendererService.addContext(content);
}

View file

@ -230,7 +230,6 @@ export class NoteEditService implements OnApplicationShutdown {
host: MiUser['host'];
isBot: MiUser['isBot'];
noindex: MiUser['noindex'];
mandatoryCW: MiUser['mandatoryCW'];
}, editid: MiNote['id'], data: Option, silent = false): Promise<MiNote> {
if (!editid) {
throw new Error('fail');
@ -397,15 +396,6 @@ export class NoteEditService implements OnApplicationShutdown {
data.cw = null;
}
// Apply mandatory CW, if applicable
if (user.mandatoryCW) {
if (!data.cw) {
data.cw = user.mandatoryCW;
} else if (!data.cw.includes(user.mandatoryCW)) {
data.cw += `, ${user.mandatoryCW}`;
}
}
let tags = data.apHashtags;
let emojis = data.apEmojis;
let mentionedUsers = data.apMentions;