]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/application/application.ts
Fix notification scrollbar color
[github/Chocobozzz/PeerTube.git] / server / models / application / application.ts
CommitLineData
50d6de9c
C
1import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
2import { AccountModel } from '../account/account'
8dc8a34e
C
3import * as memoizee from 'memoizee'
4
5export const getServerActor = memoizee(async function () {
6 const application = await ApplicationModel.load()
7 if (!application) throw Error('Could not load Application from database.')
8
9 const actor = application.Account.Actor
10 actor.Account = application.Account
11
12 return actor
13}, { promise: true })
3fd3ab2d 14
3acc5084 15@DefaultScope(() => ({
50d6de9c
C
16 include: [
17 {
3acc5084 18 model: AccountModel,
50d6de9c
C
19 required: true
20 }
21 ]
3acc5084 22}))
3fd3ab2d 23@Table({
4f0f2ab2
C
24 tableName: 'application',
25 timestamps: false
3fd3ab2d 26})
b49f22d8 27export class ApplicationModel extends Model {
3fd3ab2d
C
28
29 @AllowNull(false)
30 @Default(0)
31 @IsInt
32 @Column
33 migrationVersion: number
34
32a18cbf
C
35 @AllowNull(true)
36 @Column
37 latestPeerTubeVersion: string
38
50d6de9c
C
39 @HasOne(() => AccountModel, {
40 foreignKey: {
41 allowNull: true
42 },
43 onDelete: 'cascade'
44 })
45 Account: AccountModel
46
3fd3ab2d
C
47 static countTotal () {
48 return ApplicationModel.count()
49 }
50d6de9c
C
50
51 static load () {
52 return ApplicationModel.findOne()
53 }
00d6b0dd 54}