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:
parent
c1b95838f6
commit
f6cfa5cbb4
@ -12,6 +12,8 @@ import renderDelete from '../../remote/activitypub/renderer/delete';
|
|||||||
import renderTombstone from '../../remote/activitypub/renderer/tombstone';
|
import renderTombstone from '../../remote/activitypub/renderer/tombstone';
|
||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
import { deliverToFollowers } from '../../remote/activitypub/deliver-manager';
|
import { deliverToFollowers } from '../../remote/activitypub/deliver-manager';
|
||||||
|
import { Brackets } from 'typeorm';
|
||||||
|
import { deliverToRelays } from '../relay';
|
||||||
|
|
||||||
export async function deleteFile(file: DriveFile, isExpired = false) {
|
export async function deleteFile(file: DriveFile, isExpired = false) {
|
||||||
if (file.storedInternal) {
|
if (file.storedInternal) {
|
||||||
@ -95,11 +97,13 @@ async function postProcess(file: DriveFile, isExpired = false) {
|
|||||||
if (!Users.isLocalUser(cascadingNote.user)) continue;
|
if (!Users.isLocalUser(cascadingNote.user)) continue;
|
||||||
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${cascadingNote.id}`), cascadingNote.user));
|
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${cascadingNote.id}`), cascadingNote.user));
|
||||||
deliverToFollowers(cascadingNote.user, content); // federate delete msg
|
deliverToFollowers(cascadingNote.user, content); // federate delete msg
|
||||||
|
deliverToRelays(cascadingNote.user, content);
|
||||||
}
|
}
|
||||||
if (!relatedNote.user) continue;
|
if (!relatedNote.user) continue;
|
||||||
if (Users.isLocalUser(relatedNote.user)) {
|
if (Users.isLocalUser(relatedNote.user)) {
|
||||||
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${relatedNote.id}`), relatedNote.user));
|
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${relatedNote.id}`), relatedNote.user));
|
||||||
deliverToFollowers(relatedNote.user, content);
|
deliverToFollowers(relatedNote.user, content);
|
||||||
|
deliverToRelays(relatedNote.user, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notes.createQueryBuilder().delete()
|
Notes.createQueryBuilder().delete()
|
||||||
@ -145,6 +149,10 @@ async function findCascadingNotes(note: Note) {
|
|||||||
const recursive = async (noteId: string) => {
|
const recursive = async (noteId: string) => {
|
||||||
const query = Notes.createQueryBuilder('note')
|
const query = Notes.createQueryBuilder('note')
|
||||||
.where('note.replyId = :noteId', { noteId })
|
.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');
|
.leftJoinAndSelect('note.user', 'user');
|
||||||
const replies = await query.getMany();
|
const replies = await query.getMany();
|
||||||
for (const reply of replies) {
|
for (const reply of replies) {
|
||||||
|
@ -13,6 +13,7 @@ import { notesChart, perUserNotesChart, instanceChart } from '../chart';
|
|||||||
import { deliverToFollowers } from '../../remote/activitypub/deliver-manager';
|
import { deliverToFollowers } from '../../remote/activitypub/deliver-manager';
|
||||||
import { countSameRenotes } from '../../misc/count-same-renotes';
|
import { countSameRenotes } from '../../misc/count-same-renotes';
|
||||||
import { deliverToRelays } from '../relay';
|
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;
|
if (!Users.isLocalUser(cascadingNote.user)) continue;
|
||||||
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${cascadingNote.id}`), cascadingNote.user));
|
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${cascadingNote.id}`), cascadingNote.user));
|
||||||
deliverToFollowers(cascadingNote.user, content);
|
deliverToFollowers(cascadingNote.user, content);
|
||||||
|
deliverToRelays(cascadingNote.user, content);
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -86,6 +88,10 @@ async function findCascadingNotes(note: Note) {
|
|||||||
const recursive = async (noteId: string) => {
|
const recursive = async (noteId: string) => {
|
||||||
const query = Notes.createQueryBuilder('note')
|
const query = Notes.createQueryBuilder('note')
|
||||||
.where('note.replyId = :noteId', { noteId })
|
.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');
|
.leftJoinAndSelect('note.user', 'user');
|
||||||
const replies = await query.getMany();
|
const replies = await query.getMany();
|
||||||
for (const reply of replies) {
|
for (const reply of replies) {
|
||||||
|
Loading…
Reference in New Issue
Block a user