e5c5947fbae211c84b34d15a46188384ad9a20c1
[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 _0xe739=['code','Attachment,\x20%s,\x20%s','message','result','catch','CreateAttachment','Attachment','create','body','options','raw','lodash','moment','bluebird','randomstring','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','request\x20sent','error'];(function(_0x180b9c,_0x663206){var _0x51baad=function(_0x3fe54a){while(--_0x3fe54a){_0x180b9c['push'](_0x180b9c['shift']());}};_0x51baad(++_0x663206);}(_0xe739,0x105));var _0x9e73=function(_0x3a8f21,_0x45d901){_0x3a8f21=_0x3a8f21-0x0;var _0x383baf=_0xe739[_0x3a8f21];return _0x383baf;};'use strict';var _=require(_0x9e73('0x0'));var util=require('util');var moment=require(_0x9e73('0x1'));var BPromise=require(_0x9e73('0x2'));var rs=require(_0x9e73('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x9e73('0x4'))(_0x9e73('0x5'));var config=require(_0x9e73('0x6'));var jayson=require(_0x9e73('0x7'));var client=jayson['client'][_0x9e73('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x26cb5b,_0xb37872,_0x5e46e7){return new BPromise(function(_0xa49f86,_0x1ee042){return client[_0x9e73('0x9')](_0x26cb5b,_0x5e46e7)[_0x9e73('0xa')](function(_0x14de8a){logger[_0x9e73('0xb')]('Attachment,\x20%s,\x20%s',_0xb37872,_0x9e73('0xc'));logger['debug']('Attachment,\x20%s,\x20%s,\x20%s',_0xb37872,_0x9e73('0xc'),JSON['stringify'](_0x14de8a));if(_0x14de8a[_0x9e73('0xd')]){if(_0x14de8a[_0x9e73('0xd')][_0x9e73('0xe')]===0x1f4){logger['error'](_0x9e73('0xf'),_0xb37872,_0x14de8a[_0x9e73('0xd')][_0x9e73('0x10')]);return _0x1ee042(_0x14de8a[_0x9e73('0xd')]['message']);}logger[_0x9e73('0xd')](_0x9e73('0xf'),_0xb37872,_0x14de8a[_0x9e73('0xd')]['message']);return _0xa49f86(_0x14de8a[_0x9e73('0xd')][_0x9e73('0x10')]);}else{logger['info'](_0x9e73('0xf'),_0xb37872,_0x9e73('0xc'));_0xa49f86(_0x14de8a[_0x9e73('0x11')]['message']);}})[_0x9e73('0x12')](function(_0x51968a){logger[_0x9e73('0xd')]('Attachment,\x20%s,\x20%s',_0xb37872,_0x51968a);_0x1ee042(_0x51968a);});});}exports[_0x9e73('0x13')]=function(_0x48b1db){var _0x4dabb2=this;return new Promise(function(_0x419c5b,_0x3944fc){return db[_0x9e73('0x14')][_0x9e73('0x15')](_0x48b1db[_0x9e73('0x16')],{'raw':_0x48b1db[_0x9e73('0x17')]?_0x48b1db[_0x9e73('0x17')][_0x9e73('0x18')]===undefined?!![]:![]:!![]})[_0x9e73('0xa')](function(_0x3f56bf){logger['info'](_0x9e73('0x13'),_0x48b1db);logger['debug'](_0x9e73('0x13'),_0x48b1db,JSON['stringify'](_0x3f56bf));_0x419c5b(_0x3f56bf);})[_0x9e73('0x12')](function(_0x589a5d){logger[_0x9e73('0xd')](_0x9e73('0x13'),_0x589a5d['message'],_0x48b1db);_0x3944fc(_0x4dabb2['error'](0x1f4,_0x589a5d[_0x9e73('0x10')]));});});};