Built motion from commit (unavailable).|2.4.3
[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 _0x083f=['message','result','CreateSquareMessage','SquareMessage','create','body','options','catch','lodash','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code'];(function(_0x13ad16,_0x54be96){var _0x232358=function(_0x517849){while(--_0x517849){_0x13ad16['push'](_0x13ad16['shift']());}};_0x232358(++_0x54be96);}(_0x083f,0xf2));var _0xf083=function(_0x2c91e9,_0x2fb965){_0x2c91e9=_0x2c91e9-0x0;var _0x13f0ff=_0x083f[_0x2c91e9];return _0x13f0ff;};'use strict';var _=require(_0xf083('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xf083('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf083('0x2'));var db=require(_0xf083('0x3'))['db'];var utils=require(_0xf083('0x4'));var logger=require('../../config/logger')(_0xf083('0x5'));var config=require(_0xf083('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xf083('0x7')][_0xf083('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x413bc1,_0x5667cb,_0x51378f){return new BPromise(function(_0x5182d6,_0x51915e){return client[_0xf083('0x9')](_0x413bc1,_0x51378f)[_0xf083('0xa')](function(_0x27ec09){logger[_0xf083('0xb')](_0xf083('0xc'),_0x5667cb,_0xf083('0xd'));logger[_0xf083('0xe')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x5667cb,_0xf083('0xd'),JSON[_0xf083('0xf')](_0x27ec09));if(_0x27ec09[_0xf083('0x10')]){if(_0x27ec09[_0xf083('0x10')][_0xf083('0x11')]===0x1f4){logger[_0xf083('0x10')]('SquareMessage,\x20%s,\x20%s',_0x5667cb,_0x27ec09['error'][_0xf083('0x12')]);return _0x51915e(_0x27ec09['error'][_0xf083('0x12')]);}logger[_0xf083('0x10')](_0xf083('0xc'),_0x5667cb,_0x27ec09['error'][_0xf083('0x12')]);return _0x5182d6(_0x27ec09['error'][_0xf083('0x12')]);}else{logger['info'](_0xf083('0xc'),_0x5667cb,'request\x20sent');_0x5182d6(_0x27ec09[_0xf083('0x13')][_0xf083('0x12')]);}})['catch'](function(_0x21ed0a){logger[_0xf083('0x10')](_0xf083('0xc'),_0x5667cb,_0x21ed0a);_0x51915e(_0x21ed0a);});});}exports[_0xf083('0x14')]=function(_0x3d9521){var _0xe4f58a=this;return new Promise(function(_0x4b52b0,_0x23c7c2){return db[_0xf083('0x15')][_0xf083('0x16')](_0x3d9521[_0xf083('0x17')],{'raw':_0x3d9521['options']?_0x3d9521[_0xf083('0x18')]['raw']===undefined?!![]:![]:!![]})[_0xf083('0xa')](function(_0x3f374e){logger[_0xf083('0xb')](_0xf083('0x14'),_0x3d9521);logger['debug'](_0xf083('0x14'),_0x3d9521,JSON['stringify'](_0x3f374e));_0x4b52b0(_0x3f374e);})[_0xf083('0x19')](function(_0x23ced2){logger[_0xf083('0x10')](_0xf083('0x14'),_0x23ced2[_0xf083('0x12')],_0x3d9521);_0x23c7c2(_0xe4f58a[_0xf083('0x10')](0x1f4,_0x23ced2[_0xf083('0x12')]));});});};