4cbc34e89bee21ba44875ab1d218c26fa7b7c918
[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 _0x9f94=['rpc','jayson/promise','client','http','Attachment,\x20%s,\x20%s','request\x20sent','debug','error','code','message','info','result','catch','CreateAttachment','Attachment','create','body','options','raw','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x18890a,_0x8efbc){var _0xc6044d=function(_0xb848bc){while(--_0xb848bc){_0x18890a['push'](_0x18890a['shift']());}};_0xc6044d(++_0x8efbc);}(_0x9f94,0x1e7));var _0x49f9=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x9f94[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0x49f9('0x0'));var util=require(_0x49f9('0x1'));var moment=require(_0x49f9('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x49f9('0x3'));var db=require(_0x49f9('0x4'))['db'];var utils=require(_0x49f9('0x5'));var logger=require(_0x49f9('0x6'))(_0x49f9('0x7'));var config=require('../../config/environment');var jayson=require(_0x49f9('0x8'));var client=jayson[_0x49f9('0x9')][_0x49f9('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2fdbf1,_0x10ada8,_0x2e0928){return new BPromise(function(_0x355683,_0x2eddd1){return client['request'](_0x2fdbf1,_0x2e0928)['then'](function(_0x1628bb){logger['info'](_0x49f9('0xb'),_0x10ada8,_0x49f9('0xc'));logger[_0x49f9('0xd')]('Attachment,\x20%s,\x20%s,\x20%s',_0x10ada8,_0x49f9('0xc'),JSON['stringify'](_0x1628bb));if(_0x1628bb[_0x49f9('0xe')]){if(_0x1628bb[_0x49f9('0xe')][_0x49f9('0xf')]===0x1f4){logger[_0x49f9('0xe')]('Attachment,\x20%s,\x20%s',_0x10ada8,_0x1628bb['error'][_0x49f9('0x10')]);return _0x2eddd1(_0x1628bb[_0x49f9('0xe')][_0x49f9('0x10')]);}logger[_0x49f9('0xe')]('Attachment,\x20%s,\x20%s',_0x10ada8,_0x1628bb['error']['message']);return _0x355683(_0x1628bb[_0x49f9('0xe')]['message']);}else{logger[_0x49f9('0x11')]('Attachment,\x20%s,\x20%s',_0x10ada8,_0x49f9('0xc'));_0x355683(_0x1628bb[_0x49f9('0x12')]['message']);}})[_0x49f9('0x13')](function(_0x1a2026){logger[_0x49f9('0xe')](_0x49f9('0xb'),_0x10ada8,_0x1a2026);_0x2eddd1(_0x1a2026);});});}exports[_0x49f9('0x14')]=function(_0x509610){var _0x3cc45e=this;return new Promise(function(_0x359d48,_0x32568b){return db[_0x49f9('0x15')][_0x49f9('0x16')](_0x509610[_0x49f9('0x17')],{'raw':_0x509610[_0x49f9('0x18')]?_0x509610[_0x49f9('0x18')][_0x49f9('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x4f0bc9){logger[_0x49f9('0x11')]('CreateAttachment',_0x509610);logger[_0x49f9('0xd')]('CreateAttachment',_0x509610,JSON['stringify'](_0x4f0bc9));_0x359d48(_0x4f0bc9);})[_0x49f9('0x13')](function(_0xde1383){logger['error'](_0x49f9('0x14'),_0xde1383['message'],_0x509610);_0x32568b(_0x3cc45e['error'](0x1f4,_0xde1383[_0x49f9('0x10')]));});});};