delete fetch logs when a note or user is deleted
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import { createHash } from 'crypto';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { LessThan } from 'typeorm';
|
||||
import { In, LessThan } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { SkApFetchLog, SkApInboxLog, SkApContext } from '@/models/_.js';
|
||||
import type { ApContextsRepository, ApFetchLogsRepository, ApInboxLogsRepository } from '@/models/_.js';
|
||||
@@ -121,6 +121,24 @@ export class ApLogService {
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all logged copies of an object or objects
|
||||
* @param objectUris URIs / AP IDs of the objects to delete
|
||||
*/
|
||||
public async deleteObjectLogs(objectUris: string | string[]): Promise<number> {
|
||||
if (Array.isArray(objectUris)) {
|
||||
const logsDeleted = await this.apFetchLogsRepository.delete({
|
||||
objectUri: In(objectUris),
|
||||
});
|
||||
return logsDeleted.affected ?? 0;
|
||||
} else {
|
||||
const logsDeleted = await this.apFetchLogsRepository.delete({
|
||||
objectUri: objectUris,
|
||||
});
|
||||
return logsDeleted.affected ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all expired AP logs and garbage-collects the AP context cache.
|
||||
* Returns the total number of deleted rows.
|
||||
|
||||
Reference in New Issue
Block a user