Built motion from commit 994c64e1.|2.6.1
[motion2.git] / server / api / faxInteraction / faxInteraction.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 _0xa83a=['jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./faxInteraction.socket','request','then','info','FaxInteraction,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','UpdateFaxInteraction','FaxInteraction','update','body','options','where','limit','find','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x25cd96,_0x475a8a){var _0x42d425=function(_0x1aeb9f){while(--_0x1aeb9f){_0x25cd96['push'](_0x25cd96['shift']());}};_0x42d425(++_0x475a8a);}(_0xa83a,0x73));var _0xaa83=function(_0x8ed269,_0x1c29ca){_0x8ed269=_0x8ed269-0x0;var _0x474472=_0xa83a[_0x8ed269];return _0x474472;};'use strict';var _=require(_0xaa83('0x0'));var util=require(_0xaa83('0x1'));var moment=require(_0xaa83('0x2'));var BPromise=require(_0xaa83('0x3'));var rs=require(_0xaa83('0x4'));var fs=require('fs');var Redis=require(_0xaa83('0x5'));var db=require(_0xaa83('0x6'))['db'];var utils=require(_0xaa83('0x7'));var logger=require(_0xaa83('0x8'))(_0xaa83('0x9'));var config=require(_0xaa83('0xa'));var jayson=require(_0xaa83('0xb'));var client=jayson['client'][_0xaa83('0xc')]({'port':0x232a});config[_0xaa83('0xd')]=_[_0xaa83('0xe')](config[_0xaa83('0xd')],{'host':_0xaa83('0xf'),'port':0x18eb});var socket=require(_0xaa83('0x10'))(new Redis(config[_0xaa83('0xd')]));require(_0xaa83('0x11'))['register'](socket);function respondWithRpcPromise(_0x200758,_0x3bdff1,_0x304a37){return new BPromise(function(_0x2975d7,_0x14efbf){return client[_0xaa83('0x12')](_0x200758,_0x304a37)[_0xaa83('0x13')](function(_0x2e1f7e){logger[_0xaa83('0x14')](_0xaa83('0x15'),_0x3bdff1,_0xaa83('0x16'));logger[_0xaa83('0x17')]('FaxInteraction,\x20%s,\x20%s,\x20%s',_0x3bdff1,_0xaa83('0x16'),JSON[_0xaa83('0x18')](_0x2e1f7e));if(_0x2e1f7e[_0xaa83('0x19')]){if(_0x2e1f7e[_0xaa83('0x19')][_0xaa83('0x1a')]===0x1f4){logger[_0xaa83('0x19')](_0xaa83('0x15'),_0x3bdff1,_0x2e1f7e['error']['message']);return _0x14efbf(_0x2e1f7e[_0xaa83('0x19')][_0xaa83('0x1b')]);}logger['error'](_0xaa83('0x15'),_0x3bdff1,_0x2e1f7e[_0xaa83('0x19')][_0xaa83('0x1b')]);return _0x2975d7(_0x2e1f7e[_0xaa83('0x19')][_0xaa83('0x1b')]);}else{logger[_0xaa83('0x14')](_0xaa83('0x15'),_0x3bdff1,_0xaa83('0x16'));_0x2975d7(_0x2e1f7e[_0xaa83('0x1c')][_0xaa83('0x1b')]);}})[_0xaa83('0x1d')](function(_0x4d7bd2){logger['error']('FaxInteraction,\x20%s,\x20%s',_0x3bdff1,_0x4d7bd2);_0x14efbf(_0x4d7bd2);});});}exports[_0xaa83('0x1e')]=function(_0x101c25){var _0x5e2cfc=this;return new Promise(function(_0x2912d7,_0x4fb024){return db[_0xaa83('0x1f')][_0xaa83('0x20')](_0x101c25[_0xaa83('0x21')],{'raw':_0x101c25[_0xaa83('0x22')]?_0x101c25[_0xaa83('0x22')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x101c25['options']?_0x101c25[_0xaa83('0x22')][_0xaa83('0x23')]||null:null,'attributes':_0x101c25[_0xaa83('0x22')]?_0x101c25[_0xaa83('0x22')]['attributes']||null:null,'limit':_0x101c25[_0xaa83('0x22')]?_0x101c25[_0xaa83('0x22')][_0xaa83('0x24')]||null:null})[_0xaa83('0x13')](function(_0x549b88){logger[_0xaa83('0x14')](_0xaa83('0x1e'),_0x101c25);logger[_0xaa83('0x17')]('UpdateFaxInteraction',_0x101c25,JSON['stringify'](_0x549b88));_0x2912d7(_0x549b88);})[_0xaa83('0x1d')](function(_0x203fe9){logger[_0xaa83('0x19')]('UpdateFaxInteraction',_0x203fe9[_0xaa83('0x1b')],_0x101c25);_0x4fb024(_0x5e2cfc[_0xaa83('0x19')](0x1f4,_0x203fe9[_0xaa83('0x1b')]));});});};exports['AddTagsToFaxInteraction']=function(_0x591ffd){return new Promise(function(_0x149448,_0x57ea43){return db[_0xaa83('0x1f')][_0xaa83('0x25')]({'where':_0x591ffd[_0xaa83('0x22')]?_0x591ffd[_0xaa83('0x22')]['where']||null:null})[_0xaa83('0x13')](function(_0x18dc3f){if(_0x18dc3f){return _0x18dc3f['addTags'](_0x591ffd[_0xaa83('0x21')][_0xaa83('0x26')],_[_0xaa83('0x27')](_0x591ffd[_0xaa83('0x21')],[_0xaa83('0x26'),'id'])||{});}})[_0xaa83('0x28')](function(_0x4b2220){logger[_0xaa83('0x14')](_0xaa83('0x29'),_0x591ffd);logger[_0xaa83('0x17')](_0xaa83('0x29'),_0x591ffd,JSON[_0xaa83('0x18')](_0x4b2220));_0x149448(_0x4b2220);})[_0xaa83('0x1d')](function(_0x24ae91){logger['error'](_0xaa83('0x29'),_0x24ae91['message'],_0x591ffd);_0x57ea43(_this[_0xaa83('0x19')](0x1f4,_0x24ae91['message']));});});};