Skip to content

Commit

Permalink
fix: 引用RNがpure RNとして連合され、pure RNが引用RNとして連合される (#12744)
Browse files Browse the repository at this point in the history
* fix: quote notes are rendered as pure renote

* fix: filesが指定されてて空配列のときにQuote扱いされる

* chore: isQuoteの仕様をmisc/is-quote.tsと揃える

* docs: is-quote.tsの方にNoteCreateService.isQuoteのことを書いて更新忘れを防ぐ
  • Loading branch information
anatawa12 authored Dec 22, 2023
1 parent 433d46e commit 52b94db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export class NoteCreateService implements OnApplicationShutdown {
}

// Check blocking
if (data.renote && this.isQuote(data)) {
if (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);
Expand Down Expand Up @@ -730,8 +730,9 @@ export class NoteCreateService implements OnApplicationShutdown {
}

@bindThis
private isQuote(note: Option): boolean {
return !!note.text || !!note.cw || !!note.files || !!note.poll;
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);
}

@bindThis
Expand Down Expand Up @@ -799,7 +800,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 = data.renote && !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);

Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/misc/is-quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import type { MiNote } from '@/models/Note.js';

// eslint-disable-next-line import/no-default-export
export default function(note: MiNote): boolean {
// sync with NoteCreateService.isQuote
return note.renoteId != null && (note.text != null || note.hasPoll || (note.fileIds != null && note.fileIds.length > 0));
}

0 comments on commit 52b94db

Please sign in to comment.