delete fetch logs when a note or user is deleted
This commit is contained in:
parent
dbaeb7f2ac
commit
9de5ecae51
3 changed files with 50 additions and 2 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue