cba9f32973b4673088114cca12875363f18f50bf
[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 _0xd6f7=['catch','Attachment,\x20%s,\x20%s','CreateAttachment','Attachment','body','options','debug','stringify','lodash','util','moment','bluebird','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s,\x20%s','error','code','message','request\x20sent','result'];(function(_0x264b9b,_0xa1181e){var _0x4c7a0e=function(_0x4b77a0){while(--_0x4b77a0){_0x264b9b['push'](_0x264b9b['shift']());}};_0x4c7a0e(++_0xa1181e);}(_0xd6f7,0x116));var _0x7d6f=function(_0x5c9307,_0x5b97e4){_0x5c9307=_0x5c9307-0x0;var _0x373e29=_0xd6f7[_0x5c9307];return _0x373e29;};'use strict';var _=require(_0x7d6f('0x0'));var util=require(_0x7d6f('0x1'));var moment=require(_0x7d6f('0x2'));var BPromise=require(_0x7d6f('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7d6f('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x7d6f('0x5'))('rpc');var config=require(_0x7d6f('0x6'));var jayson=require(_0x7d6f('0x7'));var client=jayson[_0x7d6f('0x8')][_0x7d6f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x41fce6,_0x3345e6,_0x5afc21){return new BPromise(function(_0x5b130a,_0x193010){return client[_0x7d6f('0xa')](_0x41fce6,_0x5afc21)[_0x7d6f('0xb')](function(_0x1df366){logger[_0x7d6f('0xc')]('Attachment,\x20%s,\x20%s',_0x3345e6,'request\x20sent');logger['debug'](_0x7d6f('0xd'),_0x3345e6,'request\x20sent',JSON['stringify'](_0x1df366));if(_0x1df366[_0x7d6f('0xe')]){if(_0x1df366[_0x7d6f('0xe')][_0x7d6f('0xf')]===0x1f4){logger[_0x7d6f('0xe')]('Attachment,\x20%s,\x20%s',_0x3345e6,_0x1df366[_0x7d6f('0xe')]['message']);return _0x193010(_0x1df366[_0x7d6f('0xe')][_0x7d6f('0x10')]);}logger['error']('Attachment,\x20%s,\x20%s',_0x3345e6,_0x1df366['error'][_0x7d6f('0x10')]);return _0x5b130a(_0x1df366[_0x7d6f('0xe')][_0x7d6f('0x10')]);}else{logger[_0x7d6f('0xc')]('Attachment,\x20%s,\x20%s',_0x3345e6,_0x7d6f('0x11'));_0x5b130a(_0x1df366[_0x7d6f('0x12')][_0x7d6f('0x10')]);}})[_0x7d6f('0x13')](function(_0x52471e){logger[_0x7d6f('0xe')](_0x7d6f('0x14'),_0x3345e6,_0x52471e);_0x193010(_0x52471e);});});}exports[_0x7d6f('0x15')]=function(_0x50e1c5){var _0x1829a3=this;return new Promise(function(_0x1bdeb2,_0x33c9fc){return db[_0x7d6f('0x16')]['create'](_0x50e1c5[_0x7d6f('0x17')],{'raw':_0x50e1c5[_0x7d6f('0x18')]?_0x50e1c5[_0x7d6f('0x18')]['raw']===undefined?!![]:![]:!![]})[_0x7d6f('0xb')](function(_0x3bdfca){logger[_0x7d6f('0xc')](_0x7d6f('0x15'),_0x50e1c5);logger[_0x7d6f('0x19')]('CreateAttachment',_0x50e1c5,JSON[_0x7d6f('0x1a')](_0x3bdfca));_0x1bdeb2(_0x3bdfca);})['catch'](function(_0x3a305f){logger[_0x7d6f('0xe')]('CreateAttachment',_0x3a305f[_0x7d6f('0x10')],_0x50e1c5);_0x33c9fc(_0x1829a3[_0x7d6f('0xe')](0x1f4,_0x3a305f[_0x7d6f('0x10')]));});});};