401350b88f5eb506bbab89bd152777df797d34c1
[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 _0x422f=['client','http','request','then','info','debug','Attachment,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','Attachment,\x20%s,\x20%s','result','catch','CreateAttachment','create','body','options','raw','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0xb99421,_0xaab133){var _0x4b3ec7=function(_0x591d1a){while(--_0x591d1a){_0xb99421['push'](_0xb99421['shift']());}};_0x4b3ec7(++_0xaab133);}(_0x422f,0x1c7));var _0xf422=function(_0x20402d,_0x418c0d){_0x20402d=_0x20402d-0x0;var _0x1061e9=_0x422f[_0x20402d];return _0x1061e9;};'use strict';var _=require('lodash');var util=require(_0xf422('0x0'));var moment=require('moment');var BPromise=require(_0xf422('0x1'));var rs=require(_0xf422('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf422('0x3'))['db'];var utils=require(_0xf422('0x4'));var logger=require(_0xf422('0x5'))(_0xf422('0x6'));var config=require(_0xf422('0x7'));var jayson=require(_0xf422('0x8'));var client=jayson[_0xf422('0x9')][_0xf422('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x350b2d,_0x583283,_0x3f4801){return new BPromise(function(_0x1037fa,_0xc2c9f5){return client[_0xf422('0xb')](_0x350b2d,_0x3f4801)[_0xf422('0xc')](function(_0x5f02da){logger[_0xf422('0xd')]('Attachment,\x20%s,\x20%s',_0x583283,'request\x20sent');logger[_0xf422('0xe')](_0xf422('0xf'),_0x583283,_0xf422('0x10'),JSON[_0xf422('0x11')](_0x5f02da));if(_0x5f02da[_0xf422('0x12')]){if(_0x5f02da['error'][_0xf422('0x13')]===0x1f4){logger[_0xf422('0x12')]('Attachment,\x20%s,\x20%s',_0x583283,_0x5f02da[_0xf422('0x12')][_0xf422('0x14')]);return _0xc2c9f5(_0x5f02da[_0xf422('0x12')][_0xf422('0x14')]);}logger[_0xf422('0x12')](_0xf422('0x15'),_0x583283,_0x5f02da[_0xf422('0x12')][_0xf422('0x14')]);return _0x1037fa(_0x5f02da[_0xf422('0x12')]['message']);}else{logger['info']('Attachment,\x20%s,\x20%s',_0x583283,_0xf422('0x10'));_0x1037fa(_0x5f02da[_0xf422('0x16')][_0xf422('0x14')]);}})[_0xf422('0x17')](function(_0x5f3de5){logger[_0xf422('0x12')](_0xf422('0x15'),_0x583283,_0x5f3de5);_0xc2c9f5(_0x5f3de5);});});}exports[_0xf422('0x18')]=function(_0x2ae133){var _0x43de64=this;return new Promise(function(_0x29b0b1,_0x4fefd0){return db['Attachment'][_0xf422('0x19')](_0x2ae133[_0xf422('0x1a')],{'raw':_0x2ae133[_0xf422('0x1b')]?_0x2ae133['options'][_0xf422('0x1c')]===undefined?!![]:![]:!![]})['then'](function(_0x22afe7){logger[_0xf422('0xd')](_0xf422('0x18'),_0x2ae133);logger['debug'](_0xf422('0x18'),_0x2ae133,JSON[_0xf422('0x11')](_0x22afe7));_0x29b0b1(_0x22afe7);})['catch'](function(_0x4b80a0){logger[_0xf422('0x12')](_0xf422('0x18'),_0x4b80a0['message'],_0x2ae133);_0x4fefd0(_0x43de64[_0xf422('0x12')](0x1f4,_0x4b80a0['message']));});});};