summaryrefslogtreecommitdiff
path: root/packages/backend
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-06-18 10:36:18 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-06-18 10:36:18 -0400
commit6a8bc6741e8eedf7bfc6cde370fed0eea27d53ff (patch)
tree5ea9ca4e9b10c13637ba52d9316b4809f6efc376 /packages/backend
parentfix usage of appearNote in frontend components (diff)
downloadsharkey-6a8bc6741e8eedf7bfc6cde370fed0eea27d53ff.tar.gz
sharkey-6a8bc6741e8eedf7bfc6cde370fed0eea27d53ff.tar.bz2
sharkey-6a8bc6741e8eedf7bfc6cde370fed0eea27d53ff.zip
support boosts and edits in renderNoteOrRenoteActivity
Diffstat (limited to 'packages/backend')
-rw-r--r--packages/backend/src/core/NoteCreateService.ts13
-rw-r--r--packages/backend/src/core/NoteEditService.ts13
-rw-r--r--packages/backend/src/core/activitypub/ApRendererService.ts21
3 files changed, 23 insertions, 24 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts
index 0dd0a9b822..f4159facc3 100644
--- a/packages/backend/src/core/NoteCreateService.ts
+++ b/packages/backend/src/core/NoteCreateService.ts
@@ -731,7 +731,7 @@ export class NoteCreateService implements OnApplicationShutdown {
//#region AP deliver
if (!data.localOnly && this.userEntityService.isLocalUser(user)) {
trackTask(async () => {
- const noteActivity = await this.renderNoteOrRenoteActivity(data, note, user);
+ const noteActivity = await this.apRendererService.renderNoteOrRenoteActivity(note, user, { renote: data.renote });
const dm = this.apDeliverManagerService.createDeliverManager(user, noteActivity);
// メンションされたリモートユーザーに配送
@@ -875,17 +875,6 @@ export class NoteCreateService implements OnApplicationShutdown {
}
@bindThis
- 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, user, false), note);
-
- return this.apRendererService.addContext(content);
- }
-
- @bindThis
private index(note: MiNote) {
if (note.text == null && note.cw == null) return;
diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts
index 533ee7942d..4be097465d 100644
--- a/packages/backend/src/core/NoteEditService.ts
+++ b/packages/backend/src/core/NoteEditService.ts
@@ -675,7 +675,7 @@ export class NoteEditService implements OnApplicationShutdown {
//#region AP deliver
if (!data.localOnly && this.userEntityService.isLocalUser(user)) {
trackTask(async () => {
- const noteActivity = await this.renderNoteOrRenoteActivity(data, note, user);
+ const noteActivity = await this.apRendererService.renderNoteOrRenoteActivity(note, user, { renote: data.renote });
const dm = this.apDeliverManagerService.createDeliverManager(user, noteActivity);
// メンションされたリモートユーザーに配送
@@ -771,17 +771,6 @@ export class NoteEditService implements OnApplicationShutdown {
}
@bindThis
- 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.renderUpdate(await this.apRendererService.renderUpNote(note, user, false), user);
-
- return this.apRendererService.addContext(content);
- }
-
- @bindThis
private index(note: MiNote) {
if (note.text == null && note.cw == null) return;
diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts
index 08a8f30049..b075d0f803 100644
--- a/packages/backend/src/core/activitypub/ApRendererService.ts
+++ b/packages/backend/src/core/activitypub/ApRendererService.ts
@@ -1080,6 +1080,27 @@ export class ApRendererService {
}
@bindThis
+ public async renderNoteOrRenoteActivity(note: MiNote, user: MiUser, hint?: { renote?: MiNote | null }) {
+ if (note.localOnly) return null;
+
+ if (isPureRenote(note)) {
+ const renote = hint?.renote ?? note.renote ?? await this.notesRepository.findOneByOrFail({ id: note.renoteId });
+ const apAnnounce = this.renderAnnounce(renote.uri ?? `${this.config.url}/notes/${renote.id}`, note);
+ return this.addContext(apAnnounce);
+ }
+
+ const apNote = await this.renderNote(note, user, false);
+
+ if (note.updatedAt != null) {
+ const apUpdate = this.renderUpdate(apNote, user);
+ return this.addContext(apUpdate);
+ } else {
+ const apCreate = this.renderCreate(apNote, note);
+ return this.addContext(apCreate);
+ }
+ }
+
+ @bindThis
private async getEmojis(names: string[]): Promise<MiEmoji[]> {
if (names.length === 0) return [];