aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-20 11:31:48 +0200
committerChocobozzz <me@florianbigard.com>2018-09-20 11:45:59 +0200
commitf201a749929ec8094a7ba6bcab7b196870ca5a5e (patch)
tree76c0f5f8a90705b5badb83f64ffdc395e468c1a9 /server/models/account/user.ts
parent91411dba928678c15a5e99d9795ae061909e397d (diff)
downloadPeerTube-f201a749929ec8094a7ba6bcab7b196870ca5a5e.tar.gz
PeerTube-f201a749929ec8094a7ba6bcab7b196870ca5a5e.tar.zst
PeerTube-f201a749929ec8094a7ba6bcab7b196870ca5a5e.zip
Cache user token
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r--server/models/account/user.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 680b1d52d..e56b0bf40 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -1,5 +1,7 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { 2import {
3 AfterDelete,
4 AfterUpdate,
3 AllowNull, 5 AllowNull,
4 BeforeCreate, 6 BeforeCreate,
5 BeforeUpdate, 7 BeforeUpdate,
@@ -39,6 +41,7 @@ import { AccountModel } from './account'
39import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' 41import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
40import { values } from 'lodash' 42import { values } from 'lodash'
41import { NSFW_POLICY_TYPES } from '../../initializers' 43import { NSFW_POLICY_TYPES } from '../../initializers'
44import { clearCacheByUserId } from '../../lib/oauth-model'
42 45
43enum ScopeNames { 46enum ScopeNames {
44 WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL' 47 WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'
@@ -168,6 +171,12 @@ export class UserModel extends Model<UserModel> {
168 } 171 }
169 } 172 }
170 173
174 @AfterUpdate
175 @AfterDelete
176 static removeTokenCache (instance: UserModel) {
177 return clearCacheByUserId(instance.id)
178 }
179
171 static countTotal () { 180 static countTotal () {
172 return this.count() 181 return this.count()
173 } 182 }