Built motion from commit 0900f080.|2.5.45
[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 _0x66e3=['util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','then','info','request\x20sent','debug','stringify','error','SquareMessage,\x20%s,\x20%s','message','result','CreateSquareMessage','create','options','raw','catch','lodash'];(function(_0x23b67f,_0x3fb420){var _0x36a261=function(_0x1b9d8a){while(--_0x1b9d8a){_0x23b67f['push'](_0x23b67f['shift']());}};_0x36a261(++_0x3fb420);}(_0x66e3,0x137));var _0x366e=function(_0x21cafa,_0x3b4288){_0x21cafa=_0x21cafa-0x0;var _0x2f943e=_0x66e3[_0x21cafa];return _0x2f943e;};'use strict';var _=require(_0x366e('0x0'));var util=require(_0x366e('0x1'));var moment=require(_0x366e('0x2'));var BPromise=require(_0x366e('0x3'));var rs=require(_0x366e('0x4'));var fs=require('fs');var Redis=require(_0x366e('0x5'));var db=require(_0x366e('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x366e('0x7'));var config=require(_0x366e('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x366e('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x25f408,_0x8940a7,_0x35fbe7){return new BPromise(function(_0x390c14,_0x4da091){return client['request'](_0x25f408,_0x35fbe7)[_0x366e('0xa')](function(_0xc83040){logger[_0x366e('0xb')]('SquareMessage,\x20%s,\x20%s',_0x8940a7,_0x366e('0xc'));logger[_0x366e('0xd')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x8940a7,'request\x20sent',JSON[_0x366e('0xe')](_0xc83040));if(_0xc83040[_0x366e('0xf')]){if(_0xc83040[_0x366e('0xf')]['code']===0x1f4){logger[_0x366e('0xf')](_0x366e('0x10'),_0x8940a7,_0xc83040[_0x366e('0xf')]['message']);return _0x4da091(_0xc83040[_0x366e('0xf')][_0x366e('0x11')]);}logger[_0x366e('0xf')]('SquareMessage,\x20%s,\x20%s',_0x8940a7,_0xc83040[_0x366e('0xf')][_0x366e('0x11')]);return _0x390c14(_0xc83040['error'][_0x366e('0x11')]);}else{logger['info']('SquareMessage,\x20%s,\x20%s',_0x8940a7,_0x366e('0xc'));_0x390c14(_0xc83040[_0x366e('0x12')]['message']);}})['catch'](function(_0x103fb0){logger[_0x366e('0xf')](_0x366e('0x10'),_0x8940a7,_0x103fb0);_0x4da091(_0x103fb0);});});}exports[_0x366e('0x13')]=function(_0x54c5e5){var _0xc7c056=this;return new Promise(function(_0x28c377,_0x4930d9){return db['SquareMessage'][_0x366e('0x14')](_0x54c5e5['body'],{'raw':_0x54c5e5[_0x366e('0x15')]?_0x54c5e5[_0x366e('0x15')][_0x366e('0x16')]===undefined?!![]:![]:!![]})[_0x366e('0xa')](function(_0x47f98a){logger[_0x366e('0xb')](_0x366e('0x13'),_0x54c5e5);logger[_0x366e('0xd')](_0x366e('0x13'),_0x54c5e5,JSON[_0x366e('0xe')](_0x47f98a));_0x28c377(_0x47f98a);})[_0x366e('0x17')](function(_0x44bf53){logger[_0x366e('0xf')](_0x366e('0x13'),_0x44bf53[_0x366e('0x11')],_0x54c5e5);_0x4930d9(_0xc7c056['error'](0x1f4,_0x44bf53[_0x366e('0x11')]));});});};