Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / chatInteraction / chatInteraction.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x95f2=['message','result','catch','UpdateChatInteraction','ChatInteraction','update','body','options','where','attributes','AddTagsToChatInteraction','find','addTags','ids','omit','spread','AddTags','lodash','util','moment','ioredis','../../config/utils','../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./chatInteraction.socket','request','then','info','ChatInteraction,\x20%s,\x20%s','request\x20sent','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x443865,_0x395e48){var _0x139846=function(_0x2d947e){while(--_0x2d947e){_0x443865['push'](_0x443865['shift']());}};_0x139846(++_0x395e48);}(_0x95f2,0xd4));var _0x295f=function(_0xd1c39b,_0x16f0c6){_0xd1c39b=_0xd1c39b-0x0;var _0x58f5bc=_0x95f2[_0xd1c39b];return _0x58f5bc;};'use strict';var _=require(_0x295f('0x0'));var util=require(_0x295f('0x1'));var moment=require(_0x295f('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x295f('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x295f('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0x295f('0x5'));var jayson=require(_0x295f('0x6'));var client=jayson[_0x295f('0x7')][_0x295f('0x8')]({'port':0x232a});config[_0x295f('0x9')]=_['defaults'](config[_0x295f('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x295f('0xa'))(new Redis(config[_0x295f('0x9')]));require(_0x295f('0xb'))['register'](socket);function respondWithRpcPromise(_0x304bff,_0x322c0a,_0x2f7750){return new BPromise(function(_0xd8b4d0,_0x2249e7){return client[_0x295f('0xc')](_0x304bff,_0x2f7750)[_0x295f('0xd')](function(_0x42ae58){logger[_0x295f('0xe')](_0x295f('0xf'),_0x322c0a,_0x295f('0x10'));logger[_0x295f('0x11')](_0x295f('0x12'),_0x322c0a,_0x295f('0x10'),JSON[_0x295f('0x13')](_0x42ae58));if(_0x42ae58[_0x295f('0x14')]){if(_0x42ae58['error'][_0x295f('0x15')]===0x1f4){logger[_0x295f('0x14')]('ChatInteraction,\x20%s,\x20%s',_0x322c0a,_0x42ae58[_0x295f('0x14')][_0x295f('0x16')]);return _0x2249e7(_0x42ae58[_0x295f('0x14')]['message']);}logger['error'](_0x295f('0xf'),_0x322c0a,_0x42ae58[_0x295f('0x14')][_0x295f('0x16')]);return _0xd8b4d0(_0x42ae58[_0x295f('0x14')][_0x295f('0x16')]);}else{logger['info'](_0x295f('0xf'),_0x322c0a,'request\x20sent');_0xd8b4d0(_0x42ae58[_0x295f('0x17')][_0x295f('0x16')]);}})[_0x295f('0x18')](function(_0x4e7cdc){logger['error']('ChatInteraction,\x20%s,\x20%s',_0x322c0a,_0x4e7cdc);_0x2249e7(_0x4e7cdc);});});}exports[_0x295f('0x19')]=function(_0x2d4333){var _0x4a1552=this;return new Promise(function(_0x21e46a,_0x49d477){return db[_0x295f('0x1a')][_0x295f('0x1b')](_0x2d4333[_0x295f('0x1c')],{'raw':_0x2d4333[_0x295f('0x1d')]?_0x2d4333['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2d4333[_0x295f('0x1d')]?_0x2d4333[_0x295f('0x1d')][_0x295f('0x1e')]||null:null,'attributes':_0x2d4333['options']?_0x2d4333[_0x295f('0x1d')][_0x295f('0x1f')]||null:null,'limit':_0x2d4333[_0x295f('0x1d')]?_0x2d4333[_0x295f('0x1d')]['limit']||null:null})[_0x295f('0xd')](function(_0x34fdc1){logger[_0x295f('0xe')](_0x295f('0x19'),_0x2d4333);logger[_0x295f('0x11')](_0x295f('0x19'),_0x2d4333,JSON[_0x295f('0x13')](_0x34fdc1));_0x21e46a(_0x34fdc1);})['catch'](function(_0x8a9273){logger[_0x295f('0x14')]('UpdateChatInteraction',_0x8a9273[_0x295f('0x16')],_0x2d4333);_0x49d477(_0x4a1552[_0x295f('0x14')](0x1f4,_0x8a9273[_0x295f('0x16')]));});});};exports[_0x295f('0x20')]=function(_0x44c810){return new Promise(function(_0x57357e,_0x5e2713){return db[_0x295f('0x1a')][_0x295f('0x21')]({'where':_0x44c810[_0x295f('0x1d')]?_0x44c810[_0x295f('0x1d')][_0x295f('0x1e')]||null:null})['then'](function(_0x352e74){if(_0x352e74){return _0x352e74[_0x295f('0x22')](_0x44c810['body'][_0x295f('0x23')],_[_0x295f('0x24')](_0x44c810[_0x295f('0x1c')],['ids','id'])||{});}})[_0x295f('0x25')](function(_0x595561){logger[_0x295f('0xe')](_0x295f('0x26'),_0x44c810);logger[_0x295f('0x11')](_0x295f('0x26'),_0x44c810,JSON[_0x295f('0x13')](_0x595561));_0x57357e(_0x595561);})[_0x295f('0x18')](function(_0x19117){logger[_0x295f('0x14')](_0x295f('0x26'),_0x19117[_0x295f('0x16')],_0x44c810);_0x5e2713(_this[_0x295f('0x14')](0x1f4,_0x19117[_0x295f('0x16')]));});});};