]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/application/application.ts
Translated using Weblate (Vietnamese)
[github/Chocobozzz/PeerTube.git] / server / models / application / application.ts
index 21f8b1cbc70acc65c96e24c829ee65fdca1bffad..c51ceb2454b3990344c6d7c163400abc83fa3ceb 100644 (file)
@@ -1,6 +1,8 @@
+import memoizee from 'memoizee'
 import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
+import { getNodeABIVersion } from '@server/helpers/version'
+import { AttributesOnly } from '@shared/typescript-utils'
 import { AccountModel } from '../account/account'
-import * as memoizee from 'memoizee'
 
 export const getServerActor = memoizee(async function () {
   const application = await ApplicationModel.load()
@@ -24,7 +26,7 @@ export const getServerActor = memoizee(async function () {
   tableName: 'application',
   timestamps: false
 })
-export class ApplicationModel extends Model {
+export class ApplicationModel extends Model<Partial<AttributesOnly<ApplicationModel>>> {
 
   @AllowNull(false)
   @Default(0)
@@ -36,6 +38,14 @@ export class ApplicationModel extends Model {
   @Column
   latestPeerTubeVersion: string
 
+  @AllowNull(false)
+  @Column
+  nodeVersion: string
+
+  @AllowNull(false)
+  @Column
+  nodeABIVersion: number
+
   @HasOne(() => AccountModel, {
     foreignKey: {
       allowNull: true
@@ -51,4 +61,19 @@ export class ApplicationModel extends Model {
   static load () {
     return ApplicationModel.findOne()
   }
+
+  static async nodeABIChanged () {
+    const application = await this.load()
+
+    return application.nodeABIVersion !== getNodeABIVersion()
+  }
+
+  static async updateNodeVersions () {
+    const application = await this.load()
+
+    application.nodeABIVersion = getNodeABIVersion()
+    application.nodeVersion = process.version
+
+    await application.save()
+  }
 }