75a46a179431bd8998d3ad78d583275c20abf79e
[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 _0x2bdb=['error','code','message','result','CreateAttachment','Attachment','create','options','catch','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x4ccc7c,_0x35e855){var _0x5921f9=function(_0x944e4d){while(--_0x944e4d){_0x4ccc7c['push'](_0x4ccc7c['shift']());}};_0x5921f9(++_0x35e855);}(_0x2bdb,0x105));var _0xb2bd=function(_0x51ad81,_0xf21e4b){_0x51ad81=_0x51ad81-0x0;var _0x181ecf=_0x2bdb[_0x51ad81];return _0x181ecf;};'use strict';var _=require(_0xb2bd('0x0'));var util=require('util');var moment=require(_0xb2bd('0x1'));var BPromise=require('bluebird');var rs=require(_0xb2bd('0x2'));var fs=require('fs');var Redis=require(_0xb2bd('0x3'));var db=require(_0xb2bd('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xb2bd('0x5'))(_0xb2bd('0x6'));var config=require(_0xb2bd('0x7'));var jayson=require(_0xb2bd('0x8'));var client=jayson[_0xb2bd('0x9')][_0xb2bd('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3bff5b,_0x5bae78,_0x21462b){return new BPromise(function(_0x4d9d3f,_0x181f5a){return client[_0xb2bd('0xb')](_0x3bff5b,_0x21462b)[_0xb2bd('0xc')](function(_0xeaa2b7){logger[_0xb2bd('0xd')](_0xb2bd('0xe'),_0x5bae78,_0xb2bd('0xf'));logger[_0xb2bd('0x10')](_0xb2bd('0x11'),_0x5bae78,'request\x20sent',JSON[_0xb2bd('0x12')](_0xeaa2b7));if(_0xeaa2b7[_0xb2bd('0x13')]){if(_0xeaa2b7[_0xb2bd('0x13')][_0xb2bd('0x14')]===0x1f4){logger[_0xb2bd('0x13')](_0xb2bd('0xe'),_0x5bae78,_0xeaa2b7[_0xb2bd('0x13')][_0xb2bd('0x15')]);return _0x181f5a(_0xeaa2b7['error'][_0xb2bd('0x15')]);}logger['error'](_0xb2bd('0xe'),_0x5bae78,_0xeaa2b7[_0xb2bd('0x13')][_0xb2bd('0x15')]);return _0x4d9d3f(_0xeaa2b7[_0xb2bd('0x13')][_0xb2bd('0x15')]);}else{logger['info'](_0xb2bd('0xe'),_0x5bae78,_0xb2bd('0xf'));_0x4d9d3f(_0xeaa2b7[_0xb2bd('0x16')][_0xb2bd('0x15')]);}})['catch'](function(_0x14950f){logger[_0xb2bd('0x13')]('Attachment,\x20%s,\x20%s',_0x5bae78,_0x14950f);_0x181f5a(_0x14950f);});});}exports[_0xb2bd('0x17')]=function(_0x380089){var _0x387897=this;return new Promise(function(_0x315815,_0x5d848d){return db[_0xb2bd('0x18')][_0xb2bd('0x19')](_0x380089['body'],{'raw':_0x380089[_0xb2bd('0x1a')]?_0x380089[_0xb2bd('0x1a')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x51c595){logger[_0xb2bd('0xd')]('CreateAttachment',_0x380089);logger[_0xb2bd('0x10')]('CreateAttachment',_0x380089,JSON[_0xb2bd('0x12')](_0x51c595));_0x315815(_0x51c595);})[_0xb2bd('0x1b')](function(_0x505c35){logger[_0xb2bd('0x13')]('CreateAttachment',_0x505c35[_0xb2bd('0x15')],_0x380089);_0x5d848d(_0x387897[_0xb2bd('0x13')](0x1f4,_0x505c35[_0xb2bd('0x15')]));});});};