Built motion from commit e0fa946e.|2.6.5
[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 _0xa1fd=['jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','debug','Attachment,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','error','message','result','CreateAttachment','create','body','options','raw','catch','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x5ddb1c,_0x5ea4df){var _0x354adc=function(_0x2dfb1f){while(--_0x2dfb1f){_0x5ddb1c['push'](_0x5ddb1c['shift']());}};_0x354adc(++_0x5ea4df);}(_0xa1fd,0x1b9));var _0xda1f=function(_0x17542e,_0x497c31){_0x17542e=_0x17542e-0x0;var _0x28c798=_0xa1fd[_0x17542e];return _0x28c798;};'use strict';var _=require(_0xda1f('0x0'));var util=require(_0xda1f('0x1'));var moment=require(_0xda1f('0x2'));var BPromise=require(_0xda1f('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xda1f('0x4'));var db=require(_0xda1f('0x5'))['db'];var utils=require(_0xda1f('0x6'));var logger=require(_0xda1f('0x7'))(_0xda1f('0x8'));var config=require('../../config/environment');var jayson=require(_0xda1f('0x9'));var client=jayson[_0xda1f('0xa')][_0xda1f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x552ba4,_0x33502e,_0x46a29e){return new BPromise(function(_0x199a8d,_0x338463){return client[_0xda1f('0xc')](_0x552ba4,_0x46a29e)[_0xda1f('0xd')](function(_0x1493f8){logger[_0xda1f('0xe')](_0xda1f('0xf'),_0x33502e,'request\x20sent');logger[_0xda1f('0x10')](_0xda1f('0x11'),_0x33502e,_0xda1f('0x12'),JSON[_0xda1f('0x13')](_0x1493f8));if(_0x1493f8['error']){if(_0x1493f8['error'][_0xda1f('0x14')]===0x1f4){logger[_0xda1f('0x15')](_0xda1f('0xf'),_0x33502e,_0x1493f8[_0xda1f('0x15')][_0xda1f('0x16')]);return _0x338463(_0x1493f8['error'][_0xda1f('0x16')]);}logger[_0xda1f('0x15')](_0xda1f('0xf'),_0x33502e,_0x1493f8[_0xda1f('0x15')][_0xda1f('0x16')]);return _0x199a8d(_0x1493f8[_0xda1f('0x15')]['message']);}else{logger[_0xda1f('0xe')](_0xda1f('0xf'),_0x33502e,_0xda1f('0x12'));_0x199a8d(_0x1493f8[_0xda1f('0x17')]['message']);}})['catch'](function(_0x3020ea){logger['error'](_0xda1f('0xf'),_0x33502e,_0x3020ea);_0x338463(_0x3020ea);});});}exports[_0xda1f('0x18')]=function(_0x1e10af){var _0x59b7bf=this;return new Promise(function(_0xe81fc2,_0xe18a0a){return db['Attachment'][_0xda1f('0x19')](_0x1e10af[_0xda1f('0x1a')],{'raw':_0x1e10af['options']?_0x1e10af[_0xda1f('0x1b')][_0xda1f('0x1c')]===undefined?!![]:![]:!![]})[_0xda1f('0xd')](function(_0xe85e94){logger[_0xda1f('0xe')](_0xda1f('0x18'),_0x1e10af);logger[_0xda1f('0x10')](_0xda1f('0x18'),_0x1e10af,JSON[_0xda1f('0x13')](_0xe85e94));_0xe81fc2(_0xe85e94);})[_0xda1f('0x1d')](function(_0x1d510b){logger[_0xda1f('0x15')]('CreateAttachment',_0x1d510b[_0xda1f('0x16')],_0x1e10af);_0xe18a0a(_0x59b7bf['error'](0x1f4,_0x1d510b[_0xda1f('0x16')]));});});};