Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cs-chatbots/router-masterbot-tools

Package Overview
Dependencies
Maintainers
4
Versions
434
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cs-chatbots/router-masterbot-tools - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

2

package.json
{
"name": "@cs-chatbots/router-masterbot-tools",
"version": "0.1.6",
"version": "0.1.7",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

'use strict';
const PROCESS_EVENTS = [
'postback',
'referral',
'optin',
'pass_thread_control',
'message',
'request_thread_control',
'take_thread_control',
'read',
'delivery'
];
class SharedContextPlugin {
/**
* @param {Object} [stateStorage] - chatbot state storage
*/
constructor (stateStorage) {
this.stateStorage = stateStorage;
}
/**
* @param {Object} message - the messaging event object
* @param {string} pageId - id of page (channel), where the event occured
* @param {Sender} messageSender - an instance of Sender class, which allows to send responses
* @returns {Object} - status 200 will stop the dispatching and will be returned
*/
async processMessage (message, pageId, messageSender) {
// Process just pure sharedContext messages
if (message
&& typeof message === 'object'
&& message.sharedContext
&& !PROCESS_EVENTS.some((e) => typeof message[e] !== 'undefined')) {
const { sender, recipient, sharedContext } = message;
const senderId = sender.id === pageId ? recipient.id : sender.id;
const state = await this.stateStorage.getState(senderId, pageId);
if (state) {
const newState = {
...state,
state: {
...state.state,
sharedContext
}
};
await this.stateStorage.saveState(newState);
return { status: 200 };
}
}
return { status: 204 };
}
/**
* @param {Request} req

@@ -7,0 +63,0 @@ * @param {Responder} res

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc