diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-06-18 14:25:04 +0000 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2024-06-18 14:25:04 +0000 |
| commit | b7805adc85653d8d789728dfaaa6a7e80d1440b8 (patch) | |
| tree | 0109695430a1e604e68ddc2b7137f1fa7e354e4c /packages/backend/src/core/NoteCreateService.ts | |
| parent | merge: feat: add an option to collapse replies (!545) (diff) | |
| parent | merge: merge up to 2024.5.0 (!537) (diff) | |
| download | sharkey-b7805adc85653d8d789728dfaaa6a7e80d1440b8.tar.gz sharkey-b7805adc85653d8d789728dfaaa6a7e80d1440b8.tar.bz2 sharkey-b7805adc85653d8d789728dfaaa6a7e80d1440b8.zip | |
merge: prepare for 2024.5, 2nd try (!554)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/554
Closes #494
Approved-by: Tess K <me@thvxl.se>
Approved-by: Marie <marie@kaifa.ch>
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
| -rw-r--r-- | packages/backend/src/core/NoteCreateService.ts | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index d51315f71f..41efa76f3f 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -282,7 +282,7 @@ export class NoteCreateService implements OnApplicationShutdown { data.visibility = 'home'; } - if (data.renote) { + if (this.isRenote(data)) { switch (data.renote.visibility) { case 'public': // public noteは無条件にrenote可能 @@ -309,7 +309,7 @@ export class NoteCreateService implements OnApplicationShutdown { } // Check blocking - if (data.renote && !this.isQuote(data)) { + if (this.isRenote(data) && !this.isQuote(data)) { if (data.renote.userHost === null) { if (data.renote.userId !== user.id) { const blocked = await this.userBlockingService.checkBlocked(data.renote.userId, user.id); @@ -495,7 +495,7 @@ export class NoteCreateService implements OnApplicationShutdown { } // Check blocking - if (data.renote && !this.isQuote(data)) { + if (this.isRenote(data) && !this.isQuote(data)) { if (data.renote.userHost === null) { if (data.renote.userId !== user.id) { const blocked = await this.userBlockingService.checkBlocked(data.renote.userId, user.id); @@ -670,6 +670,7 @@ export class NoteCreateService implements OnApplicationShutdown { noteVisibility: insert.visibility, userId: user.id, userHost: user.host, + channelId: insert.channelId, }); await transactionalEntityManager.insert(MiPoll, poll); @@ -863,7 +864,7 @@ export class NoteCreateService implements OnApplicationShutdown { } // If it is renote - if (data.renote) { + if (this.isRenote(data)) { const type = this.isQuote(data) ? 'quote' : 'renote'; // Notify @@ -1063,9 +1064,20 @@ export class NoteCreateService implements OnApplicationShutdown { } @bindThis - private isQuote(note: Option): note is Option & { renote: MiNote } { - // sync with misc/is-quote.ts - return !!note.renote && (!!note.text || !!note.cw || (!!note.files && !!note.files.length) || !!note.poll); + private isRenote(note: Option): note is Option & { renote: MiNote } { + return note.renote != null; + } + + @bindThis + private isQuote(note: Option & { renote: MiNote }): note is Option & { renote: MiNote } & ( + { text: string } | { cw: string } | { reply: MiNote } | { poll: IPoll } | { files: MiDriveFile[] } + ) { + // NOTE: SYNC WITH misc/is-quote.ts + return note.text != null || + note.reply != null || + note.cw != null || + note.poll != null || + (note.files != null && note.files.length > 0); } @bindThis @@ -1141,7 +1153,7 @@ export class NoteCreateService implements OnApplicationShutdown { private async renderNoteOrRenoteActivity(data: Option, note: MiNote) { if (data.localOnly) return null; - const content = data.renote && !this.isQuote(data) + 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); |