1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Add ability to list and revoke token sessions

This commit is contained in:
Chocobozzz 2025-07-30 11:33:07 +02:00
parent a53ed039b8
commit 57caf25611
No known key found for this signature in database
GPG key ID: 583A612D890159BE
40 changed files with 1158 additions and 138 deletions

View file

@ -0,0 +1,32 @@
import { MOAuthToken } from '@server/types/models/index.js'
import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js'
import { AbstractScheduler } from './abstract-scheduler.js'
export class UpdateTokenSessionScheduler extends AbstractScheduler {
private static instance: UpdateTokenSessionScheduler
protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.UPDATE_TOKEN_SESSION
private readonly toUpdate = new Set<MOAuthToken>()
private constructor () {
super()
}
addToUpdate (token: MOAuthToken) {
this.toUpdate.add(token)
}
protected async internalExecute () {
const toUpdate = Array.from(this.toUpdate)
this.toUpdate.clear()
for (const token of toUpdate) {
await token.save()
}
}
static get Instance () {
return this.instance || (this.instance = new this())
}
}