chat-platform 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chat-platform",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Universal Chat Platform",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,7 +31,7 @@ function SQLiteFactory(params) {
31
31
  throw 'SQLite context provider: missing parameter "dbPath"';
32
32
  }
33
33
  if (_.isEmpty(params.chatbotId)) {
34
- throw 'SQLite context provider: missing parameter "chatbotId"';
34
+ throw 'SQLite context provider: missing parameter "chatbotId", if using the SQLite context store standalone, just add a key "chatbotId": "my-bot" in the params of the context store.';
35
35
  }
36
36
  if (!fs.existsSync(params.dbPath)) {
37
37
  //throw 'SQLite context provider: "dbPath" (' + params.path + ') doesn\'t exist';
@@ -273,14 +273,14 @@ function SQLiteFactory(params) {
273
273
  DROP INDEX "chatid_userid";
274
274
  DROP INDEX "chatid_chatid";
275
275
  */
276
- // if table doesn't exists, then create
277
- const tableExists = await sequelize.query(
278
- "SELECT name FROM sqlite_master WHERE type='table' AND name='contexts';",
279
- { type: QueryTypes.SELECT }
280
- );
281
- const createTable = tableExists.length === 0;
282
276
  // create the table
283
277
  try {
278
+ // if table doesn't exists, then create
279
+ const tableExists = await sequelize.query(
280
+ "SELECT name FROM sqlite_master WHERE type='table' AND name='contexts';",
281
+ { type: QueryTypes.SELECT }
282
+ );
283
+ const createTable = tableExists.length === 0;
284
284
  if (createTable) {
285
285
  await Context.sync();
286
286
  await ChatId.sync();
@@ -296,7 +296,6 @@ function SQLiteFactory(params) {
296
296
  }
297
297
  } catch(e) {
298
298
  lcd.dump(e, 'Something went wrong creating the SQLite "contexts" table');
299
- throw e;
300
299
  }
301
300
 
302
301
  return true;
@@ -310,6 +309,7 @@ _.extend(SQLiteFactory.prototype, {
310
309
  + ' JSON config like this <pre style="margin-top: 10px;">\n'
311
310
  + '{\n'
312
311
  + '"dbPath": "/my-path/my-database.sqlite"\n'
312
+ + '"chatbotId": "my-bot"\n'
313
313
  + '}</pre>'
314
314
  + '<br/> The table <em>context</em> will be automatically created.',
315
315
  get: function(/*chatId, userId*/) {