mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-13 21:40:45 +01:00
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
2 changed files with 14 additions and 0 deletions
|
@ -12,6 +12,8 @@ import renderDelete from '../../remote/activitypub/renderer/delete';
|
|||
import renderTombstone from '../../remote/activitypub/renderer/tombstone';
|
||||
import config from '../../config';
|
||||
import { deliverToFollowers } from '../../remote/activitypub/deliver-manager';
|
||||
import { Brackets } from 'typeorm';
|
||||
import { deliverToRelays } from '../relay';
|
||||
|
||||
export async function deleteFile(file: DriveFile, isExpired = false) {
|
||||
if (file.storedInternal) {
|
||||
|
@ -95,11 +97,13 @@ async function postProcess(file: DriveFile, isExpired = false) {
|
|||
if (!Users.isLocalUser(cascadingNote.user)) continue;
|
||||
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${cascadingNote.id}`), cascadingNote.user));
|
||||
deliverToFollowers(cascadingNote.user, content); // federate delete msg
|
||||
deliverToRelays(cascadingNote.user, content);
|
||||
}
|
||||
if (!relatedNote.user) continue;
|
||||
if (Users.isLocalUser(relatedNote.user)) {
|
||||
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${relatedNote.id}`), relatedNote.user));
|
||||
deliverToFollowers(relatedNote.user, content);
|
||||
deliverToRelays(relatedNote.user, content);
|
||||
}
|
||||
}
|
||||
Notes.createQueryBuilder().delete()
|
||||
|
@ -145,6 +149,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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue