aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/server/plugin.ts79
1 files changed, 79 insertions, 0 deletions
diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts
new file mode 100644
index 000000000..7ce376d13
--- /dev/null
+++ b/server/models/server/plugin.ts
@@ -0,0 +1,79 @@
1import { AllowNull, Column, CreatedAt, DataType, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
2import { throwIfNotValid } from '../utils'
3import {
4 isPluginDescriptionValid,
5 isPluginNameValid,
6 isPluginTypeValid,
7 isPluginVersionValid
8} from '../../helpers/custom-validators/plugins'
9
10@Table({
11 tableName: 'plugin',
12 indexes: [
13 {
14 fields: [ 'name' ],
15 unique: true
16 }
17 ]
18})
19export class PluginModel extends Model<PluginModel> {
20
21 @AllowNull(false)
22 @Is('PluginName', value => throwIfNotValid(value, isPluginNameValid, 'name'))
23 @Column
24 name: string
25
26 @AllowNull(false)
27 @Is('PluginType', value => throwIfNotValid(value, isPluginTypeValid, 'type'))
28 @Column
29 type: number
30
31 @AllowNull(false)
32 @Is('PluginVersion', value => throwIfNotValid(value, isPluginVersionValid, 'version'))
33 @Column
34 version: string
35
36 @AllowNull(false)
37 @Column
38 enabled: boolean
39
40 @AllowNull(false)
41 @Column
42 uninstalled: boolean
43
44 @AllowNull(false)
45 @Is('PluginPeertubeEngine', value => throwIfNotValid(value, isPluginVersionValid, 'peertubeEngine'))
46 @Column
47 peertubeEngine: string
48
49 @AllowNull(true)
50 @Is('PluginDescription', value => throwIfNotValid(value, isPluginDescriptionValid, 'description'))
51 @Column
52 description: string
53
54 @AllowNull(true)
55 @Column(DataType.JSONB)
56 settings: any
57
58 @AllowNull(true)
59 @Column(DataType.JSONB)
60 storage: any
61
62 @CreatedAt
63 createdAt: Date
64
65 @UpdatedAt
66 updatedAt: Date
67
68 static listEnabledPluginsAndThemes () {
69 const query = {
70 where: {
71 enabled: true,
72 uninstalled: false
73 }
74 }
75
76 return PluginModel.findAll(query)
77 }
78
79}