Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): We can renote pure renote #12171

Merged
merged 12 commits into from
Oct 30, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- Fix: STLでフォローしていないチャンネルが取得される問題を修正
- Fix: `hashtags/trend`にてRedisからトレンドの情報が取得できない際にInternal Server Errorになる問題を修正
- Fix: HTLをリロードまたは遡行したとき、フォローしているチャンネルのノートが含まれない問題を修正 #11765
- Fix: リノートをリノートできるのを修正

## 2023.10.2

Expand Down
18 changes: 16 additions & 2 deletions packages/backend/src/server/api/endpoints/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,28 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}

function isPureRenote(note: MiNote): boolean {
anatawa12 marked this conversation as resolved.
Show resolved Hide resolved
console.log("isPureRenote", note);
if (!note.renoteId) return false;

console.log("isPureRenote: no renoteId");
if (note.text) return false; // it's quoted with text
console.log("isPureRenote: not quoted with text");
if (note.fileIds.length !== 0) return false; // it's quoted with files
console.log("isPureRenote: not quoted with file");
if (note.hasPoll) return false; // it's quoted with poll
console.log("isPureRenote: not quoted with poll");
return true;
}

let renote: MiNote | null = null;
if (ps.renoteId != null) {
// Fetch renote to note
renote = await this.notesRepository.findOneBy({ id: ps.renoteId });

if (renote == null) {
throw new ApiError(meta.errors.noSuchRenoteTarget);
} else if (renote.renoteId && !renote.text && !renote.fileIds && !renote.hasPoll) {
} else if (isPureRenote(renote)) {
throw new ApiError(meta.errors.cannotReRenote);
}

Expand Down Expand Up @@ -254,7 +268,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-

if (reply == null) {
throw new ApiError(meta.errors.noSuchReplyTarget);
} else if (reply.renoteId && !reply.text && !reply.fileIds && !reply.hasPoll) {
} else if (isPureRenote(reply)) {
throw new ApiError(meta.errors.cannotReplyToPureRenote);
}

Expand Down
Loading