Built motion from commit (unavailable).|2.4.18
[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 _0xbd0a=['message','catch','SquareMessage','create','body','options','raw','CreateSquareMessage','stringify','lodash','moment','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','error','code','result'];(function(_0x2a6a22,_0x1fc1de){var _0x26747b=function(_0x4f100f){while(--_0x4f100f){_0x2a6a22['push'](_0x2a6a22['shift']());}};_0x26747b(++_0x1fc1de);}(_0xbd0a,0x1b9));var _0xabd0=function(_0x506e40,_0x2b8498){_0x506e40=_0x506e40-0x0;var _0xda31ef=_0xbd0a[_0x506e40];return _0xda31ef;};'use strict';var _=require(_0xabd0('0x0'));var util=require('util');var moment=require(_0xabd0('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xabd0('0x2'))['db'];var utils=require(_0xabd0('0x3'));var logger=require(_0xabd0('0x4'))(_0xabd0('0x5'));var config=require(_0xabd0('0x6'));var jayson=require(_0xabd0('0x7'));var client=jayson[_0xabd0('0x8')][_0xabd0('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xe18a18,_0x4ac4ad,_0xf44097){return new BPromise(function(_0xb60e77,_0x2b50c1){return client['request'](_0xe18a18,_0xf44097)[_0xabd0('0xa')](function(_0x4830c4){logger[_0xabd0('0xb')](_0xabd0('0xc'),_0x4ac4ad,_0xabd0('0xd'));logger[_0xabd0('0xe')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x4ac4ad,_0xabd0('0xd'),JSON['stringify'](_0x4830c4));if(_0x4830c4[_0xabd0('0xf')]){if(_0x4830c4[_0xabd0('0xf')][_0xabd0('0x10')]===0x1f4){logger[_0xabd0('0xf')](_0xabd0('0xc'),_0x4ac4ad,_0x4830c4[_0xabd0('0xf')]['message']);return _0x2b50c1(_0x4830c4[_0xabd0('0xf')]['message']);}logger[_0xabd0('0xf')](_0xabd0('0xc'),_0x4ac4ad,_0x4830c4['error']['message']);return _0xb60e77(_0x4830c4['error']['message']);}else{logger[_0xabd0('0xb')](_0xabd0('0xc'),_0x4ac4ad,_0xabd0('0xd'));_0xb60e77(_0x4830c4[_0xabd0('0x11')][_0xabd0('0x12')]);}})[_0xabd0('0x13')](function(_0x389e1e){logger[_0xabd0('0xf')](_0xabd0('0xc'),_0x4ac4ad,_0x389e1e);_0x2b50c1(_0x389e1e);});});}exports['CreateSquareMessage']=function(_0x3a0ace){var _0x5de1df=this;return new Promise(function(_0x579dcd,_0x2bbc18){return db[_0xabd0('0x14')][_0xabd0('0x15')](_0x3a0ace[_0xabd0('0x16')],{'raw':_0x3a0ace['options']?_0x3a0ace[_0xabd0('0x17')][_0xabd0('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x56c2f5){logger[_0xabd0('0xb')](_0xabd0('0x19'),_0x3a0ace);logger['debug'](_0xabd0('0x19'),_0x3a0ace,JSON[_0xabd0('0x1a')](_0x56c2f5));_0x579dcd(_0x56c2f5);})[_0xabd0('0x13')](function(_0x1e077e){logger['error'](_0xabd0('0x19'),_0x1e077e[_0xabd0('0x12')],_0x3a0ace);_0x2bbc18(_0x5de1df[_0xabd0('0xf')](0x1f4,_0x1e077e[_0xabd0('0x12')]));});});};