]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/application/application.ts
Translated using Weblate (German)
[github/Chocobozzz/PeerTube.git] / server / models / application / application.ts
index 854a5fb368550b4744fa194637c9f1631f1ab2a8..e3939383be804d9d346d6f709390e5d1b6fb11e2 100644 (file)
@@ -1,18 +1,31 @@
+import 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'
 
-@DefaultScope({
+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: [
     {
-      model: () => AccountModel,
+      model: AccountModel,
       required: true
     }
   ]
-})
+}))
 @Table({
-  tableName: 'application'
+  tableName: 'application',
+  timestamps: false
 })
-export class ApplicationModel extends Model<ApplicationModel> {
+export class ApplicationModel extends Model<Partial<AttributesOnly<ApplicationModel>>> {
 
   @AllowNull(false)
   @Default(0)
@@ -20,6 +33,10 @@ export class ApplicationModel extends Model<ApplicationModel> {
   @Column
   migrationVersion: number
 
+  @AllowNull(true)
+  @Column
+  latestPeerTubeVersion: string
+
   @HasOne(() => AccountModel, {
     foreignKey: {
       allowNull: true