Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Optimize updating oauth tokens activity

Chocobozzzbbc1afada563
diff --git a/client/angular.json b/client/angular.json
index a63a14e583..9e07951545 100644
--- a/client/angular.json
+++ b/client/angular.json
@@ -185,7 +185,7 @@
"."
],
"sass": {
- "silenceDeprecations": [ "import", "mixed-decls", "color-functions", "global-builtin" ]
+ "silenceDeprecations": [ "import", "color-functions", "global-builtin" ]
}
},
"assets": [
diff --git a/client/src/standalone/build-tools/vite-utils.ts b/client/src/standalone/build-tools/vite-utils.ts
index bf366659cf..60297ac9ed 100644
--- a/client/src/standalone/build-tools/vite-utils.ts
+++ b/client/src/standalone/build-tools/vite-utils.ts
@@ -7,7 +7,7 @@ export function getCSSConfig (root: string) {
api: 'modern-compiler',
loadPaths: [ resolve(root, './src/sass/include') ],
// FIXME: Wait for bootstrap upgrade that fixes deprecated sass utils
- silenceDeprecations: [ 'import', 'mixed-decls', 'color-functions', 'global-builtin' ]
+ silenceDeprecations: [ 'import', 'color-functions', 'global-builtin' ]
}
}
}
diff --git a/server/core/lib/schedulers/update-token-session-scheduler.ts b/server/core/lib/schedulers/update-token-session-scheduler.ts
index b6e5a2b8e0..67826617f4 100644
--- a/server/core/lib/schedulers/update-token-session-scheduler.ts
+++ b/server/core/lib/schedulers/update-token-session-scheduler.ts
@@ -3,7 +3,6 @@ import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js'
import { AbstractScheduler } from './abstract-scheduler.js'
type UpdatePayload = {
- id: number
lastActivityDate: Date
lastActivityIP: string
lastActivityDevice: string
@@ -14,29 +13,27 @@ export class UpdateTokenSessionScheduler extends AbstractScheduler {
protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.UPDATE_TOKEN_SESSION
- private readonly toUpdate = new Set<UpdatePayload>()
+ private toUpdate = new Map<number, UpdatePayload>()
private constructor () {
super()
}
- addToUpdate (payload: UpdatePayload) {
- this.toUpdate.add(payload)
+ addToUpdate (id: number, payload: UpdatePayload) {
+ this.toUpdate.set(id, payload)
}
protected async internalExecute () {
- const toUpdate = Array.from(this.toUpdate)
- this.toUpdate.clear()
+ const entriesToUpdate = this.toUpdate.entries()
+ this.toUpdate = new Map()
- for (const payload of toUpdate) {
+ for (const [ id, payload ] of entriesToUpdate) {
await OAuthTokenModel.update({
lastActivityDate: payload.lastActivityDate,
lastActivityIP: payload.lastActivityIP,
lastActivityDevice: payload.lastActivityDevice
}, {
- where: {
- id: payload.id
- },
+ where: { id },
// Prevent tokens cache invalidation, we don't update fields that are meaningful for this cache
hooks: false
})
diff --git a/server/core/middlewares/auth.ts b/server/core/middlewares/auth.ts
index fc5fe5a048..c0460b5464 100644
--- a/server/core/middlewares/auth.ts
+++ b/server/core/middlewares/auth.ts
@@ -13,8 +13,7 @@ export function authenticate (req: express.Request, res: express.Response, next:
res.locals.oauth = { token }
res.locals.authenticated = true
- UpdateTokenSessionScheduler.Instance.addToUpdate({
- id: token.id,
+ UpdateTokenSessionScheduler.Instance.addToUpdate(token.id, {
lastActivityDate: new Date(),
lastActivityIP: req.ip,
lastActivityDevice: req.header('user-agent')