Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / squareMessage / squareMessage.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 _0xb5f1=['lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','then','request\x20sent','debug','stringify','error','code','SquareMessage,\x20%s,\x20%s','message','result','catch','SquareMessage','create','body','options','raw','info','CreateSquareMessage'];(function(_0x17da47,_0x43e004){var _0x961445=function(_0x3bf0a4){while(--_0x3bf0a4){_0x17da47['push'](_0x17da47['shift']());}};_0x961445(++_0x43e004);}(_0xb5f1,0x150));var _0x1b5f=function(_0x2ca639,_0x2d1c04){_0x2ca639=_0x2ca639-0x0;var _0x1b61e0=_0xb5f1[_0x2ca639];return _0x1b61e0;};'use strict';var _=require(_0x1b5f('0x0'));var util=require(_0x1b5f('0x1'));var moment=require('moment');var BPromise=require(_0x1b5f('0x2'));var rs=require(_0x1b5f('0x3'));var fs=require('fs');var Redis=require(_0x1b5f('0x4'));var db=require(_0x1b5f('0x5'))['db'];var utils=require(_0x1b5f('0x6'));var logger=require('../../config/logger')(_0x1b5f('0x7'));var config=require(_0x1b5f('0x8'));var jayson=require(_0x1b5f('0x9'));var client=jayson['client'][_0x1b5f('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x26a200,_0x59cab7,_0x2c2096){return new BPromise(function(_0x1d1cc2,_0x24c722){return client['request'](_0x26a200,_0x2c2096)[_0x1b5f('0xb')](function(_0x543516){logger['info']('SquareMessage,\x20%s,\x20%s',_0x59cab7,_0x1b5f('0xc'));logger[_0x1b5f('0xd')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x59cab7,_0x1b5f('0xc'),JSON[_0x1b5f('0xe')](_0x543516));if(_0x543516[_0x1b5f('0xf')]){if(_0x543516[_0x1b5f('0xf')][_0x1b5f('0x10')]===0x1f4){logger[_0x1b5f('0xf')](_0x1b5f('0x11'),_0x59cab7,_0x543516[_0x1b5f('0xf')][_0x1b5f('0x12')]);return _0x24c722(_0x543516['error']['message']);}logger[_0x1b5f('0xf')](_0x1b5f('0x11'),_0x59cab7,_0x543516[_0x1b5f('0xf')][_0x1b5f('0x12')]);return _0x1d1cc2(_0x543516[_0x1b5f('0xf')][_0x1b5f('0x12')]);}else{logger['info'](_0x1b5f('0x11'),_0x59cab7,_0x1b5f('0xc'));_0x1d1cc2(_0x543516[_0x1b5f('0x13')][_0x1b5f('0x12')]);}})[_0x1b5f('0x14')](function(_0x6173fb){logger[_0x1b5f('0xf')](_0x1b5f('0x11'),_0x59cab7,_0x6173fb);_0x24c722(_0x6173fb);});});}exports['CreateSquareMessage']=function(_0x59963b){var _0x370dd8=this;return new Promise(function(_0x3ee425,_0x21326e){return db[_0x1b5f('0x15')][_0x1b5f('0x16')](_0x59963b[_0x1b5f('0x17')],{'raw':_0x59963b[_0x1b5f('0x18')]?_0x59963b[_0x1b5f('0x18')][_0x1b5f('0x19')]===undefined?!![]:![]:!![]})[_0x1b5f('0xb')](function(_0x405965){logger[_0x1b5f('0x1a')]('CreateSquareMessage',_0x59963b);logger[_0x1b5f('0xd')](_0x1b5f('0x1b'),_0x59963b,JSON[_0x1b5f('0xe')](_0x405965));_0x3ee425(_0x405965);})[_0x1b5f('0x14')](function(_0x2c70be){logger['error'](_0x1b5f('0x1b'),_0x2c70be[_0x1b5f('0x12')],_0x59963b);_0x21326e(_0x370dd8['error'](0x1f4,_0x2c70be['message']));});});};