aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/fixtures/peertube-plugin-test-four/main.js
blob: 2e81550c1575e9633b7c7f1d11d2df345b94832e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
async function register ({
  peertubeHelpers,
  registerHook
}) {
  const logger = peertubeHelpers.logger

  logger.info('Hello world from plugin four')

  const username = 'root'
  const results = await peertubeHelpers.database.query(
    'SELECT "email" from "user" WHERE "username" = $username',
    {
      type: 'SELECT',
      bind: { username }
    }
  )

  logger.info('root email is ' + results[0]['email'])

  registerHook({
    target: 'action:api.video.viewed',
    handler: async ({ video }) => {
      await peertubeHelpers.videos.removeVideo(video.id)

      logger.info('Video deleted by plugin four.')
    }
  })
}

async function unregister () {
  return
}

module.exports = {
  register,
  unregister
}

// ###########################################################################