1 import * as memoizee from 'memoizee'
2 import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
3 import { AttributesOnly } from '@shared/core-utils'
4 import { AccountModel } from '../account/account'
6 export const getServerActor = memoizee(async function () {
7 const application = await ApplicationModel.load()
8 if (!application) throw Error('Could not load Application from database.')
10 const actor = application.Account.Actor
11 actor.Account = application.Account
16 @DefaultScope(() => ({
25 tableName: 'application',
28 export class ApplicationModel extends Model<Partial<AttributesOnly<ApplicationModel>>> {
34 migrationVersion: number
38 latestPeerTubeVersion: string
40 @HasOne(() => AccountModel, {
48 static countTotal () {
49 return ApplicationModel.count()
53 return ApplicationModel.findOne()