5b400656f317105465533ab12eafb89f7e403e63
[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 _0x8aa7=['ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateAttachment','Attachment','create','body','options','raw','stringify','util','moment','bluebird','randomstring'];(function(_0x3c90df,_0x249ce5){var _0x15c7a6=function(_0x33c960){while(--_0x33c960){_0x3c90df['push'](_0x3c90df['shift']());}};_0x15c7a6(++_0x249ce5);}(_0x8aa7,0xb6));var _0x78aa=function(_0x5f09c5,_0x2bfca0){_0x5f09c5=_0x5f09c5-0x0;var _0x426ad9=_0x8aa7[_0x5f09c5];return _0x426ad9;};'use strict';var _=require('lodash');var util=require(_0x78aa('0x0'));var moment=require(_0x78aa('0x1'));var BPromise=require(_0x78aa('0x2'));var rs=require(_0x78aa('0x3'));var fs=require('fs');var Redis=require(_0x78aa('0x4'));var db=require(_0x78aa('0x5'))['db'];var utils=require(_0x78aa('0x6'));var logger=require('../../config/logger')(_0x78aa('0x7'));var config=require(_0x78aa('0x8'));var jayson=require(_0x78aa('0x9'));var client=jayson[_0x78aa('0xa')][_0x78aa('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x369ee7,_0x462a9a,_0xa79008){return new BPromise(function(_0x2368ac,_0x460488){return client[_0x78aa('0xc')](_0x369ee7,_0xa79008)[_0x78aa('0xd')](function(_0x45d377){logger[_0x78aa('0xe')](_0x78aa('0xf'),_0x462a9a,_0x78aa('0x10'));logger[_0x78aa('0x11')](_0x78aa('0x12'),_0x462a9a,_0x78aa('0x10'),JSON['stringify'](_0x45d377));if(_0x45d377['error']){if(_0x45d377[_0x78aa('0x13')][_0x78aa('0x14')]===0x1f4){logger['error'](_0x78aa('0xf'),_0x462a9a,_0x45d377[_0x78aa('0x13')][_0x78aa('0x15')]);return _0x460488(_0x45d377[_0x78aa('0x13')][_0x78aa('0x15')]);}logger['error'](_0x78aa('0xf'),_0x462a9a,_0x45d377[_0x78aa('0x13')][_0x78aa('0x15')]);return _0x2368ac(_0x45d377[_0x78aa('0x13')][_0x78aa('0x15')]);}else{logger['info'](_0x78aa('0xf'),_0x462a9a,_0x78aa('0x10'));_0x2368ac(_0x45d377[_0x78aa('0x16')][_0x78aa('0x15')]);}})[_0x78aa('0x17')](function(_0x2897f8){logger['error']('Attachment,\x20%s,\x20%s',_0x462a9a,_0x2897f8);_0x460488(_0x2897f8);});});}exports[_0x78aa('0x18')]=function(_0x345e4d){var _0xc316d9=this;return new Promise(function(_0x4207b0,_0x9879bf){return db[_0x78aa('0x19')][_0x78aa('0x1a')](_0x345e4d[_0x78aa('0x1b')],{'raw':_0x345e4d[_0x78aa('0x1c')]?_0x345e4d[_0x78aa('0x1c')][_0x78aa('0x1d')]===undefined?!![]:![]:!![]})['then'](function(_0x18c60d){logger[_0x78aa('0xe')]('CreateAttachment',_0x345e4d);logger[_0x78aa('0x11')](_0x78aa('0x18'),_0x345e4d,JSON[_0x78aa('0x1e')](_0x18c60d));_0x4207b0(_0x18c60d);})['catch'](function(_0x5a9dbf){logger[_0x78aa('0x13')](_0x78aa('0x18'),_0x5a9dbf['message'],_0x345e4d);_0x9879bf(_0xc316d9[_0x78aa('0x13')](0x1f4,_0x5a9dbf[_0x78aa('0x15')]));});});};