X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=server%2Flib%2Fplugins%2Fplugin-helpers-builder.ts;h=f1bc24d8b14777eb6563c38cf74c5085aecd2ace;hb=ad35265d743e621d86f3f0796dd9d8795c599dca;hp=d57c69ef0251f0c30353bb4fe7f726f681f494e5;hpb=302eba0d898e38dca14739486441c27c0be6c62f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts index d57c69ef0..f1bc24d8b 100644 --- a/server/lib/plugins/plugin-helpers-builder.ts +++ b/server/lib/plugins/plugin-helpers-builder.ts @@ -17,6 +17,7 @@ import { VideoBlacklistCreate } from '@shared/models' import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../blocklist' import { getServerConfig } from '../config' import { blacklistVideo, unblacklistVideo } from '../video-blacklist' +import { UserModel } from '@server/models/account/user' function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHelpers { const logger = buildPluginLogger(npmName) @@ -163,6 +164,11 @@ function buildPluginRelatedHelpers (plugin: MPlugin, npmName: string) { function buildUserHelpers () { return { - getAuthUser: (res: express.Response) => res.locals.oauth?.token?.User + getAuthUser: (res: express.Response) => { + const user = res.locals.oauth?.token?.User + if (!user) return undefined + + return UserModel.loadByIdFull(user.id) + } } }