Built motion from commit 85328c08.|2.5.50
[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 _0x54d8=['rpc','../../config/environment','jayson/promise','client','http','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','error','code','message','info','result','CreateSquareMessage','create','options','raw','stringify','catch','lodash','util','moment','bluebird','ioredis','../../config/utils','../../config/logger'];(function(_0x4e3537,_0x361c10){var _0x5f48cb=function(_0x525888){while(--_0x525888){_0x4e3537['push'](_0x4e3537['shift']());}};_0x5f48cb(++_0x361c10);}(_0x54d8,0x13d));var _0x854d=function(_0x20ef64,_0x4a8fe9){_0x20ef64=_0x20ef64-0x0;var _0x3707d8=_0x54d8[_0x20ef64];return _0x3707d8;};'use strict';var _=require(_0x854d('0x0'));var util=require(_0x854d('0x1'));var moment=require(_0x854d('0x2'));var BPromise=require(_0x854d('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x854d('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x854d('0x5'));var logger=require(_0x854d('0x6'))(_0x854d('0x7'));var config=require(_0x854d('0x8'));var jayson=require(_0x854d('0x9'));var client=jayson[_0x854d('0xa')][_0x854d('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x102d28,_0x48f294,_0x2632bd){return new BPromise(function(_0x43d097,_0x57dc46){return client['request'](_0x102d28,_0x2632bd)['then'](function(_0x277585){logger['info'](_0x854d('0xc'),_0x48f294,_0x854d('0xd'));logger[_0x854d('0xe')](_0x854d('0xf'),_0x48f294,_0x854d('0xd'),JSON['stringify'](_0x277585));if(_0x277585[_0x854d('0x10')]){if(_0x277585[_0x854d('0x10')][_0x854d('0x11')]===0x1f4){logger[_0x854d('0x10')]('SquareMessage,\x20%s,\x20%s',_0x48f294,_0x277585[_0x854d('0x10')][_0x854d('0x12')]);return _0x57dc46(_0x277585[_0x854d('0x10')][_0x854d('0x12')]);}logger[_0x854d('0x10')]('SquareMessage,\x20%s,\x20%s',_0x48f294,_0x277585['error'][_0x854d('0x12')]);return _0x43d097(_0x277585[_0x854d('0x10')][_0x854d('0x12')]);}else{logger[_0x854d('0x13')](_0x854d('0xc'),_0x48f294,'request\x20sent');_0x43d097(_0x277585[_0x854d('0x14')][_0x854d('0x12')]);}})['catch'](function(_0x800567){logger[_0x854d('0x10')](_0x854d('0xc'),_0x48f294,_0x800567);_0x57dc46(_0x800567);});});}exports[_0x854d('0x15')]=function(_0xb58179){var _0x403a51=this;return new Promise(function(_0x18dd5c,_0x520d67){return db['SquareMessage'][_0x854d('0x16')](_0xb58179['body'],{'raw':_0xb58179[_0x854d('0x17')]?_0xb58179['options'][_0x854d('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x99494f){logger['info'](_0x854d('0x15'),_0xb58179);logger[_0x854d('0xe')](_0x854d('0x15'),_0xb58179,JSON[_0x854d('0x19')](_0x99494f));_0x18dd5c(_0x99494f);})[_0x854d('0x1a')](function(_0x41ccc0){logger[_0x854d('0x10')](_0x854d('0x15'),_0x41ccc0[_0x854d('0x12')],_0xb58179);_0x520d67(_0x403a51[_0x854d('0x10')](0x1f4,_0x41ccc0[_0x854d('0x12')]));});});};