Built motion from commit b5a10faa.|2.6.13
[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 _0x2bfb=['SmsInteraction,\x20%s,\x20%s','debug','SmsInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','UpdateSmsInteraction','update','body','options','raw','where','attributes','limit','then','AddTagsToSmsInteraction','SmsInteraction','find','ids','omit','spread','AddTags','lodash','util','moment','randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','info'];(function(_0x2e676b,_0x3a0790){var _0x1cc8ed=function(_0xdc3e1c){while(--_0xdc3e1c){_0x2e676b['push'](_0x2e676b['shift']());}};_0x1cc8ed(++_0x3a0790);}(_0x2bfb,0x12a));var _0xb2bf=function(_0x5e4481,_0x2b619e){_0x5e4481=_0x5e4481-0x0;var _0x5d3a5d=_0x2bfb[_0x5e4481];return _0x5d3a5d;};'use strict';var _=require(_0xb2bf('0x0'));var util=require(_0xb2bf('0x1'));var moment=require(_0xb2bf('0x2'));var BPromise=require('bluebird');var rs=require(_0xb2bf('0x3'));var fs=require('fs');var Redis=require(_0xb2bf('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xb2bf('0x5'));var logger=require('../../config/logger')(_0xb2bf('0x6'));var config=require(_0xb2bf('0x7'));var jayson=require(_0xb2bf('0x8'));var client=jayson[_0xb2bf('0x9')][_0xb2bf('0xa')]({'port':0x232a});config['redis']=_[_0xb2bf('0xb')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb2bf('0xc')]));require('./smsInteraction.socket')['register'](socket);function respondWithRpcPromise(_0xc7c0c3,_0x27e5a5,_0x1c8c7f){return new BPromise(function(_0x4047e7,_0x49bb32){return client['request'](_0xc7c0c3,_0x1c8c7f)['then'](function(_0x176f45){logger[_0xb2bf('0xd')](_0xb2bf('0xe'),_0x27e5a5,'request\x20sent');logger[_0xb2bf('0xf')](_0xb2bf('0x10'),_0x27e5a5,_0xb2bf('0x11'),JSON[_0xb2bf('0x12')](_0x176f45));if(_0x176f45['error']){if(_0x176f45[_0xb2bf('0x13')]['code']===0x1f4){logger[_0xb2bf('0x13')](_0xb2bf('0xe'),_0x27e5a5,_0x176f45[_0xb2bf('0x13')][_0xb2bf('0x14')]);return _0x49bb32(_0x176f45['error']['message']);}logger['error'](_0xb2bf('0xe'),_0x27e5a5,_0x176f45[_0xb2bf('0x13')]['message']);return _0x4047e7(_0x176f45[_0xb2bf('0x13')][_0xb2bf('0x14')]);}else{logger[_0xb2bf('0xd')](_0xb2bf('0xe'),_0x27e5a5,_0xb2bf('0x11'));_0x4047e7(_0x176f45[_0xb2bf('0x15')][_0xb2bf('0x14')]);}})[_0xb2bf('0x16')](function(_0x4d9883){logger['error'](_0xb2bf('0xe'),_0x27e5a5,_0x4d9883);_0x49bb32(_0x4d9883);});});}exports[_0xb2bf('0x17')]=function(_0x21482c){var _0xde80ed=this;return new Promise(function(_0x3ad25a,_0x43a2dd){return db['SmsInteraction'][_0xb2bf('0x18')](_0x21482c[_0xb2bf('0x19')],{'raw':_0x21482c[_0xb2bf('0x1a')]?_0x21482c[_0xb2bf('0x1a')][_0xb2bf('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x21482c[_0xb2bf('0x1a')]?_0x21482c['options'][_0xb2bf('0x1c')]||null:null,'attributes':_0x21482c[_0xb2bf('0x1a')]?_0x21482c[_0xb2bf('0x1a')][_0xb2bf('0x1d')]||null:null,'limit':_0x21482c[_0xb2bf('0x1a')]?_0x21482c['options'][_0xb2bf('0x1e')]||null:null})[_0xb2bf('0x1f')](function(_0x40797c){logger['info'](_0xb2bf('0x17'),_0x21482c);logger[_0xb2bf('0xf')](_0xb2bf('0x17'),_0x21482c,JSON[_0xb2bf('0x12')](_0x40797c));_0x3ad25a(_0x40797c);})[_0xb2bf('0x16')](function(_0x52243b){logger[_0xb2bf('0x13')](_0xb2bf('0x17'),_0x52243b[_0xb2bf('0x14')],_0x21482c);_0x43a2dd(_0xde80ed[_0xb2bf('0x13')](0x1f4,_0x52243b[_0xb2bf('0x14')]));});});};exports[_0xb2bf('0x20')]=function(_0x2ed99d){return new Promise(function(_0x548171,_0x419fdf){return db[_0xb2bf('0x21')][_0xb2bf('0x22')]({'where':_0x2ed99d[_0xb2bf('0x1a')]?_0x2ed99d[_0xb2bf('0x1a')][_0xb2bf('0x1c')]||null:null})['then'](function(_0xc51f77){if(_0xc51f77){return _0xc51f77['addTags'](_0x2ed99d['body'][_0xb2bf('0x23')],_[_0xb2bf('0x24')](_0x2ed99d['body'],['ids','id'])||{});}})[_0xb2bf('0x25')](function(_0x590b77){logger[_0xb2bf('0xd')]('AddTags',_0x2ed99d);logger[_0xb2bf('0xf')](_0xb2bf('0x26'),_0x2ed99d,JSON['stringify'](_0x590b77));_0x548171(_0x590b77);})[_0xb2bf('0x16')](function(_0x1abaa2){logger[_0xb2bf('0x13')]('AddTags',_0x1abaa2['message'],_0x2ed99d);_0x419fdf(_this[_0xb2bf('0x13')](0x1f4,_0x1abaa2[_0xb2bf('0x14')]));});});};