Built motion from commit e0fa946e.|2.6.5
[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 _0xa970=['SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','CreateSquareMessage','SquareMessage','create','options','lodash','util','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x376b45,_0x5964fb){var _0x2341b3=function(_0x5a7f01){while(--_0x5a7f01){_0x376b45['push'](_0x376b45['shift']());}};_0x2341b3(++_0x5964fb);}(_0xa970,0x1b3));var _0x0a97=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xa970[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x0a97('0x0'));var util=require(_0x0a97('0x1'));var moment=require('moment');var BPromise=require(_0x0a97('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0a97('0x3'));var db=require(_0x0a97('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x0a97('0x5'))(_0x0a97('0x6'));var config=require(_0x0a97('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x0a97('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x366e2d,_0x15ef0d,_0x151c28){return new BPromise(function(_0x48abfd,_0x167847){return client[_0x0a97('0x9')](_0x366e2d,_0x151c28)[_0x0a97('0xa')](function(_0x5cf18a){logger[_0x0a97('0xb')](_0x0a97('0xc'),_0x15ef0d,_0x0a97('0xd'));logger[_0x0a97('0xe')](_0x0a97('0xf'),_0x15ef0d,_0x0a97('0xd'),JSON[_0x0a97('0x10')](_0x5cf18a));if(_0x5cf18a[_0x0a97('0x11')]){if(_0x5cf18a[_0x0a97('0x11')][_0x0a97('0x12')]===0x1f4){logger[_0x0a97('0x11')](_0x0a97('0xc'),_0x15ef0d,_0x5cf18a[_0x0a97('0x11')]['message']);return _0x167847(_0x5cf18a[_0x0a97('0x11')]['message']);}logger[_0x0a97('0x11')]('SquareMessage,\x20%s,\x20%s',_0x15ef0d,_0x5cf18a[_0x0a97('0x11')][_0x0a97('0x13')]);return _0x48abfd(_0x5cf18a[_0x0a97('0x11')][_0x0a97('0x13')]);}else{logger[_0x0a97('0xb')](_0x0a97('0xc'),_0x15ef0d,'request\x20sent');_0x48abfd(_0x5cf18a['result'][_0x0a97('0x13')]);}})[_0x0a97('0x14')](function(_0x47887b){logger[_0x0a97('0x11')](_0x0a97('0xc'),_0x15ef0d,_0x47887b);_0x167847(_0x47887b);});});}exports[_0x0a97('0x15')]=function(_0x2d2341){var _0x867acc=this;return new Promise(function(_0x1b53cd,_0x267325){return db[_0x0a97('0x16')][_0x0a97('0x17')](_0x2d2341['body'],{'raw':_0x2d2341['options']?_0x2d2341[_0x0a97('0x18')]['raw']===undefined?!![]:![]:!![]})[_0x0a97('0xa')](function(_0x3a2b77){logger['info']('CreateSquareMessage',_0x2d2341);logger['debug'](_0x0a97('0x15'),_0x2d2341,JSON[_0x0a97('0x10')](_0x3a2b77));_0x1b53cd(_0x3a2b77);})['catch'](function(_0x39b6de){logger[_0x0a97('0x11')](_0x0a97('0x15'),_0x39b6de[_0x0a97('0x13')],_0x2d2341);_0x267325(_0x867acc[_0x0a97('0x11')](0x1f4,_0x39b6de[_0x0a97('0x13')]));});});};