Built motion from commit 3061e47c.|2.6.31
[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 _0x839b=['result','catch','SmsInteraction','update','body','options','raw','where','attributes','limit','debug','UpdateSmsInteraction','stringify','AddTagsToSmsInteraction','find','addTags','omit','AddTags','lodash','moment','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','redis','defaults','socket.io-emitter','request','then','info','SmsInteraction,\x20%s,\x20%s','request\x20sent','SmsInteraction,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x3a3c17,_0x5b7b7e){var _0xd07f21=function(_0xeaad44){while(--_0xeaad44){_0x3a3c17['push'](_0x3a3c17['shift']());}};_0xd07f21(++_0x5b7b7e);}(_0x839b,0xfc));var _0xb839=function(_0x1c6698,_0x4553e0){_0x1c6698=_0x1c6698-0x0;var _0x7c2358=_0x839b[_0x1c6698];return _0x7c2358;};'use strict';var _=require(_0xb839('0x0'));var util=require('util');var moment=require(_0xb839('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb839('0x2'));var db=require(_0xb839('0x3'))['db'];var utils=require(_0xb839('0x4'));var logger=require('../../config/logger')(_0xb839('0x5'));var config=require(_0xb839('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xb839('0x7')][_0xb839('0x8')]({'port':0x232a});config[_0xb839('0x9')]=_[_0xb839('0xa')](config[_0xb839('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0xb839('0xb'))(new Redis(config['redis']));require('./smsInteraction.socket')['register'](socket);function respondWithRpcPromise(_0x5672ae,_0x14ba74,_0x14c3d1){return new BPromise(function(_0x3cd4cf,_0x3ad1cd){return client[_0xb839('0xc')](_0x5672ae,_0x14c3d1)[_0xb839('0xd')](function(_0x45371c){logger[_0xb839('0xe')](_0xb839('0xf'),_0x14ba74,_0xb839('0x10'));logger['debug'](_0xb839('0x11'),_0x14ba74,'request\x20sent',JSON['stringify'](_0x45371c));if(_0x45371c[_0xb839('0x12')]){if(_0x45371c['error'][_0xb839('0x13')]===0x1f4){logger[_0xb839('0x12')](_0xb839('0xf'),_0x14ba74,_0x45371c[_0xb839('0x12')][_0xb839('0x14')]);return _0x3ad1cd(_0x45371c[_0xb839('0x12')][_0xb839('0x14')]);}logger[_0xb839('0x12')]('SmsInteraction,\x20%s,\x20%s',_0x14ba74,_0x45371c[_0xb839('0x12')][_0xb839('0x14')]);return _0x3cd4cf(_0x45371c[_0xb839('0x12')]['message']);}else{logger[_0xb839('0xe')](_0xb839('0xf'),_0x14ba74,_0xb839('0x10'));_0x3cd4cf(_0x45371c[_0xb839('0x15')]['message']);}})[_0xb839('0x16')](function(_0x2906a9){logger[_0xb839('0x12')](_0xb839('0xf'),_0x14ba74,_0x2906a9);_0x3ad1cd(_0x2906a9);});});}exports['UpdateSmsInteraction']=function(_0x32a920){var _0xde790b=this;return new Promise(function(_0x4eeb13,_0x2a09fc){return db[_0xb839('0x17')][_0xb839('0x18')](_0x32a920[_0xb839('0x19')],{'raw':_0x32a920[_0xb839('0x1a')]?_0x32a920[_0xb839('0x1a')][_0xb839('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x32a920[_0xb839('0x1a')]?_0x32a920[_0xb839('0x1a')][_0xb839('0x1c')]||null:null,'attributes':_0x32a920[_0xb839('0x1a')]?_0x32a920[_0xb839('0x1a')][_0xb839('0x1d')]||null:null,'limit':_0x32a920['options']?_0x32a920[_0xb839('0x1a')][_0xb839('0x1e')]||null:null})['then'](function(_0x37bbdd){logger[_0xb839('0xe')]('UpdateSmsInteraction',_0x32a920);logger[_0xb839('0x1f')](_0xb839('0x20'),_0x32a920,JSON[_0xb839('0x21')](_0x37bbdd));_0x4eeb13(_0x37bbdd);})[_0xb839('0x16')](function(_0x47479e){logger[_0xb839('0x12')]('UpdateSmsInteraction',_0x47479e[_0xb839('0x14')],_0x32a920);_0x2a09fc(_0xde790b['error'](0x1f4,_0x47479e[_0xb839('0x14')]));});});};exports[_0xb839('0x22')]=function(_0x27ed3a){return new Promise(function(_0x467306,_0x49955c){return db['SmsInteraction'][_0xb839('0x23')]({'where':_0x27ed3a[_0xb839('0x1a')]?_0x27ed3a[_0xb839('0x1a')][_0xb839('0x1c')]||null:null})[_0xb839('0xd')](function(_0x457344){if(_0x457344){return _0x457344[_0xb839('0x24')](_0x27ed3a['body']['ids'],_[_0xb839('0x25')](_0x27ed3a[_0xb839('0x19')],['ids','id'])||{});}})['spread'](function(_0x48a539){logger[_0xb839('0xe')]('AddTags',_0x27ed3a);logger[_0xb839('0x1f')](_0xb839('0x26'),_0x27ed3a,JSON[_0xb839('0x21')](_0x48a539));_0x467306(_0x48a539);})[_0xb839('0x16')](function(_0x539b72){logger[_0xb839('0x12')]('AddTags',_0x539b72[_0xb839('0x14')],_0x27ed3a);_0x49955c(_this[_0xb839('0x12')](0x1f4,_0x539b72[_0xb839('0x14')]));});});};