connectycube
Advanced tools
Comparing version 3.21.1 to 3.22.0
@@ -672,2 +672,3 @@ const Config = require('../cubeConfig'), | ||
replaceSubElement = ChatUtils.getElement(stanza, 'replace'), | ||
reactionsSubElement = ChatUtils.getElement(stanza, 'reactions'), | ||
removeSubElement = ChatUtils.getElement(stanza, 'remove'), | ||
@@ -724,9 +725,11 @@ composing = ChatUtils.getElement(stanza, 'composing'), | ||
if (typeof this.onMessageUpdateListener === 'function') { | ||
Utils.safeCallbackCall(this.onMessageUpdateListener, | ||
ChatUtils.getAttr(replaceSubElement, 'id'), | ||
ChatUtils.getAttr(replaceSubElement, 'last') === "true", | ||
bodyContent, | ||
dialogId, | ||
userId, | ||
extraParamsParsed ? extraParamsParsed.extension : null); | ||
Utils.safeCallbackCall( | ||
this.onMessageUpdateListener, | ||
ChatUtils.getAttr(replaceSubElement, 'id'), | ||
ChatUtils.getAttr(replaceSubElement, 'last') === "true", | ||
bodyContent, | ||
dialogId, | ||
userId, | ||
extraParamsParsed ? extraParamsParsed.extension : null | ||
); | ||
} | ||
@@ -736,2 +739,26 @@ return true; | ||
// reactions | ||
if (reactionsSubElement) { | ||
if (isForwarded && type === 'groupchat') { | ||
return true; | ||
} | ||
if (typeof this.onMessageReactionsListener === 'function') { | ||
const messageId = ChatUtils.getAttr(reactionsSubElement, 'message_id') | ||
const userId = +ChatUtils.getAttr(reactionsSubElement, 'user_id') | ||
const {add, remove} = ChatUtils.parseReactions(reactionsSubElement) | ||
const {dialogId} = extraParamsParsed | ||
Utils.safeCallbackCall( | ||
this.onMessageReactionsListener, | ||
messageId, | ||
userId, | ||
dialogId, | ||
add, | ||
remove, | ||
); | ||
} | ||
return true; | ||
} | ||
// delete message | ||
@@ -738,0 +765,0 @@ if (removeSubElement) { |
@@ -123,2 +123,6 @@ const Utils = require('../cubeInternalUtils'), | ||
let subNode = objChildNodes[i]; | ||
if (typeof subNode === 'string') { | ||
extension[title] = subNode; | ||
continue | ||
} | ||
let subNodeChildNodes = subNode.childNodes || subNode.children; | ||
@@ -128,3 +132,3 @@ let subNodeTagName = subNode.tagName || subNode.name; | ||
if (subNodeChildNodes.length > 1) { | ||
if (subNodeChildNodes.length >= 1) { | ||
extension[title] = this._XMLtoJS(extension[title], subNodeTagName, subNode); | ||
@@ -149,3 +153,3 @@ } else { | ||
} else if (typeof extension[field] === 'object') { | ||
this._JStoXML(field, extension[field], stanza); | ||
this._JStoXML(field, extension[field], stanza.getChild('extraParams')); | ||
} else { | ||
@@ -198,6 +202,5 @@ stanza | ||
if (extraParams.children[c].children.length === 1) { | ||
if (extraParams.children[c].children.length) { | ||
let child = extraParams.children[c]; | ||
extension[child.name] = child.children[0]; | ||
extension = this._XMLtoJS(extension, child.name, child) | ||
} | ||
@@ -239,4 +242,22 @@ } | ||
} | ||
static parseReactions(reactionsEl) { | ||
let reactions = reactionsEl.children | ||
reactions = reactions.map(reactionEl => ({ | ||
add: this.getAttr(reactionEl, 'add') === 'true', | ||
remove: this.getAttr(reactionEl, 'remove') === 'true', | ||
reaction: this.getAttr(reactionEl, 'type') | ||
})) | ||
return reactions.reduce((acc, parsedReaction) => { | ||
if (parsedReaction.add) { | ||
acc['add'] = parsedReaction.reaction | ||
} | ||
if (parsedReaction.remove) { | ||
acc['remove'] = parsedReaction.reaction | ||
} | ||
return acc | ||
}, {}) | ||
} | ||
} | ||
module.exports = ChatInternalUtils; |
@@ -69,4 +69,41 @@ const Config = require('../cubeConfig') | ||
} | ||
listReactions(messageId) { | ||
const ajaxParams = { | ||
type: 'GET', | ||
dataType: 'json', | ||
url: Utils.getUrl(MESSAGES_API_URL, messageId, 'reactions'), | ||
data: {} | ||
} | ||
return this.proxy.ajax(ajaxParams) | ||
} | ||
addReaction(messageId, reaction) { | ||
return this.updateReaction(messageId, reaction) | ||
} | ||
removeReaction(messageId, reaction) { | ||
return this.updateReaction(messageId, null, reaction) | ||
} | ||
updateReaction(messageId, addReaction, removeReaction) { | ||
const params = { } | ||
if (addReaction) { | ||
params['add'] = addReaction | ||
} | ||
if (removeReaction) { | ||
params['remove'] = removeReaction | ||
} | ||
const ajaxParams = { | ||
type: 'PUT', | ||
dataType: 'text', | ||
url: Utils.getUrl(MESSAGES_API_URL, messageId, 'reactions'), | ||
data: params | ||
} | ||
return this.proxy.ajax(ajaxParams) | ||
} | ||
} | ||
module.exports = ChatMessagesService |
{ | ||
"name": "connectycube", | ||
"description": "ConnectyCube chat and video chat JavaScript SDK", | ||
"version": "3.21.1", | ||
"version": "3.22.0", | ||
"homepage": "https://developers.connectycube.com/reactnative", | ||
@@ -84,3 +84,3 @@ "main": "lib/cubeMain.js", | ||
}, | ||
"gitHead": "a8343e3541a29e692d501cf78dc4adb8b7cfd309" | ||
"gitHead": "ff28253df1873046474736446d31012f4e73d55d" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1490812
10098