Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / mailMessage / mailMessage.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 _0xfcbb=['catch','CreateMailMessage','body','options','raw','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','redis','defaults','localhost','socket.io-emitter','./mailMessage.socket','register','request','then','MailMessage,\x20%s,\x20%s','request\x20sent','debug','MailMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result'];(function(_0x2d9ad7,_0xb1a24f){var _0x432432=function(_0x1e2bce){while(--_0x1e2bce){_0x2d9ad7['push'](_0x2d9ad7['shift']());}};_0x432432(++_0xb1a24f);}(_0xfcbb,0x10d));var _0xbfcb=function(_0x33b458,_0x1083e0){_0x33b458=_0x33b458-0x0;var _0x45d9ec=_0xfcbb[_0x33b458];return _0x45d9ec;};'use strict';var _=require(_0xbfcb('0x0'));var util=require(_0xbfcb('0x1'));var moment=require(_0xbfcb('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbfcb('0x3'));var db=require(_0xbfcb('0x4'))['db'];var utils=require(_0xbfcb('0x5'));var logger=require(_0xbfcb('0x6'))(_0xbfcb('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xbfcb('0x8')][_0xbfcb('0x9')]({'port':0x232a});config[_0xbfcb('0xa')]=_[_0xbfcb('0xb')](config[_0xbfcb('0xa')],{'host':_0xbfcb('0xc'),'port':0x18eb});var socket=require(_0xbfcb('0xd'))(new Redis(config['redis']));require(_0xbfcb('0xe'))[_0xbfcb('0xf')](socket);function respondWithRpcPromise(_0x346685,_0x52b2f8,_0x2c72f3){return new BPromise(function(_0x3d01fa,_0x3e735a){return client[_0xbfcb('0x10')](_0x346685,_0x2c72f3)[_0xbfcb('0x11')](function(_0x1fad67){logger['info'](_0xbfcb('0x12'),_0x52b2f8,_0xbfcb('0x13'));logger[_0xbfcb('0x14')](_0xbfcb('0x15'),_0x52b2f8,'request\x20sent',JSON[_0xbfcb('0x16')](_0x1fad67));if(_0x1fad67['error']){if(_0x1fad67[_0xbfcb('0x17')][_0xbfcb('0x18')]===0x1f4){logger[_0xbfcb('0x17')](_0xbfcb('0x12'),_0x52b2f8,_0x1fad67[_0xbfcb('0x17')][_0xbfcb('0x19')]);return _0x3e735a(_0x1fad67[_0xbfcb('0x17')][_0xbfcb('0x19')]);}logger[_0xbfcb('0x17')](_0xbfcb('0x12'),_0x52b2f8,_0x1fad67[_0xbfcb('0x17')][_0xbfcb('0x19')]);return _0x3d01fa(_0x1fad67[_0xbfcb('0x17')][_0xbfcb('0x19')]);}else{logger[_0xbfcb('0x1a')](_0xbfcb('0x12'),_0x52b2f8,_0xbfcb('0x13'));_0x3d01fa(_0x1fad67[_0xbfcb('0x1b')][_0xbfcb('0x19')]);}})[_0xbfcb('0x1c')](function(_0xccd6ff){logger[_0xbfcb('0x17')]('MailMessage,\x20%s,\x20%s',_0x52b2f8,_0xccd6ff);_0x3e735a(_0xccd6ff);});});}exports[_0xbfcb('0x1d')]=function(_0x37263b){var _0x54ec7a=this;return new Promise(function(_0xa3c089,_0x1a7225){return db['MailMessage']['create'](_0x37263b[_0xbfcb('0x1e')],{'raw':_0x37263b[_0xbfcb('0x1f')]?_0x37263b[_0xbfcb('0x1f')][_0xbfcb('0x20')]===undefined?!![]:![]:!![]})[_0xbfcb('0x11')](function(_0x56c158){logger[_0xbfcb('0x1a')](_0xbfcb('0x1d'),_0x37263b);logger[_0xbfcb('0x14')](_0xbfcb('0x1d'),_0x37263b,JSON[_0xbfcb('0x16')](_0x56c158));_0xa3c089(_0x56c158);})[_0xbfcb('0x1c')](function(_0x69c8e9){logger[_0xbfcb('0x17')](_0xbfcb('0x1d'),_0x69c8e9[_0xbfcb('0x19')],_0x37263b);_0x1a7225(_0x54ec7a[_0xbfcb('0x17')](0x1f4,_0x69c8e9[_0xbfcb('0x19')]));});});};