Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / smsInteraction / smsInteraction.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 _0x30f4=['options','raw','limit','AddTagsToSmsInteraction','where','addTags','body','ids','omit','spread','AddTags','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./smsInteraction.socket','register','request','then','SmsInteraction,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','UpdateSmsInteraction','update'];(function(_0x461598,_0x4c9a58){var _0x97a7b5=function(_0x2a3404){while(--_0x2a3404){_0x461598['push'](_0x461598['shift']());}};_0x97a7b5(++_0x4c9a58);}(_0x30f4,0xce));var _0x430f=function(_0x300ba2,_0xe84fce){_0x300ba2=_0x300ba2-0x0;var _0x4c780d=_0x30f4[_0x300ba2];return _0x4c780d;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x430f('0x0'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x430f('0x1'));var db=require(_0x430f('0x2'))['db'];var utils=require('../../config/utils');var logger=require(_0x430f('0x3'))(_0x430f('0x4'));var config=require(_0x430f('0x5'));var jayson=require(_0x430f('0x6'));var client=jayson[_0x430f('0x7')][_0x430f('0x8')]({'port':0x232a});config[_0x430f('0x9')]=_[_0x430f('0xa')](config[_0x430f('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x430f('0xb'))(new Redis(config[_0x430f('0x9')]));require(_0x430f('0xc'))[_0x430f('0xd')](socket);function respondWithRpcPromise(_0x2dd8c2,_0x277891,_0x293108){return new BPromise(function(_0x3dc883,_0x19cbbf){return client[_0x430f('0xe')](_0x2dd8c2,_0x293108)[_0x430f('0xf')](function(_0x4b7dcd){logger['info'](_0x430f('0x10'),_0x277891,_0x430f('0x11'));logger[_0x430f('0x12')]('SmsInteraction,\x20%s,\x20%s,\x20%s',_0x277891,_0x430f('0x11'),JSON[_0x430f('0x13')](_0x4b7dcd));if(_0x4b7dcd[_0x430f('0x14')]){if(_0x4b7dcd[_0x430f('0x14')][_0x430f('0x15')]===0x1f4){logger[_0x430f('0x14')](_0x430f('0x10'),_0x277891,_0x4b7dcd[_0x430f('0x14')][_0x430f('0x16')]);return _0x19cbbf(_0x4b7dcd[_0x430f('0x14')][_0x430f('0x16')]);}logger[_0x430f('0x14')]('SmsInteraction,\x20%s,\x20%s',_0x277891,_0x4b7dcd[_0x430f('0x14')][_0x430f('0x16')]);return _0x3dc883(_0x4b7dcd[_0x430f('0x14')][_0x430f('0x16')]);}else{logger[_0x430f('0x17')](_0x430f('0x10'),_0x277891,_0x430f('0x11'));_0x3dc883(_0x4b7dcd[_0x430f('0x18')]['message']);}})[_0x430f('0x19')](function(_0x187418){logger[_0x430f('0x14')](_0x430f('0x10'),_0x277891,_0x187418);_0x19cbbf(_0x187418);});});}exports[_0x430f('0x1a')]=function(_0x61eeda){var _0x212a7d=this;return new Promise(function(_0x64b2b3,_0x1e6227){return db['SmsInteraction'][_0x430f('0x1b')](_0x61eeda['body'],{'raw':_0x61eeda[_0x430f('0x1c')]?_0x61eeda[_0x430f('0x1c')][_0x430f('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x61eeda[_0x430f('0x1c')]?_0x61eeda[_0x430f('0x1c')]['where']||null:null,'attributes':_0x61eeda[_0x430f('0x1c')]?_0x61eeda[_0x430f('0x1c')]['attributes']||null:null,'limit':_0x61eeda[_0x430f('0x1c')]?_0x61eeda['options'][_0x430f('0x1e')]||null:null})['then'](function(_0x1b3121){logger[_0x430f('0x17')](_0x430f('0x1a'),_0x61eeda);logger[_0x430f('0x12')](_0x430f('0x1a'),_0x61eeda,JSON[_0x430f('0x13')](_0x1b3121));_0x64b2b3(_0x1b3121);})['catch'](function(_0x3ba01f){logger[_0x430f('0x14')](_0x430f('0x1a'),_0x3ba01f[_0x430f('0x16')],_0x61eeda);_0x1e6227(_0x212a7d['error'](0x1f4,_0x3ba01f[_0x430f('0x16')]));});});};exports[_0x430f('0x1f')]=function(_0x5a8fe4){return new Promise(function(_0x5599c9,_0x528fd2){return db['SmsInteraction']['find']({'where':_0x5a8fe4['options']?_0x5a8fe4[_0x430f('0x1c')][_0x430f('0x20')]||null:null})[_0x430f('0xf')](function(_0x5db7ef){if(_0x5db7ef){return _0x5db7ef[_0x430f('0x21')](_0x5a8fe4[_0x430f('0x22')][_0x430f('0x23')],_[_0x430f('0x24')](_0x5a8fe4['body'],[_0x430f('0x23'),'id'])||{});}})[_0x430f('0x25')](function(_0x56755a){logger[_0x430f('0x17')]('AddTags',_0x5a8fe4);logger[_0x430f('0x12')](_0x430f('0x26'),_0x5a8fe4,JSON['stringify'](_0x56755a));_0x5599c9(_0x56755a);})['catch'](function(_0xd14933){logger[_0x430f('0x14')](_0x430f('0x26'),_0xd14933[_0x430f('0x16')],_0x5a8fe4);_0x528fd2(_this[_0x430f('0x14')](0x1f4,_0xd14933[_0x430f('0x16')]));});});};