Built motion from commit (unavailable).|2.3.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 _0xf523=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','localhost','socket.io-emitter','./faxInteraction.socket','register','request','info','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','error','FaxInteraction,\x20%s,\x20%s','message','result','catch','UpdateFaxInteraction','body','options','where','attributes','limit','then','AddTagsToFaxInteraction','FaxInteraction','find','addTags','omit','stringify','AddTags','moment','bluebird'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xf523,0x108));var _0x3f52=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xf523[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x3f52('0x0'));var BPromise=require(_0x3f52('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3f52('0x2'));var db=require(_0x3f52('0x3'))['db'];var utils=require(_0x3f52('0x4'));var logger=require(_0x3f52('0x5'))(_0x3f52('0x6'));var config=require(_0x3f52('0x7'));var jayson=require(_0x3f52('0x8'));var client=jayson['client']['http']({'port':0x232a});config[_0x3f52('0x9')]=_['defaults'](config[_0x3f52('0x9')],{'host':_0x3f52('0xa'),'port':0x18eb});var socket=require(_0x3f52('0xb'))(new Redis(config[_0x3f52('0x9')]));require(_0x3f52('0xc'))[_0x3f52('0xd')](socket);function respondWithRpcPromise(_0x301659,_0x5da567,_0x209feb){return new BPromise(function(_0x5e96a3,_0x2be4af){return client[_0x3f52('0xe')](_0x301659,_0x209feb)['then'](function(_0x2739d8){logger[_0x3f52('0xf')]('FaxInteraction,\x20%s,\x20%s',_0x5da567,_0x3f52('0x10'));logger[_0x3f52('0x11')](_0x3f52('0x12'),_0x5da567,_0x3f52('0x10'),JSON['stringify'](_0x2739d8));if(_0x2739d8[_0x3f52('0x13')]){if(_0x2739d8['error']['code']===0x1f4){logger[_0x3f52('0x13')](_0x3f52('0x14'),_0x5da567,_0x2739d8[_0x3f52('0x13')][_0x3f52('0x15')]);return _0x2be4af(_0x2739d8[_0x3f52('0x13')][_0x3f52('0x15')]);}logger[_0x3f52('0x13')](_0x3f52('0x14'),_0x5da567,_0x2739d8['error'][_0x3f52('0x15')]);return _0x5e96a3(_0x2739d8[_0x3f52('0x13')][_0x3f52('0x15')]);}else{logger['info']('FaxInteraction,\x20%s,\x20%s',_0x5da567,_0x3f52('0x10'));_0x5e96a3(_0x2739d8[_0x3f52('0x16')][_0x3f52('0x15')]);}})[_0x3f52('0x17')](function(_0x2b8834){logger[_0x3f52('0x13')](_0x3f52('0x14'),_0x5da567,_0x2b8834);_0x2be4af(_0x2b8834);});});}exports[_0x3f52('0x18')]=function(_0x572855){var _0x565107=this;return new Promise(function(_0x4f921e,_0xab290c){return db['FaxInteraction']['update'](_0x572855[_0x3f52('0x19')],{'raw':_0x572855[_0x3f52('0x1a')]?_0x572855[_0x3f52('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x572855[_0x3f52('0x1a')]?_0x572855['options'][_0x3f52('0x1b')]||null:null,'attributes':_0x572855[_0x3f52('0x1a')]?_0x572855['options'][_0x3f52('0x1c')]||null:null,'limit':_0x572855['options']?_0x572855[_0x3f52('0x1a')][_0x3f52('0x1d')]||null:null})[_0x3f52('0x1e')](function(_0x37e770){logger[_0x3f52('0xf')]('UpdateFaxInteraction',_0x572855);logger['debug'](_0x3f52('0x18'),_0x572855,JSON['stringify'](_0x37e770));_0x4f921e(_0x37e770);})[_0x3f52('0x17')](function(_0x56048b){logger[_0x3f52('0x13')](_0x3f52('0x18'),_0x56048b['message'],_0x572855);_0xab290c(_0x565107['error'](0x1f4,_0x56048b[_0x3f52('0x15')]));});});};exports[_0x3f52('0x1f')]=function(_0x1d9227){return new Promise(function(_0x2e55b6,_0x1020e2){return db[_0x3f52('0x20')][_0x3f52('0x21')]({'where':_0x1d9227[_0x3f52('0x1a')]?_0x1d9227['options'][_0x3f52('0x1b')]||null:null})['then'](function(_0x5e2312){if(_0x5e2312){return _0x5e2312[_0x3f52('0x22')](_0x1d9227['body']['ids'],_[_0x3f52('0x23')](_0x1d9227[_0x3f52('0x19')],['ids','id'])||{});}})['spread'](function(_0x1972b9){logger[_0x3f52('0xf')]('AddTags',_0x1d9227);logger['debug']('AddTags',_0x1d9227,JSON[_0x3f52('0x24')](_0x1972b9));_0x2e55b6(_0x1972b9);})[_0x3f52('0x17')](function(_0x129c7a){logger[_0x3f52('0x13')](_0x3f52('0x25'),_0x129c7a[_0x3f52('0x15')],_0x1d9227);_0x1020e2(_this[_0x3f52('0x13')](0x1f4,_0x129c7a[_0x3f52('0x15')]));});});};