Built motion from commit 97153652.|2.6.26
[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 _0x4a83=['debug','stringify','error','code','message','catch','CreateSquareMessage','create','body','options','raw','lodash','bluebird','randomstring','../../mysqldb','../../config/logger','../../config/environment','client','http','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent'];(function(_0x2e6912,_0xe09d6d){var _0x348ec8=function(_0x43e2e7){while(--_0x43e2e7){_0x2e6912['push'](_0x2e6912['shift']());}};_0x348ec8(++_0xe09d6d);}(_0x4a83,0x18b));var _0x34a8=function(_0x55b19f,_0x268075){_0x55b19f=_0x55b19f-0x0;var _0x391271=_0x4a83[_0x55b19f];return _0x391271;};'use strict';var _=require(_0x34a8('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x34a8('0x1'));var rs=require(_0x34a8('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x34a8('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x34a8('0x4'))('rpc');var config=require(_0x34a8('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x34a8('0x6')][_0x34a8('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x581541,_0x2592a1,_0x5e4c85){return new BPromise(function(_0xd43ca6,_0x17295b){return client[_0x34a8('0x8')](_0x581541,_0x5e4c85)[_0x34a8('0x9')](function(_0x3ff516){logger[_0x34a8('0xa')](_0x34a8('0xb'),_0x2592a1,_0x34a8('0xc'));logger[_0x34a8('0xd')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x2592a1,_0x34a8('0xc'),JSON[_0x34a8('0xe')](_0x3ff516));if(_0x3ff516[_0x34a8('0xf')]){if(_0x3ff516[_0x34a8('0xf')][_0x34a8('0x10')]===0x1f4){logger[_0x34a8('0xf')]('SquareMessage,\x20%s,\x20%s',_0x2592a1,_0x3ff516[_0x34a8('0xf')][_0x34a8('0x11')]);return _0x17295b(_0x3ff516[_0x34a8('0xf')]['message']);}logger['error'](_0x34a8('0xb'),_0x2592a1,_0x3ff516['error'][_0x34a8('0x11')]);return _0xd43ca6(_0x3ff516[_0x34a8('0xf')][_0x34a8('0x11')]);}else{logger[_0x34a8('0xa')](_0x34a8('0xb'),_0x2592a1,_0x34a8('0xc'));_0xd43ca6(_0x3ff516['result'][_0x34a8('0x11')]);}})[_0x34a8('0x12')](function(_0x2c8c2a){logger[_0x34a8('0xf')](_0x34a8('0xb'),_0x2592a1,_0x2c8c2a);_0x17295b(_0x2c8c2a);});});}exports[_0x34a8('0x13')]=function(_0x27aa92){var _0x5a248c=this;return new Promise(function(_0x1acaeb,_0x2d1a8f){return db['SquareMessage'][_0x34a8('0x14')](_0x27aa92[_0x34a8('0x15')],{'raw':_0x27aa92[_0x34a8('0x16')]?_0x27aa92[_0x34a8('0x16')][_0x34a8('0x17')]===undefined?!![]:![]:!![]})[_0x34a8('0x9')](function(_0x22ec48){logger['info'](_0x34a8('0x13'),_0x27aa92);logger['debug'](_0x34a8('0x13'),_0x27aa92,JSON[_0x34a8('0xe')](_0x22ec48));_0x1acaeb(_0x22ec48);})[_0x34a8('0x12')](function(_0x356fe9){logger[_0x34a8('0xf')](_0x34a8('0x13'),_0x356fe9[_0x34a8('0x11')],_0x27aa92);_0x2d1a8f(_0x5a248c[_0x34a8('0xf')](0x1f4,_0x356fe9['message']));});});};