X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fapplication%2Fapplication.ts;h=5531d134a1b6f67c14b6b9bc2b8483cccb2eb90d;hb=16c016e8b1d5ca46343d3363f9a49e24c5d7c944;hp=81320b9afeafae058c72947b2c3b1accca5b06b0;hpb=4f0f2ab228d73dbec303914dd59b52f6cdaddf46;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/application/application.ts b/server/models/application/application.ts index 81320b9af..5531d134a 100644 --- a/server/models/application/application.ts +++ b/server/models/application/application.ts @@ -1,6 +1,18 @@ +import * as memoizee from 'memoizee' import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' +import { AttributesOnly } from '@shared/core-utils' import { AccountModel } from '../account/account' +export const getServerActor = memoizee(async function () { + const application = await ApplicationModel.load() + if (!application) throw Error('Could not load Application from database.') + + const actor = application.Account.Actor + actor.Account = application.Account + + return actor +}, { promise: true }) + @DefaultScope(() => ({ include: [ { @@ -13,7 +25,7 @@ import { AccountModel } from '../account/account' tableName: 'application', timestamps: false }) -export class ApplicationModel extends Model { +export class ApplicationModel extends Model>> { @AllowNull(false) @Default(0) @@ -21,6 +33,10 @@ export class ApplicationModel extends Model { @Column migrationVersion: number + @AllowNull(true) + @Column + latestPeerTubeVersion: string + @HasOne(() => AccountModel, { foreignKey: { allowNull: true