use TimeService everywhere in the backend
This commit is contained in:
parent
ed750fd990
commit
6cceca90f9
123 changed files with 550 additions and 285 deletions
|
|
@ -12,6 +12,7 @@ import type { ApContextsRepository, ApFetchLogsRepository, ApInboxLogsRepository
|
|||
import type { Config } from '@/config.js';
|
||||
import { JsonValue } from '@/misc/json-value.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { IActivity, IObject } from './activitypub/type.js';
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ export class ApLogService {
|
|||
|
||||
private readonly utilityService: UtilityService,
|
||||
private readonly idService: IdService,
|
||||
private readonly timeService: TimeService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
|
@ -46,7 +48,7 @@ export class ApLogService {
|
|||
|
||||
const log = new SkApInboxLog({
|
||||
id: this.idService.gen(),
|
||||
at: new Date(),
|
||||
at: this.timeService.date,
|
||||
verified: false,
|
||||
accepted: false,
|
||||
host,
|
||||
|
|
@ -85,7 +87,7 @@ export class ApLogService {
|
|||
}): Promise<SkApFetchLog> {
|
||||
const log = new SkApFetchLog({
|
||||
id: this.idService.gen(),
|
||||
at: new Date(),
|
||||
at: this.timeService.date,
|
||||
accepted: false,
|
||||
...data,
|
||||
});
|
||||
|
|
@ -163,7 +165,7 @@ export class ApLogService {
|
|||
*/
|
||||
public async deleteExpiredLogs(): Promise<number> {
|
||||
// This is the date in UTC of the oldest log to KEEP
|
||||
const oldestAllowed = new Date(Date.now() - this.config.activityLogging.maxAge);
|
||||
const oldestAllowed = new Date(this.timeService.now - this.config.activityLogging.maxAge);
|
||||
|
||||
// Delete all logs older than the threshold.
|
||||
const inboxDeleted = await this.deleteExpiredInboxLogs(oldestAllowed);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue