Built motion from commit 44b1f254.|2.6.26
[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 _0xf290=['../../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','error','code','message','catch','CreateAttachment','create','body','options','raw','util','bluebird','ioredis'];(function(_0x3b39af,_0x1878df){var _0x25f1ea=function(_0x493c27){while(--_0x493c27){_0x3b39af['push'](_0x3b39af['shift']());}};_0x25f1ea(++_0x1878df);}(_0xf290,0xde));var _0x0f29=function(_0x685346,_0x3ef2e5){_0x685346=_0x685346-0x0;var _0x52e15b=_0xf290[_0x685346];return _0x52e15b;};'use strict';var _=require('lodash');var util=require(_0x0f29('0x0'));var moment=require('moment');var BPromise=require(_0x0f29('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0f29('0x2'));var db=require(_0x0f29('0x3'))['db'];var utils=require(_0x0f29('0x4'));var logger=require(_0x0f29('0x5'))(_0x0f29('0x6'));var config=require('../../config/environment');var jayson=require(_0x0f29('0x7'));var client=jayson['client'][_0x0f29('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1c45ec,_0x355e21,_0xaa2675){return new BPromise(function(_0xc78ca2,_0x45350b){return client[_0x0f29('0x9')](_0x1c45ec,_0xaa2675)[_0x0f29('0xa')](function(_0x376de4){logger[_0x0f29('0xb')](_0x0f29('0xc'),_0x355e21,_0x0f29('0xd'));logger[_0x0f29('0xe')](_0x0f29('0xf'),_0x355e21,_0x0f29('0xd'),JSON['stringify'](_0x376de4));if(_0x376de4[_0x0f29('0x10')]){if(_0x376de4['error'][_0x0f29('0x11')]===0x1f4){logger[_0x0f29('0x10')](_0x0f29('0xc'),_0x355e21,_0x376de4[_0x0f29('0x10')][_0x0f29('0x12')]);return _0x45350b(_0x376de4[_0x0f29('0x10')]['message']);}logger[_0x0f29('0x10')](_0x0f29('0xc'),_0x355e21,_0x376de4[_0x0f29('0x10')][_0x0f29('0x12')]);return _0xc78ca2(_0x376de4[_0x0f29('0x10')][_0x0f29('0x12')]);}else{logger[_0x0f29('0xb')](_0x0f29('0xc'),_0x355e21,'request\x20sent');_0xc78ca2(_0x376de4['result'][_0x0f29('0x12')]);}})[_0x0f29('0x13')](function(_0x38031e){logger[_0x0f29('0x10')]('Attachment,\x20%s,\x20%s',_0x355e21,_0x38031e);_0x45350b(_0x38031e);});});}exports[_0x0f29('0x14')]=function(_0x5d72a5){var _0x17b994=this;return new Promise(function(_0x4ca5e8,_0x5ddc74){return db['Attachment'][_0x0f29('0x15')](_0x5d72a5[_0x0f29('0x16')],{'raw':_0x5d72a5[_0x0f29('0x17')]?_0x5d72a5[_0x0f29('0x17')][_0x0f29('0x18')]===undefined?!![]:![]:!![]})[_0x0f29('0xa')](function(_0x150271){logger['info'](_0x0f29('0x14'),_0x5d72a5);logger['debug']('CreateAttachment',_0x5d72a5,JSON['stringify'](_0x150271));_0x4ca5e8(_0x150271);})['catch'](function(_0x38a1ce){logger[_0x0f29('0x10')]('CreateAttachment',_0x38a1ce[_0x0f29('0x12')],_0x5d72a5);_0x5ddc74(_0x17b994[_0x0f29('0x10')](0x1f4,_0x38a1ce[_0x0f29('0x12')]));});});};