Fix CASCADE-related problems (#6374)

* Fix renotes remaining on remote when CASCADE is invoked

* Fix CASCADE-invoked deletion not being federated to relays

Co-authored-by: DW <chocological00@gitlab.com>
This commit is contained in:
DW
2020-05-16 11:49:46 -04:00
committed by GitHub
parent c1b95838f6
commit f6cfa5cbb4
2 changed files with 14 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ import { notesChart, perUserNotesChart, instanceChart } from '../chart';
import { deliverToFollowers } from '../../remote/activitypub/deliver-manager';
import { countSameRenotes } from '../../misc/count-same-renotes';
import { deliverToRelays } from '../relay';
import { Brackets } from 'typeorm';
/**
* 投稿を削除します。
@@ -59,6 +60,7 @@ export default async function(user: User, note: Note, quiet = false) {
if (!Users.isLocalUser(cascadingNote.user)) continue;
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${cascadingNote.id}`), cascadingNote.user));
deliverToFollowers(cascadingNote.user, content);
deliverToRelays(cascadingNote.user, content);
}
//#endregion
@@ -86,6 +88,10 @@ async function findCascadingNotes(note: Note) {
const recursive = async (noteId: string) => {
const query = Notes.createQueryBuilder('note')
.where('note.replyId = :noteId', { noteId })
.orWhere(new Brackets(q => {
q.where('note.renoteId = :noteId', { noteId })
.andWhere('note.text IS NOT NULL');
}))
.leftJoinAndSelect('note.user', 'user');
const replies = await query.getMany();
for (const reply of replies) {