f5500e12d523a6c2735937a221d2da39e8e3ddc9
[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 _0x885e=['body','options','raw','catch','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','Attachment,\x20%s,\x20%s','message','CreateAttachment','Attachment','create'];(function(_0x44f775,_0x40dd9){var _0x2a574e=function(_0x582bb5){while(--_0x582bb5){_0x44f775['push'](_0x44f775['shift']());}};_0x2a574e(++_0x40dd9);}(_0x885e,0xe4));var _0xe885=function(_0x5e1b47,_0x5bd558){_0x5e1b47=_0x5e1b47-0x0;var _0x3b5976=_0x885e[_0x5e1b47];return _0x3b5976;};'use strict';var _=require(_0xe885('0x0'));var util=require(_0xe885('0x1'));var moment=require('moment');var BPromise=require(_0xe885('0x2'));var rs=require(_0xe885('0x3'));var fs=require('fs');var Redis=require(_0xe885('0x4'));var db=require(_0xe885('0x5'))['db'];var utils=require(_0xe885('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0xe885('0x7'));var jayson=require(_0xe885('0x8'));var client=jayson[_0xe885('0x9')][_0xe885('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x55d2b2,_0x37778a,_0x597bdc){return new BPromise(function(_0x2e8fe0,_0x3c5cc7){return client[_0xe885('0xb')](_0x55d2b2,_0x597bdc)[_0xe885('0xc')](function(_0x231f2f){logger[_0xe885('0xd')]('Attachment,\x20%s,\x20%s',_0x37778a,_0xe885('0xe'));logger[_0xe885('0xf')](_0xe885('0x10'),_0x37778a,_0xe885('0xe'),JSON[_0xe885('0x11')](_0x231f2f));if(_0x231f2f[_0xe885('0x12')]){if(_0x231f2f[_0xe885('0x12')]['code']===0x1f4){logger[_0xe885('0x12')](_0xe885('0x13'),_0x37778a,_0x231f2f[_0xe885('0x12')][_0xe885('0x14')]);return _0x3c5cc7(_0x231f2f[_0xe885('0x12')][_0xe885('0x14')]);}logger[_0xe885('0x12')]('Attachment,\x20%s,\x20%s',_0x37778a,_0x231f2f['error']['message']);return _0x2e8fe0(_0x231f2f[_0xe885('0x12')][_0xe885('0x14')]);}else{logger[_0xe885('0xd')](_0xe885('0x13'),_0x37778a,'request\x20sent');_0x2e8fe0(_0x231f2f['result'][_0xe885('0x14')]);}})['catch'](function(_0x36b9e7){logger[_0xe885('0x12')](_0xe885('0x13'),_0x37778a,_0x36b9e7);_0x3c5cc7(_0x36b9e7);});});}exports[_0xe885('0x15')]=function(_0x25a002){var _0x365eab=this;return new Promise(function(_0x4f5045,_0x39f07c){return db[_0xe885('0x16')][_0xe885('0x17')](_0x25a002[_0xe885('0x18')],{'raw':_0x25a002[_0xe885('0x19')]?_0x25a002[_0xe885('0x19')][_0xe885('0x1a')]===undefined?!![]:![]:!![]})['then'](function(_0x159624){logger[_0xe885('0xd')](_0xe885('0x15'),_0x25a002);logger[_0xe885('0xf')](_0xe885('0x15'),_0x25a002,JSON[_0xe885('0x11')](_0x159624));_0x4f5045(_0x159624);})[_0xe885('0x1b')](function(_0x4375ff){logger[_0xe885('0x12')](_0xe885('0x15'),_0x4375ff[_0xe885('0x14')],_0x25a002);_0x39f07c(_0x365eab[_0xe885('0x12')](0x1f4,_0x4375ff['message']));});});};