Built motion from commit (unavailable).|2.5.21
[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 _0x927f=['catch','UpdateChatInteraction','update','body','options','where','attributes','limit','AddTagsToChatInteraction','ChatInteraction','find','addTags','ids','spread','AddTags','stringify','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','./chatInteraction.socket','request','then','info','ChatInteraction,\x20%s,\x20%s','request\x20sent','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','error','code','message','result'];(function(_0xa9d0c9,_0x5b7bff){var _0x36d4d5=function(_0x54411f){while(--_0x54411f){_0xa9d0c9['push'](_0xa9d0c9['shift']());}};_0x36d4d5(++_0x5b7bff);}(_0x927f,0x8b));var _0xf927=function(_0x4e192c,_0x52db7f){_0x4e192c=_0x4e192c-0x0;var _0x427f9d=_0x927f[_0x4e192c];return _0x427f9d;};'use strict';var _=require(_0xf927('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xf927('0x1'));var rs=require(_0xf927('0x2'));var fs=require('fs');var Redis=require(_0xf927('0x3'));var db=require(_0xf927('0x4'))['db'];var utils=require(_0xf927('0x5'));var logger=require('../../config/logger')(_0xf927('0x6'));var config=require(_0xf927('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xf927('0x8')]['http']({'port':0x232a});config[_0xf927('0x9')]=_[_0xf927('0xa')](config[_0xf927('0x9')],{'host':_0xf927('0xb'),'port':0x18eb});var socket=require(_0xf927('0xc'))(new Redis(config[_0xf927('0x9')]));require(_0xf927('0xd'))['register'](socket);function respondWithRpcPromise(_0x51efb4,_0x10fc06,_0x4978e3){return new BPromise(function(_0x4a4665,_0x627401){return client[_0xf927('0xe')](_0x51efb4,_0x4978e3)[_0xf927('0xf')](function(_0x1a02f4){logger[_0xf927('0x10')](_0xf927('0x11'),_0x10fc06,_0xf927('0x12'));logger[_0xf927('0x13')](_0xf927('0x14'),_0x10fc06,_0xf927('0x12'),JSON['stringify'](_0x1a02f4));if(_0x1a02f4[_0xf927('0x15')]){if(_0x1a02f4[_0xf927('0x15')][_0xf927('0x16')]===0x1f4){logger['error']('ChatInteraction,\x20%s,\x20%s',_0x10fc06,_0x1a02f4[_0xf927('0x15')]['message']);return _0x627401(_0x1a02f4['error']['message']);}logger[_0xf927('0x15')](_0xf927('0x11'),_0x10fc06,_0x1a02f4['error'][_0xf927('0x17')]);return _0x4a4665(_0x1a02f4[_0xf927('0x15')][_0xf927('0x17')]);}else{logger[_0xf927('0x10')]('ChatInteraction,\x20%s,\x20%s',_0x10fc06,_0xf927('0x12'));_0x4a4665(_0x1a02f4[_0xf927('0x18')][_0xf927('0x17')]);}})[_0xf927('0x19')](function(_0x5e154c){logger[_0xf927('0x15')](_0xf927('0x11'),_0x10fc06,_0x5e154c);_0x627401(_0x5e154c);});});}exports[_0xf927('0x1a')]=function(_0x569acb){var _0x3577f1=this;return new Promise(function(_0x3380ed,_0x3df6c3){return db['ChatInteraction'][_0xf927('0x1b')](_0x569acb[_0xf927('0x1c')],{'raw':_0x569acb['options']?_0x569acb[_0xf927('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x569acb[_0xf927('0x1d')]?_0x569acb[_0xf927('0x1d')][_0xf927('0x1e')]||null:null,'attributes':_0x569acb[_0xf927('0x1d')]?_0x569acb[_0xf927('0x1d')][_0xf927('0x1f')]||null:null,'limit':_0x569acb[_0xf927('0x1d')]?_0x569acb[_0xf927('0x1d')][_0xf927('0x20')]||null:null})[_0xf927('0xf')](function(_0x2f2f93){logger[_0xf927('0x10')](_0xf927('0x1a'),_0x569acb);logger[_0xf927('0x13')](_0xf927('0x1a'),_0x569acb,JSON['stringify'](_0x2f2f93));_0x3380ed(_0x2f2f93);})[_0xf927('0x19')](function(_0x5da887){logger[_0xf927('0x15')](_0xf927('0x1a'),_0x5da887[_0xf927('0x17')],_0x569acb);_0x3df6c3(_0x3577f1['error'](0x1f4,_0x5da887[_0xf927('0x17')]));});});};exports[_0xf927('0x21')]=function(_0x459be3){return new Promise(function(_0xeb3ff8,_0x312c6d){return db[_0xf927('0x22')][_0xf927('0x23')]({'where':_0x459be3[_0xf927('0x1d')]?_0x459be3['options'][_0xf927('0x1e')]||null:null})[_0xf927('0xf')](function(_0x161c98){if(_0x161c98){return _0x161c98[_0xf927('0x24')](_0x459be3[_0xf927('0x1c')][_0xf927('0x25')],_['omit'](_0x459be3[_0xf927('0x1c')],[_0xf927('0x25'),'id'])||{});}})[_0xf927('0x26')](function(_0x549c03){logger['info']('AddTags',_0x459be3);logger[_0xf927('0x13')](_0xf927('0x27'),_0x459be3,JSON[_0xf927('0x28')](_0x549c03));_0xeb3ff8(_0x549c03);})['catch'](function(_0x24e93b){logger['error'](_0xf927('0x27'),_0x24e93b[_0xf927('0x17')],_0x459be3);_0x312c6d(_this[_0xf927('0x15')](0x1f4,_0x24e93b[_0xf927('0x17')]));});});};