f35fd2004879c7f4256475fa9d13ae21d22893b2
[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 _0x9c47=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateAttachment','create','body','options','raw','lodash','util'];(function(_0x31d3fe,_0x4cf03a){var _0x43cbf4=function(_0xa49b96){while(--_0xa49b96){_0x31d3fe['push'](_0x31d3fe['shift']());}};_0x43cbf4(++_0x4cf03a);}(_0x9c47,0x1ce));var _0x79c4=function(_0x2a7e5b,_0x36e1e3){_0x2a7e5b=_0x2a7e5b-0x0;var _0x5259d9=_0x9c47[_0x2a7e5b];return _0x5259d9;};'use strict';var _=require(_0x79c4('0x0'));var util=require(_0x79c4('0x1'));var moment=require(_0x79c4('0x2'));var BPromise=require(_0x79c4('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x79c4('0x4'));var db=require(_0x79c4('0x5'))['db'];var utils=require(_0x79c4('0x6'));var logger=require(_0x79c4('0x7'))(_0x79c4('0x8'));var config=require('../../config/environment');var jayson=require(_0x79c4('0x9'));var client=jayson['client'][_0x79c4('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x648aac,_0x2d4313,_0x2a887f){return new BPromise(function(_0x1b1395,_0x7b0e75){return client[_0x79c4('0xb')](_0x648aac,_0x2a887f)[_0x79c4('0xc')](function(_0x50c78f){logger[_0x79c4('0xd')](_0x79c4('0xe'),_0x2d4313,_0x79c4('0xf'));logger[_0x79c4('0x10')](_0x79c4('0x11'),_0x2d4313,'request\x20sent',JSON[_0x79c4('0x12')](_0x50c78f));if(_0x50c78f[_0x79c4('0x13')]){if(_0x50c78f[_0x79c4('0x13')][_0x79c4('0x14')]===0x1f4){logger[_0x79c4('0x13')](_0x79c4('0xe'),_0x2d4313,_0x50c78f['error'][_0x79c4('0x15')]);return _0x7b0e75(_0x50c78f[_0x79c4('0x13')][_0x79c4('0x15')]);}logger[_0x79c4('0x13')]('Attachment,\x20%s,\x20%s',_0x2d4313,_0x50c78f[_0x79c4('0x13')][_0x79c4('0x15')]);return _0x1b1395(_0x50c78f[_0x79c4('0x13')][_0x79c4('0x15')]);}else{logger['info'](_0x79c4('0xe'),_0x2d4313,'request\x20sent');_0x1b1395(_0x50c78f[_0x79c4('0x16')][_0x79c4('0x15')]);}})[_0x79c4('0x17')](function(_0x2913c1){logger[_0x79c4('0x13')](_0x79c4('0xe'),_0x2d4313,_0x2913c1);_0x7b0e75(_0x2913c1);});});}exports[_0x79c4('0x18')]=function(_0x3742f2){var _0xfd6353=this;return new Promise(function(_0x4d7d77,_0x3e4ccc){return db['Attachment'][_0x79c4('0x19')](_0x3742f2[_0x79c4('0x1a')],{'raw':_0x3742f2[_0x79c4('0x1b')]?_0x3742f2[_0x79c4('0x1b')][_0x79c4('0x1c')]===undefined?!![]:![]:!![]})['then'](function(_0x432a27){logger[_0x79c4('0xd')](_0x79c4('0x18'),_0x3742f2);logger[_0x79c4('0x10')](_0x79c4('0x18'),_0x3742f2,JSON[_0x79c4('0x12')](_0x432a27));_0x4d7d77(_0x432a27);})[_0x79c4('0x17')](function(_0x4eeb8e){logger[_0x79c4('0x13')](_0x79c4('0x18'),_0x4eeb8e['message'],_0x3742f2);_0x3e4ccc(_0xfd6353[_0x79c4('0x13')](0x1f4,_0x4eeb8e['message']));});});};