Built motion from commit (unavailable).|2.4.3
[motion2.git] / server / api / attachment / attachment.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 _0xf5c4=['request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateAttachment','Attachment','create','options','then','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/environment','jayson/promise','client','info','Attachment,\x20%s,\x20%s'];(function(_0x46382f,_0x9a7435){var _0x481955=function(_0x59a200){while(--_0x59a200){_0x46382f['push'](_0x46382f['shift']());}};_0x481955(++_0x9a7435);}(_0xf5c4,0x1ae));var _0x4f5c=function(_0x1e099f,_0x470a08){_0x1e099f=_0x1e099f-0x0;var _0x2027a3=_0xf5c4[_0x1e099f];return _0x2027a3;};'use strict';var _=require(_0x4f5c('0x0'));var util=require(_0x4f5c('0x1'));var moment=require(_0x4f5c('0x2'));var BPromise=require(_0x4f5c('0x3'));var rs=require(_0x4f5c('0x4'));var fs=require('fs');var Redis=require(_0x4f5c('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x4f5c('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0x4f5c('0x7'));var jayson=require(_0x4f5c('0x8'));var client=jayson[_0x4f5c('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x342090,_0xea98b4,_0x5cdc6b){return new BPromise(function(_0x125760,_0x43ede3){return client['request'](_0x342090,_0x5cdc6b)['then'](function(_0x127399){logger[_0x4f5c('0xa')](_0x4f5c('0xb'),_0xea98b4,_0x4f5c('0xc'));logger['debug'](_0x4f5c('0xd'),_0xea98b4,'request\x20sent',JSON[_0x4f5c('0xe')](_0x127399));if(_0x127399[_0x4f5c('0xf')]){if(_0x127399[_0x4f5c('0xf')][_0x4f5c('0x10')]===0x1f4){logger[_0x4f5c('0xf')]('Attachment,\x20%s,\x20%s',_0xea98b4,_0x127399[_0x4f5c('0xf')]['message']);return _0x43ede3(_0x127399[_0x4f5c('0xf')][_0x4f5c('0x11')]);}logger['error']('Attachment,\x20%s,\x20%s',_0xea98b4,_0x127399[_0x4f5c('0xf')][_0x4f5c('0x11')]);return _0x125760(_0x127399[_0x4f5c('0xf')]['message']);}else{logger[_0x4f5c('0xa')](_0x4f5c('0xb'),_0xea98b4,'request\x20sent');_0x125760(_0x127399[_0x4f5c('0x12')][_0x4f5c('0x11')]);}})[_0x4f5c('0x13')](function(_0x247d2d){logger[_0x4f5c('0xf')]('Attachment,\x20%s,\x20%s',_0xea98b4,_0x247d2d);_0x43ede3(_0x247d2d);});});}exports[_0x4f5c('0x14')]=function(_0x2b1fad){var _0x2b66e4=this;return new Promise(function(_0x47739d,_0x5d0807){return db[_0x4f5c('0x15')][_0x4f5c('0x16')](_0x2b1fad['body'],{'raw':_0x2b1fad[_0x4f5c('0x17')]?_0x2b1fad[_0x4f5c('0x17')]['raw']===undefined?!![]:![]:!![]})[_0x4f5c('0x18')](function(_0x300410){logger[_0x4f5c('0xa')](_0x4f5c('0x14'),_0x2b1fad);logger[_0x4f5c('0x19')](_0x4f5c('0x14'),_0x2b1fad,JSON['stringify'](_0x300410));_0x47739d(_0x300410);})['catch'](function(_0x3843de){logger[_0x4f5c('0xf')](_0x4f5c('0x14'),_0x3843de[_0x4f5c('0x11')],_0x2b1fad);_0x5d0807(_0x2b66e4[_0x4f5c('0xf')](0x1f4,_0x3843de[_0x4f5c('0x11')]));});});};