]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/fixtures/peertube-plugin-test-four/main.js
8df456c8a13447d1a2e9a19783f62bb4916e0827
1 async
function register ({
6 const logger
= peertubeHelpers
.logger
8 logger
.info('Hello world from plugin four')
11 const username
= 'root'
12 const results
= await peertubeHelpers
.database
.query(
13 'SELECT "email" from "user" WHERE "username" = $username',
20 logger
.info('root email is ' + results
[0]['email'])
25 target: 'action:api.video.viewed',
26 handler: async ({ video
}) => {
27 const videoFromDB1
= await peertubeHelpers
.videos
.loadByUrl(video
.url
)
28 const videoFromDB2
= await peertubeHelpers
.videos
.loadByIdOrUUID(video
.id
)
29 const videoFromDB3
= await peertubeHelpers
.videos
.loadByIdOrUUID(video
.uuid
)
31 if (videoFromDB1
.uuid
!== videoFromDB2
.uuid
|| videoFromDB2
.uuid
!== videoFromDB3
.uuid
) return
33 logger
.info('video from DB uuid is %s.', videoFromDB1
.uuid
)
35 await peertubeHelpers
.videos
.removeVideo(video
.id
)
37 logger
.info('Video deleted by plugin four.')
43 const serverActor
= await peertubeHelpers
.server
.getServerActor()
44 logger
.info('server actor name is %s', serverActor
.preferredUsername
)
48 logger
.info('server url is %s', peertubeHelpers
.config
.getWebserverUrl())
61 const router
= getRouter()
62 router
.post('/commander', async (req
, res
) => {
64 await actions
[req
.body
.command
](peertubeHelpers
, req
.body
)
68 logger
.error('Error in commander.', { err
})
75 async
function unregister () {
84 // ###########################################################################
86 async
function blockServer (peertubeHelpers
, body
) {
87 const serverActor
= await peertubeHelpers
.server
.getServerActor()
89 await peertubeHelpers
.moderation
.blockServer({ byAccountId: serverActor
.Account
.id
, hostToBlock: body
.hostToBlock
})
92 async
function unblockServer (peertubeHelpers
, body
) {
93 const serverActor
= await peertubeHelpers
.server
.getServerActor()
95 await peertubeHelpers
.moderation
.unblockServer({ byAccountId: serverActor
.Account
.id
, hostToUnblock: body
.hostToUnblock
})
98 async
function blockAccount (peertubeHelpers
, body
) {
99 const serverActor
= await peertubeHelpers
.server
.getServerActor()
101 await peertubeHelpers
.moderation
.blockAccount({ byAccountId: serverActor
.Account
.id
, handleToBlock: body
.handleToBlock
})
104 async
function unblockAccount (peertubeHelpers
, body
) {
105 const serverActor
= await peertubeHelpers
.server
.getServerActor()
107 await peertubeHelpers
.moderation
.unblockAccount({ byAccountId: serverActor
.Account
.id
, handleToUnblock: body
.handleToUnblock
})
110 async
function blacklist (peertubeHelpers
, body
) {
111 await peertubeHelpers
.moderation
.blacklistVideo({
112 videoIdOrUUID: body
.videoUUID
,
117 async
function unblacklist (peertubeHelpers
, body
) {
118 await peertubeHelpers
.moderation
.unblacklistVideo({ videoIdOrUUID: body
.videoUUID
})