Built motion from commit 994c64e1.|2.6.1
[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 _0x2cd5=['where','attributes','limit','UpdateSmsInteraction','catch','AddTagsToSmsInteraction','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','jayson/promise','http','redis','defaults','socket.io-emitter','./smsInteraction.socket','register','then','info','debug','SmsInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','SmsInteraction,\x20%s,\x20%s','message','SmsInteraction','update','body','options','raw'];(function(_0x3bf83f,_0x181cac){var _0x22c4a9=function(_0xb3ff0d){while(--_0xb3ff0d){_0x3bf83f['push'](_0x3bf83f['shift']());}};_0x22c4a9(++_0x181cac);}(_0x2cd5,0xa7));var _0x52cd=function(_0x5cde83,_0x12f5c8){_0x5cde83=_0x5cde83-0x0;var _0xf752b5=_0x2cd5[_0x5cde83];return _0xf752b5;};'use strict';var _=require(_0x52cd('0x0'));var util=require(_0x52cd('0x1'));var moment=require(_0x52cd('0x2'));var BPromise=require(_0x52cd('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x52cd('0x4'));var db=require(_0x52cd('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x52cd('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0x52cd('0x7'));var client=jayson['client'][_0x52cd('0x8')]({'port':0x232a});config[_0x52cd('0x9')]=_[_0x52cd('0xa')](config[_0x52cd('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x52cd('0xb'))(new Redis(config[_0x52cd('0x9')]));require(_0x52cd('0xc'))[_0x52cd('0xd')](socket);function respondWithRpcPromise(_0x2d48f4,_0xc25652,_0x4897dd){return new BPromise(function(_0x13170d,_0x503a81){return client['request'](_0x2d48f4,_0x4897dd)[_0x52cd('0xe')](function(_0x2a37e9){logger[_0x52cd('0xf')]('SmsInteraction,\x20%s,\x20%s',_0xc25652,'request\x20sent');logger[_0x52cd('0x10')](_0x52cd('0x11'),_0xc25652,'request\x20sent',JSON[_0x52cd('0x12')](_0x2a37e9));if(_0x2a37e9[_0x52cd('0x13')]){if(_0x2a37e9['error'][_0x52cd('0x14')]===0x1f4){logger[_0x52cd('0x13')](_0x52cd('0x15'),_0xc25652,_0x2a37e9[_0x52cd('0x13')][_0x52cd('0x16')]);return _0x503a81(_0x2a37e9[_0x52cd('0x13')][_0x52cd('0x16')]);}logger[_0x52cd('0x13')]('SmsInteraction,\x20%s,\x20%s',_0xc25652,_0x2a37e9[_0x52cd('0x13')]['message']);return _0x13170d(_0x2a37e9[_0x52cd('0x13')][_0x52cd('0x16')]);}else{logger[_0x52cd('0xf')](_0x52cd('0x15'),_0xc25652,'request\x20sent');_0x13170d(_0x2a37e9['result'][_0x52cd('0x16')]);}})['catch'](function(_0x3b0df7){logger[_0x52cd('0x13')](_0x52cd('0x15'),_0xc25652,_0x3b0df7);_0x503a81(_0x3b0df7);});});}exports['UpdateSmsInteraction']=function(_0xd43e9e){var _0x34af92=this;return new Promise(function(_0x3a4652,_0x589c8f){return db[_0x52cd('0x17')][_0x52cd('0x18')](_0xd43e9e[_0x52cd('0x19')],{'raw':_0xd43e9e['options']?_0xd43e9e[_0x52cd('0x1a')][_0x52cd('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xd43e9e[_0x52cd('0x1a')]?_0xd43e9e['options'][_0x52cd('0x1c')]||null:null,'attributes':_0xd43e9e[_0x52cd('0x1a')]?_0xd43e9e['options'][_0x52cd('0x1d')]||null:null,'limit':_0xd43e9e[_0x52cd('0x1a')]?_0xd43e9e[_0x52cd('0x1a')][_0x52cd('0x1e')]||null:null})[_0x52cd('0xe')](function(_0x506b8d){logger[_0x52cd('0xf')](_0x52cd('0x1f'),_0xd43e9e);logger[_0x52cd('0x10')]('UpdateSmsInteraction',_0xd43e9e,JSON[_0x52cd('0x12')](_0x506b8d));_0x3a4652(_0x506b8d);})[_0x52cd('0x20')](function(_0x2d662e){logger[_0x52cd('0x13')](_0x52cd('0x1f'),_0x2d662e[_0x52cd('0x16')],_0xd43e9e);_0x589c8f(_0x34af92['error'](0x1f4,_0x2d662e['message']));});});};exports[_0x52cd('0x21')]=function(_0x51a7bb){return new Promise(function(_0x24b86f,_0x3a8f66){return db[_0x52cd('0x17')]['find']({'where':_0x51a7bb[_0x52cd('0x1a')]?_0x51a7bb[_0x52cd('0x1a')][_0x52cd('0x1c')]||null:null})[_0x52cd('0xe')](function(_0x2059a0){if(_0x2059a0){return _0x2059a0[_0x52cd('0x22')](_0x51a7bb[_0x52cd('0x19')][_0x52cd('0x23')],_[_0x52cd('0x24')](_0x51a7bb['body'],[_0x52cd('0x23'),'id'])||{});}})[_0x52cd('0x25')](function(_0x55f6c2){logger[_0x52cd('0xf')](_0x52cd('0x26'),_0x51a7bb);logger[_0x52cd('0x10')](_0x52cd('0x26'),_0x51a7bb,JSON[_0x52cd('0x12')](_0x55f6c2));_0x24b86f(_0x55f6c2);})[_0x52cd('0x20')](function(_0x149f15){logger[_0x52cd('0x13')]('AddTags',_0x149f15['message'],_0x51a7bb);_0x3a8f66(_this[_0x52cd('0x13')](0x1f4,_0x149f15['message']));});});};