Skip to content

Commit

Permalink
Merge pull request #627 from prey/Fix-triggers-should-not-send-in-action
Browse files Browse the repository at this point in the history
Now triggers won't be sending information to actions endpoint
  • Loading branch information
SoraKenji authored Jun 6, 2022
2 parents 20560da + 5487d2f commit 2a9de86
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/agent/plugins/control-panel/websockets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ exports.heartbeat = () => {
};

exports.startWebsocket = () => {
notifyActionInterval = setInterval(retryQueuedResponses, 1000); // <-revisar el tiempo
getStatusInterval = setInterval(getStatusByInterval, 3 * 60 * 1000);
const proxy = config.get('try_proxy');
let protocol = config.get('protocol');
const host = config.get('host');
Expand Down Expand Up @@ -113,13 +111,15 @@ exports.startWebsocket = () => {
logger.debug('Setting up proxy');
}
statusTrigger.get_status((err, status) => {
exports.notify_status(status);
// Create websocket
ws = new WebSocket(`${protocol}://${url}`, options);

ws.on('open', () => {
exports.heartbeat();
storage.do('all', { type: 'responses' }, (errs, actions) => {
exports.notify_status(status);
notifyActionInterval = setInterval(retryQueuedResponses, 5000); // <-revisar el tiempo
getStatusInterval = setInterval(getStatusByInterval, 3 * 60 * 1000);
if (!actions || typeof actions === 'undefined') return;
if (actions.length === 0 || errs) return;
if (Array.isArray(actions)) {
Expand Down Expand Up @@ -188,8 +188,7 @@ exports.startWebsocket = () => {
};

exports.notify_action = (status, id, action, opts, time, respId, retries = 0) => {
if (!id) return;
if (id === 'report') return;
if (!id || id === 'report' || action === 'triggers') return;
if (retries >= 10) {
storage.do('del', { type: 'responses', id: respId });
exports.responses_queue = exports.responses_queue.filter((x) => x.id !== respId);
Expand Down

0 comments on commit 2a9de86

Please sign in to comment.