Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / openchannelInteraction / openchannelInteraction.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 _0xa800=['options','raw','where','limit','AddTagsToOpenchannelInteraction','find','addTags','ids','omit','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0xa800,0x184));var _0x0a80=function(_0xaf0b0f,_0x209e37){_0xaf0b0f=_0xaf0b0f-0x0;var _0x9ed5e9=_0xa800[_0xaf0b0f];return _0x9ed5e9;};'use strict';var _=require(_0x0a80('0x0'));var util=require(_0x0a80('0x1'));var moment=require(_0x0a80('0x2'));var BPromise=require(_0x0a80('0x3'));var rs=require(_0x0a80('0x4'));var fs=require('fs');var Redis=require(_0x0a80('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x0a80('0x6'))('rpc');var config=require(_0x0a80('0x7'));var jayson=require(_0x0a80('0x8'));var client=jayson[_0x0a80('0x9')][_0x0a80('0xa')]({'port':0x232a});config[_0x0a80('0xb')]=_['defaults'](config['redis'],{'host':_0x0a80('0xc'),'port':0x18eb});var socket=require(_0x0a80('0xd'))(new Redis(config['redis']));require(_0x0a80('0xe'))[_0x0a80('0xf')](socket);function respondWithRpcPromise(_0x40a214,_0x1e2bd3,_0x412f47){return new BPromise(function(_0x40b42e,_0x408b23){return client[_0x0a80('0x10')](_0x40a214,_0x412f47)[_0x0a80('0x11')](function(_0x2c9bac){logger[_0x0a80('0x12')](_0x0a80('0x13'),_0x1e2bd3,_0x0a80('0x14'));logger[_0x0a80('0x15')](_0x0a80('0x16'),_0x1e2bd3,_0x0a80('0x14'),JSON[_0x0a80('0x17')](_0x2c9bac));if(_0x2c9bac[_0x0a80('0x18')]){if(_0x2c9bac[_0x0a80('0x18')][_0x0a80('0x19')]===0x1f4){logger[_0x0a80('0x18')](_0x0a80('0x13'),_0x1e2bd3,_0x2c9bac[_0x0a80('0x18')][_0x0a80('0x1a')]);return _0x408b23(_0x2c9bac[_0x0a80('0x18')][_0x0a80('0x1a')]);}logger[_0x0a80('0x18')](_0x0a80('0x13'),_0x1e2bd3,_0x2c9bac['error'][_0x0a80('0x1a')]);return _0x40b42e(_0x2c9bac[_0x0a80('0x18')][_0x0a80('0x1a')]);}else{logger[_0x0a80('0x12')](_0x0a80('0x13'),_0x1e2bd3,'request\x20sent');_0x40b42e(_0x2c9bac['result'][_0x0a80('0x1a')]);}})[_0x0a80('0x1b')](function(_0x32a5c5){logger['error'](_0x0a80('0x13'),_0x1e2bd3,_0x32a5c5);_0x408b23(_0x32a5c5);});});}exports[_0x0a80('0x1c')]=function(_0x25f520){var _0x215d87=this;return new Promise(function(_0x370615,_0x3c9552){return db[_0x0a80('0x1d')][_0x0a80('0x1e')](_0x25f520[_0x0a80('0x1f')],{'raw':_0x25f520[_0x0a80('0x20')]?_0x25f520[_0x0a80('0x20')][_0x0a80('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x25f520[_0x0a80('0x20')]?_0x25f520[_0x0a80('0x20')][_0x0a80('0x22')]||null:null,'attributes':_0x25f520[_0x0a80('0x20')]?_0x25f520[_0x0a80('0x20')]['attributes']||null:null,'limit':_0x25f520['options']?_0x25f520['options'][_0x0a80('0x23')]||null:null})[_0x0a80('0x11')](function(_0x700bde){logger[_0x0a80('0x12')](_0x0a80('0x1c'),_0x25f520);logger[_0x0a80('0x15')](_0x0a80('0x1c'),_0x25f520,JSON['stringify'](_0x700bde));_0x370615(_0x700bde);})[_0x0a80('0x1b')](function(_0x435bfb){logger[_0x0a80('0x18')](_0x0a80('0x1c'),_0x435bfb[_0x0a80('0x1a')],_0x25f520);_0x3c9552(_0x215d87[_0x0a80('0x18')](0x1f4,_0x435bfb['message']));});});};exports[_0x0a80('0x24')]=function(_0x39aec3){return new Promise(function(_0x10a599,_0x5dbe4a){return db[_0x0a80('0x1d')][_0x0a80('0x25')]({'where':_0x39aec3[_0x0a80('0x20')]?_0x39aec3[_0x0a80('0x20')][_0x0a80('0x22')]||null:null})[_0x0a80('0x11')](function(_0x528669){if(_0x528669){return _0x528669[_0x0a80('0x26')](_0x39aec3[_0x0a80('0x1f')][_0x0a80('0x27')],_[_0x0a80('0x28')](_0x39aec3[_0x0a80('0x1f')],[_0x0a80('0x27'),'id'])||{});}})['spread'](function(_0x1aeb12){logger[_0x0a80('0x12')](_0x0a80('0x29'),_0x39aec3);logger['debug']('AddTags',_0x39aec3,JSON[_0x0a80('0x17')](_0x1aeb12));_0x10a599(_0x1aeb12);})[_0x0a80('0x1b')](function(_0x4a5b8e){logger['error'](_0x0a80('0x29'),_0x4a5b8e[_0x0a80('0x1a')],_0x39aec3);_0x5dbe4a(_this[_0x0a80('0x18')](0x1f4,_0x4a5b8e[_0x0a80('0x1a')]));});});};