Skip to content
Permalink
Browse files

feat(server): bot deactivated

fix #134
  • Loading branch information...
baskovsky committed Dec 3, 2019
1 parent ab63adc commit fba26bedd487f90ad5c1ab3a2d3dc8ab2e1408c1
Showing with 20 additions and 26 deletions.
  1. +1 −1 .travis.yml
  2. +0 −25 SQL/passports/examples/demo.sql
  3. +19 −0 src/server.js
  4. 0 tests/e2e/passport-db.test.js
@@ -23,7 +23,7 @@ env:
notifications:
email:
recipients:
- denis@baskovsky.ru
- support@gotointeractive.com
on_success: never
on_failure: always

This file was deleted.

@@ -62,6 +62,7 @@ app.use(require('./middlewares/logger'));
// запускать инстанс vzor для каждого активного пользователя
const Vzor = require('./core/vzor');
const { pool } = require('./core/database');
const bot = require('./core/bot');
const passportQueries = require('./db/passport');
const botQueries = require('./db/bot');
await pool.connect(async (connection) => {
@@ -72,6 +73,24 @@ app.use(require('./middlewares/logger'));
const botTable = await connection.one(
botQueries.selectByPassport(passport.id),
);
try {
// пингуем тем самым проверяем пользователя
await bot.sendChatAction(passport.telegram_id, 'typing');
} catch (error) {
logger.error(error);
switch (error.response && error.response.statusCode) {
case 403: {
await connection.query(
botQueries.deactivateByPassportId(passport.id),
);
break;
}
default: {
break;
}
}
return;
}
if (botTable.activated) {
const vzor = new Vzor({
host: 'imap.yandex.ru',
No changes.

0 comments on commit fba26be

Please sign in to comment.
You can’t perform that action at this time.