Built motion from commit (unavailable).|2.5.1
[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 _0x6416=['Attachment,\x20%s,\x20%s,\x20%s','error','message','result','CreateAttachment','Attachment','create','options','raw','then','stringify','moment','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','client','http','request','Attachment,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x339a74,_0x3f32ee){var _0x9e4a0e=function(_0xe4ddcd){while(--_0xe4ddcd){_0x339a74['push'](_0x339a74['shift']());}};_0x9e4a0e(++_0x3f32ee);}(_0x6416,0x1ee));var _0x6641=function(_0x1aaf46,_0x362b5d){_0x1aaf46=_0x1aaf46-0x0;var _0x3c87b9=_0x6416[_0x1aaf46];return _0x3c87b9;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x6641('0x0'));var BPromise=require(_0x6641('0x1'));var rs=require(_0x6641('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6641('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x6641('0x4'));var config=require(_0x6641('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x6641('0x6')][_0x6641('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x2cb8a2,_0x3a50aa,_0x2ed7af){return new BPromise(function(_0x172fb8,_0x2dcf60){return client[_0x6641('0x8')](_0x2cb8a2,_0x2ed7af)['then'](function(_0x58f37f){logger['info'](_0x6641('0x9'),_0x3a50aa,_0x6641('0xa'));logger[_0x6641('0xb')](_0x6641('0xc'),_0x3a50aa,_0x6641('0xa'),JSON['stringify'](_0x58f37f));if(_0x58f37f[_0x6641('0xd')]){if(_0x58f37f[_0x6641('0xd')]['code']===0x1f4){logger[_0x6641('0xd')]('Attachment,\x20%s,\x20%s',_0x3a50aa,_0x58f37f[_0x6641('0xd')][_0x6641('0xe')]);return _0x2dcf60(_0x58f37f[_0x6641('0xd')][_0x6641('0xe')]);}logger[_0x6641('0xd')](_0x6641('0x9'),_0x3a50aa,_0x58f37f[_0x6641('0xd')][_0x6641('0xe')]);return _0x172fb8(_0x58f37f[_0x6641('0xd')][_0x6641('0xe')]);}else{logger['info'](_0x6641('0x9'),_0x3a50aa,'request\x20sent');_0x172fb8(_0x58f37f[_0x6641('0xf')][_0x6641('0xe')]);}})['catch'](function(_0x5c2f48){logger[_0x6641('0xd')](_0x6641('0x9'),_0x3a50aa,_0x5c2f48);_0x2dcf60(_0x5c2f48);});});}exports[_0x6641('0x10')]=function(_0x1eba45){var _0x202523=this;return new Promise(function(_0x41a163,_0xd3a41e){return db[_0x6641('0x11')][_0x6641('0x12')](_0x1eba45['body'],{'raw':_0x1eba45[_0x6641('0x13')]?_0x1eba45[_0x6641('0x13')][_0x6641('0x14')]===undefined?!![]:![]:!![]})[_0x6641('0x15')](function(_0xf59d0e){logger['info']('CreateAttachment',_0x1eba45);logger['debug'](_0x6641('0x10'),_0x1eba45,JSON[_0x6641('0x16')](_0xf59d0e));_0x41a163(_0xf59d0e);})['catch'](function(_0x224735){logger['error'](_0x6641('0x10'),_0x224735[_0x6641('0xe')],_0x1eba45);_0xd3a41e(_0x202523['error'](0x1f4,_0x224735[_0x6641('0xe')]));});});};