summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/NoteEditService.ts24
-rw-r--r--packages/backend/src/core/activitypub/ApRendererService.ts15
2 files changed, 15 insertions, 24 deletions
diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts
index 18912181d7..854112ec1d 100644
--- a/packages/backend/src/core/NoteEditService.ts
+++ b/packages/backend/src/core/NoteEditService.ts
@@ -224,13 +224,7 @@ export class NoteEditService implements OnApplicationShutdown {
}
@bindThis
- public async edit(user: {
- id: MiUser['id'];
- username: MiUser['username'];
- host: MiUser['host'];
- isBot: MiUser['isBot'];
- noindex: MiUser['noindex'];
- }, editid: MiNote['id'], data: Option, silent = false): Promise<MiNote> {
+ public async edit(user: MiUser, editid: MiNote['id'], data: Option, silent = false): Promise<MiNote> {
if (!editid) {
throw new Error('fail');
}
@@ -584,13 +578,7 @@ export class NoteEditService implements OnApplicationShutdown {
}
@bindThis
- private async postNoteEdited(note: MiNote, oldNote: MiNote, user: {
- id: MiUser['id'];
- username: MiUser['username'];
- host: MiUser['host'];
- isBot: MiUser['isBot'];
- noindex: MiUser['noindex'];
- }, data: Option, silent: boolean, tags: string[], mentionedUsers: MinimumUser[]) {
+ private async postNoteEdited(note: MiNote, oldNote: MiNote, user: MiUser, data: Option, silent: boolean, tags: string[], mentionedUsers: MinimumUser[]) {
// Register host
if (this.meta.enableStatsForFederatedInstances) {
if (this.userEntityService.isRemoteUser(user)) {
@@ -703,7 +691,7 @@ export class NoteEditService 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);
// メンションされたリモートユーザーに配送
@@ -834,14 +822,12 @@ export class NoteEditService 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 user = await this.usersRepository.findOneBy({ id: note.userId });
- if (user == null) throw new Error('user not found');
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.renderUpdate(await this.apRendererService.renderUpNote(note, false), user);
+ : this.apRendererService.renderUpdate(await this.apRendererService.renderUpNote(note, user, false), user);
return this.apRendererService.addContext(content);
}
diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts
index 22cb6b8282..cb9b74f6d7 100644
--- a/packages/backend/src/core/activitypub/ApRendererService.ts
+++ b/packages/backend/src/core/activitypub/ApRendererService.ts
@@ -642,7 +642,7 @@ export class ApRendererService {
}
@bindThis
- public async renderUpNote(note: MiNote, dive = true): Promise<IPost> {
+ public async renderUpNote(note: MiNote, author: MiUser, dive = true): Promise<IPost> {
const getPromisedFiles = async (ids: string[]): Promise<MiDriveFile[]> => {
if (ids.length === 0) return [];
const items = await this.driveFilesRepository.findBy({ id: In(ids) });
@@ -656,14 +656,14 @@ export class ApRendererService {
inReplyToNote = await this.notesRepository.findOneBy({ id: note.replyId });
if (inReplyToNote != null) {
- const inReplyToUserExist = await this.usersRepository.exists({ where: { id: inReplyToNote.userId } });
+ const inReplyToUser = await this.usersRepository.findOneBy({ id: inReplyToNote.userId });
- if (inReplyToUserExist) {
+ if (inReplyToUser) {
if (inReplyToNote.uri) {
inReplyTo = inReplyToNote.uri;
} else {
if (dive) {
- inReplyTo = await this.renderUpNote(inReplyToNote, false);
+ inReplyTo = await this.renderUpNote(inReplyToNote, inReplyToUser, false);
} else {
inReplyTo = `${this.config.url}/notes/${inReplyToNote.id}`;
}
@@ -726,7 +726,12 @@ export class ApRendererService {
apAppend += `\n\nRE: ${quote}`;
}
- const summary = note.cw === '' ? String.fromCharCode(0x200B) : note.cw;
+ let summary = note.cw === '' ? String.fromCharCode(0x200B) : note.cw;
+
+ // Apply mandatory CW, if applicable
+ if (author.mandatoryCW) {
+ summary = appendContentWarning(summary, author.mandatoryCW);
+ }
const { content } = this.apMfmService.getNoteHtml(note, apAppend);