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

castle-chat-lib

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

castle-chat-lib - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

2

package.json
{
"name": "castle-chat-lib",
"version": "2.4.0",
"version": "2.5.0",
"description": "",

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

@@ -124,2 +124,79 @@ import _ from 'lodash';

async joinChannelAsync(channelId) {
try {
let joinResult = await this._api.graphqlAsync(
`
mutation($channelId: ID!) {
joinChatChannel(channelId: $channelId) {
channelId
}
}
`,
{
channelId,
}
);
if (joinResult.errors && joinResult.errors.length) {
throw new Error(joinResult.errors);
}
this._socket.emit('join-channels', {
channels: [channelId],
});
let recentMessagesResult = await this._api.graphqlAsync(
`
query($channelId: ID!) {
recentChannelChatMessages(channelId: $channelId) {
chatMessageId
channelId
fromUserId
body
createdTime
}
}
`,
{
channelId,
}
);
if (recentMessagesResult.data && recentMessagesResult.data.recentChannelChatMessages) {
this._handleMessages(recentMessagesResult.data.recentChannelChatMessages);
}
} catch (e) {
console.log('join channel error');
console.log(JSON.stringify(e));
}
}
async leaveChannelAsync(channelId) {
try {
let result = await this._api.graphqlAsync(
`
mutation($channelId: ID!) {
leaveChatChannel(channelId: $channelId) {
channelId
}
}
`,
{
channelId,
}
);
this._socket.emit('leave-channels', {
channels: [channelId],
});
if (result.errors && result.errors.length) {
throw new Error(result.errors);
}
} catch (e) {
console.log('leave channel error');
console.log(JSON.stringify(e));
}
}
async sendMessageAsync(channel, message, postId) {

@@ -126,0 +203,0 @@ try {

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