botpress-hitl
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -196,3 +196,3 @@ module.exports = | ||
pause: function pause(platform, userId) { | ||
db.setSessionPaused(true, platform, userId, 'code').then(function (sessionId) { | ||
return db.setSessionPaused(true, platform, userId, 'code').then(function (sessionId) { | ||
bp.events.emit('hitl.session', { id: sessionId }); | ||
@@ -203,6 +203,9 @@ bp.events.emit('hitl.session.changed', { id: sessionId, paused: 1 }); | ||
unpause: function unpause(platform, userId) { | ||
db.setSessionPaused(false, platform, userId, 'code').then(function (sessionId) { | ||
return db.setSessionPaused(false, platform, userId, 'code').then(function (sessionId) { | ||
bp.events.emit('hitl.session', { id: sessionId }); | ||
bp.events.emit('hitl.session.changed', { id: sessionId, paused: 0 }); | ||
}); | ||
}, | ||
isPaused: function isPaused(platform, userId) { | ||
return db.isSessionPaused(platform, userId); | ||
} | ||
@@ -417,2 +420,20 @@ }; | ||
function isSessionPaused(platform, userId) { | ||
var sessionId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var toBool = function toBool(s) { | ||
return (0, _botpress.DatabaseHelpers)(knex).bool.parse(s); | ||
}; | ||
if (sessionId) { | ||
return knex('hitl_sessions').where({ id: sessionId }).select('paused').then().get(0).then(function (s) { | ||
return s && toBool(s.paused); | ||
}); | ||
} else { | ||
return knex('hitl_sessions').where({ userId: userId, platform: platform }).select('paused').then().get(0).then(function (s) { | ||
return s && toBool(s.paused); | ||
}); | ||
} | ||
} | ||
function getAllSessions(onlyPaused) { | ||
@@ -451,3 +472,4 @@ var condition = ''; | ||
getSessionData: getSessionData, | ||
getSession: getSession | ||
getSession: getSession, | ||
isSessionPaused: isSessionPaused | ||
}; | ||
@@ -454,0 +476,0 @@ }; |
{ | ||
"name": "botpress-hitl", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Official HITL (Human In The Loop) module for Botpress", | ||
@@ -5,0 +5,0 @@ "main": "bin/node.bundle.js", |
Sorry, the diff of this file is not supported yet
4880360
45861