mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-06 03:56:56 +00:00
support boosts and edits in renderNoteOrRenoteActivity
This commit is contained in:
parent
b97e505709
commit
6a8bc6741e
3 changed files with 23 additions and 24 deletions
|
@ -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);
|
||||
|
||||
// メンションされたリモートユーザーに配送
|
||||
|
@ -874,17 +874,6 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
this.notesRepository.increment({ id: reply.id }, 'repliesCount', 1);
|
||||
}
|
||||
|
||||
@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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
// メンションされたリモートユーザーに配送
|
||||
|
@ -770,17 +770,6 @@ export class NoteEditService implements OnApplicationShutdown {
|
|||
(note.files != null && note.files.length > 0);
|
||||
}
|
||||
|
||||
@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;
|
||||
|
|
|
@ -1079,6 +1079,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 [];
|
||||
|
|
Loading…
Add table
Reference in a new issue