Selaa lähdekoodia

- Changed models` props names to more meaningful

Parad0x 5 vuotta sitten
vanhempi
commit
933f331f97
5 muutettua tiedostoa jossa 18 lisäystä ja 14 poistoa
  1. 2 2
      src/bot/app.ts
  2. 1 1
      src/bot/auth.ts
  3. 1 1
      src/connectionHandler.ts
  4. 9 6
      src/db/App.ts
  5. 5 4
      src/db/User.ts

+ 2 - 2
src/bot/app.ts

@@ -126,7 +126,7 @@ function app() {
       });
       ctx.reply(`App registered\n` +
         `Name: ${instance.name}\n` +
-        `Auth: ${instance.auth}`);
+        `Auth: ${instance.authCode}`);
       return;
     } catch (e) {
       ie(4, e);
@@ -155,7 +155,7 @@ function app() {
       return {
         i: el.id,
         n: el.name,
-        a: (el.activated ? "Activated" : "Not activated")
+        a: (el.isActivated ? "Activated" : "Not activated")
       }
     }).map(el => `[${el.i}](${el.n})\t${el.a}\n`).join("");
     const keyboard = [];

+ 1 - 1
src/bot/auth.ts

@@ -40,7 +40,7 @@ function auth(): void {
       });
 
       if (!!ctx.user) {
-        if (ctx.user.permanentBan || ctx.user.isAuthenticated === false) {
+        if (ctx.user.isPermanentlyBanned || ctx.user.isAuthenticated === false) {
           return;
         }
       }

+ 1 - 1
src/connectionHandler.ts

@@ -134,7 +134,7 @@ class Connection {
     let instance = await db.App.create({
       name
     });
-    this.write(`${instance.id}&${instance.auth};`);
+    this.write(`${instance.id}&${instance.authCode};`);
   }
 
   /**

+ 9 - 6
src/db/App.ts

@@ -5,21 +5,24 @@ import randomatic from "randomatic";
 class App extends Model {
   id!: number;
   name!: string;
-  auth!: string;
-  activated!: boolean;
+  authCode!: string;
+  isActivated!: boolean;
 }
 
 App.init({
   name: {
-    type: Sequelize.STRING
+    type: Sequelize.STRING,
+    field: "name"
   },
-  auth: {
+  authCode: {
     type: Sequelize.STRING,
+    field: "auth",
     defaultValue: "",
     unique: true
   },
-  activated: {
+  isActivated: {
     type: Sequelize.BOOLEAN,
+    field: "activated",
     defaultValue: false
   }
 }, {
@@ -31,7 +34,7 @@ App.init({
         randomatic("0", 3),
         randomatic("Aa0", 20)
       ].join("-");
-      app.auth = authCode;
+      app.authCode = authCode;
     }
   }
 });

+ 5 - 4
src/db/User.ts

@@ -4,7 +4,7 @@ import Sequelize, { Model } from "sequelize";
 class User extends Model {
   userTelegramId!: number;
   isAuthenticated!: boolean;
-  permanentBan!: boolean;
+  isPermanentlyBanned!: boolean;
   
   public readonly updatedAt!: Date;
 
@@ -16,11 +16,12 @@ User.init({
   },
   isAuthenticated: {
     type: Sequelize.BOOLEAN,
-    defaultValue: false,
-    field: "activated"
+    field: "activated",
+    defaultValue: false
   },
-  permanentBan: {
+  isPermanentlyBanned: {
     type: Sequelize.BOOLEAN,
+    field: "permanentBan",
     defaultValue: false
   }
 }, {