aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-09 11:00:30 +0200
committerChocobozzz <me@florianbigard.com>2020-04-09 11:00:30 +0200
commit1b05d82d861f42c27766e9f24d8d55e68b0cf098 (patch)
treebbf14abc606dd3f8f0c13625afbdf3b17fea3a23 /server/lib
parentbc0d801bb7a0cc503c1637f4a07bb51d68d85608 (diff)
downloadPeerTube-1b05d82d861f42c27766e9f24d8d55e68b0cf098.tar.gz
PeerTube-1b05d82d861f42c27766e9f24d8d55e68b0cf098.tar.zst
PeerTube-1b05d82d861f42c27766e9f24d8d55e68b0cf098.zip
Add SQL query support in plugins
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/plugins/plugin-helpers.ts20
-rw-r--r--server/lib/plugins/register-helpers.ts2
2 files changed, 16 insertions, 6 deletions
diff --git a/server/lib/plugins/plugin-helpers.ts b/server/lib/plugins/plugin-helpers.ts
index 36d08d84a..a1493c7df 100644
--- a/server/lib/plugins/plugin-helpers.ts
+++ b/server/lib/plugins/plugin-helpers.ts
@@ -1,11 +1,15 @@
1import { PluginModel } from '@server/models/server/plugin'
2import { PeerTubeHelpers } from '@server/typings/plugins' 1import { PeerTubeHelpers } from '@server/typings/plugins'
2import { sequelizeTypescript } from '@server/initializers/database'
3import { buildLogger } from '@server/helpers/logger'
3 4
4function buildPluginHelpers (npmName: string, plugin: PluginModel): PeerTubeHelpers { 5function buildPluginHelpers (npmName: string): PeerTubeHelpers {
5 const logger = buildLogger(npmName) 6 const logger = buildPluginLogger(npmName)
7
8 const database = buildDatabaseHelpers()
6 9
7 return { 10 return {
8 logger 11 logger,
12 database
9 } 13 }
10} 14}
11 15
@@ -15,6 +19,12 @@ export {
15 19
16// --------------------------------------------------------------------------- 20// ---------------------------------------------------------------------------
17 21
18function buildLogger (npmName: string) { 22function buildPluginLogger (npmName: string) {
19 return buildLogger(npmName) 23 return buildLogger(npmName)
20} 24}
25
26function buildDatabaseHelpers () {
27 return {
28 query: sequelizeTypescript.query.bind(sequelizeTypescript)
29 }
30}
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts
index 58bc96f04..4c0935a05 100644
--- a/server/lib/plugins/register-helpers.ts
+++ b/server/lib/plugins/register-helpers.ts
@@ -35,7 +35,7 @@ function buildRegisterHelpers (npmName: string, plugin: PluginModel): Omit<Regis
35 const videoCategoryManager = buildVideoCategoryManager(npmName) 35 const videoCategoryManager = buildVideoCategoryManager(npmName)
36 const videoLicenceManager = buildVideoLicenceManager(npmName) 36 const videoLicenceManager = buildVideoLicenceManager(npmName)
37 37
38 const peertubeHelpers = buildPluginHelpers(npmName, plugin) 38 const peertubeHelpers = buildPluginHelpers(npmName)
39 39
40 return { 40 return {
41 settingsManager, 41 settingsManager,