mirror of https://github.com/Chocobozzz/PeerTube
parent
bfa7e364bf
commit
aaa5acbb0c
|
@ -137,7 +137,9 @@ export const serverFilterHookObject = {
|
||||||
// Peertube >= 5.2
|
// Peertube >= 5.2
|
||||||
'filter:feed.podcast.channel.create-custom-tags.result': true,
|
'filter:feed.podcast.channel.create-custom-tags.result': true,
|
||||||
// Peertube >= 5.2
|
// Peertube >= 5.2
|
||||||
'filter:feed.podcast.video.create-custom-tags.result': true
|
'filter:feed.podcast.video.create-custom-tags.result': true,
|
||||||
|
// Peertube >= 6.1
|
||||||
|
'filter:api.user.me.get.result': true
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ServerFilterHookName = keyof typeof serverFilterHookObject
|
export type ServerFilterHookName = keyof typeof serverFilterHookObject
|
||||||
|
|
|
@ -103,6 +103,15 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
|
||||||
handler: obj => addToTotal(obj, 4)
|
handler: obj => addToTotal(obj, 4)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
registerHook({
|
||||||
|
target: 'filter:api.user.me.get.result',
|
||||||
|
handler: (result) => {
|
||||||
|
result.customParam = 'Customized'
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
registerHook({
|
registerHook({
|
||||||
target: 'filter:api.user.me.subscription-videos.list.params',
|
target: 'filter:api.user.me.subscription-videos.list.params',
|
||||||
handler: obj => addToCount(obj)
|
handler: obj => addToCount(obj)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import {
|
import {
|
||||||
HttpStatusCode,
|
HttpStatusCode,
|
||||||
|
MyUser,
|
||||||
PeerTubeProblemDocument,
|
PeerTubeProblemDocument,
|
||||||
VideoDetails,
|
VideoDetails,
|
||||||
VideoImportState,
|
VideoImportState,
|
||||||
|
@ -469,6 +470,14 @@ describe('Test plugin filter hooks', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Users', function () {
|
||||||
|
it('Should run filter:api.user.me.get.result', async function () {
|
||||||
|
const user = await servers[0].users.getMyInfo() as MyUser & { customParam: string }
|
||||||
|
|
||||||
|
expect(user.customParam).to.equal('Customized')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('Should run filter:api.user.signup.allowed.result', function () {
|
describe('Should run filter:api.user.signup.allowed.result', function () {
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
|
|
@ -160,7 +160,13 @@ async function getUserInformation (req: express.Request, res: express.Response)
|
||||||
// We did not load channels in res.locals.user
|
// We did not load channels in res.locals.user
|
||||||
const user = await UserModel.loadForMeAPI(res.locals.oauth.token.user.id)
|
const user = await UserModel.loadForMeAPI(res.locals.oauth.token.user.id)
|
||||||
|
|
||||||
return res.json(user.toMeFormattedJSON())
|
const result = await Hooks.wrapObject(
|
||||||
|
user.toMeFormattedJSON(),
|
||||||
|
'filter:api.user.me.get.result',
|
||||||
|
{ user }
|
||||||
|
)
|
||||||
|
|
||||||
|
return res.json(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserVideoQuotaUsed (req: express.Request, res: express.Response) {
|
async function getUserVideoQuotaUsed (req: express.Request, res: express.Response) {
|
||||||
|
|
Loading…
Reference in New Issue