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:
parent
a53ed039b8
commit
57caf25611
40 changed files with 1158 additions and 138 deletions
32
server/core/lib/schedulers/update-token-session-scheduler.ts
Normal file
32
server/core/lib/schedulers/update-token-session-scheduler.ts
Normal 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())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue