Built motion from commit 9d0783e6.|2.6.13
[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 _0x43e9=['ioredis','../../config/utils','../../config/environment','jayson/promise','client','request','then','SquareMessage,\x20%s,\x20%s','request\x20sent','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','create','body','options','raw','CreateSquareMessage','catch','lodash','util','moment','bluebird'];(function(_0x58c0fd,_0x8abc7d){var _0x5b1e33=function(_0x1819c6){while(--_0x1819c6){_0x58c0fd['push'](_0x58c0fd['shift']());}};_0x5b1e33(++_0x8abc7d);}(_0x43e9,0xc4));var _0x943e=function(_0xab1d07,_0x1851e2){_0xab1d07=_0xab1d07-0x0;var _0x61b33d=_0x43e9[_0xab1d07];return _0x61b33d;};'use strict';var _=require(_0x943e('0x0'));var util=require(_0x943e('0x1'));var moment=require(_0x943e('0x2'));var BPromise=require(_0x943e('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x943e('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x943e('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x943e('0x6'));var jayson=require(_0x943e('0x7'));var client=jayson[_0x943e('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5da1a6,_0xdb5441,_0x417e23){return new BPromise(function(_0x317113,_0x4ae2d0){return client[_0x943e('0x9')](_0x5da1a6,_0x417e23)[_0x943e('0xa')](function(_0x11c5b9){logger['info'](_0x943e('0xb'),_0xdb5441,_0x943e('0xc'));logger['debug'](_0x943e('0xd'),_0xdb5441,'request\x20sent',JSON[_0x943e('0xe')](_0x11c5b9));if(_0x11c5b9['error']){if(_0x11c5b9[_0x943e('0xf')]['code']===0x1f4){logger[_0x943e('0xf')](_0x943e('0xb'),_0xdb5441,_0x11c5b9[_0x943e('0xf')][_0x943e('0x10')]);return _0x4ae2d0(_0x11c5b9['error'][_0x943e('0x10')]);}logger[_0x943e('0xf')](_0x943e('0xb'),_0xdb5441,_0x11c5b9['error']['message']);return _0x317113(_0x11c5b9[_0x943e('0xf')]['message']);}else{logger[_0x943e('0x11')](_0x943e('0xb'),_0xdb5441,_0x943e('0xc'));_0x317113(_0x11c5b9[_0x943e('0x12')][_0x943e('0x10')]);}})['catch'](function(_0x4905fa){logger['error'](_0x943e('0xb'),_0xdb5441,_0x4905fa);_0x4ae2d0(_0x4905fa);});});}exports['CreateSquareMessage']=function(_0x1a027b){var _0x13a7a6=this;return new Promise(function(_0x5b718a,_0x16cb05){return db['SquareMessage'][_0x943e('0x13')](_0x1a027b[_0x943e('0x14')],{'raw':_0x1a027b[_0x943e('0x15')]?_0x1a027b[_0x943e('0x15')][_0x943e('0x16')]===undefined?!![]:![]:!![]})['then'](function(_0x1c93d8){logger['info'](_0x943e('0x17'),_0x1a027b);logger['debug'](_0x943e('0x17'),_0x1a027b,JSON['stringify'](_0x1c93d8));_0x5b718a(_0x1c93d8);})[_0x943e('0x18')](function(_0x5ea733){logger[_0x943e('0xf')](_0x943e('0x17'),_0x5ea733[_0x943e('0x10')],_0x1a027b);_0x16cb05(_0x13a7a6[_0x943e('0xf')](0x1f4,_0x5ea733[_0x943e('0x10')]));});});};