Built motion from commit fe909640.|2.6.8
[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 _0xc6d8=['moment','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','request','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','create','body','options','raw','CreateAttachment','lodash'];(function(_0x3afe37,_0xb367dc){var _0xd0a372=function(_0x5d9188){while(--_0x5d9188){_0x3afe37['push'](_0x3afe37['shift']());}};_0xd0a372(++_0xb367dc);}(_0xc6d8,0xd7));var _0x8c6d=function(_0x3e0fab,_0x285e29){_0x3e0fab=_0x3e0fab-0x0;var _0x36cde8=_0xc6d8[_0x3e0fab];return _0x36cde8;};'use strict';var _=require(_0x8c6d('0x0'));var util=require('util');var moment=require(_0x8c6d('0x1'));var BPromise=require('bluebird');var rs=require(_0x8c6d('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8c6d('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x8c6d('0x4'));var config=require(_0x8c6d('0x5'));var jayson=require(_0x8c6d('0x6'));var client=jayson[_0x8c6d('0x7')][_0x8c6d('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2dbb52,_0x98cae4,_0x5529f1){return new BPromise(function(_0x1496ba,_0x75c49f){return client[_0x8c6d('0x9')](_0x2dbb52,_0x5529f1)['then'](function(_0x3cecc1){logger[_0x8c6d('0xa')](_0x8c6d('0xb'),_0x98cae4,_0x8c6d('0xc'));logger[_0x8c6d('0xd')](_0x8c6d('0xe'),_0x98cae4,_0x8c6d('0xc'),JSON[_0x8c6d('0xf')](_0x3cecc1));if(_0x3cecc1['error']){if(_0x3cecc1[_0x8c6d('0x10')]['code']===0x1f4){logger['error'](_0x8c6d('0xb'),_0x98cae4,_0x3cecc1[_0x8c6d('0x10')][_0x8c6d('0x11')]);return _0x75c49f(_0x3cecc1[_0x8c6d('0x10')][_0x8c6d('0x11')]);}logger[_0x8c6d('0x10')](_0x8c6d('0xb'),_0x98cae4,_0x3cecc1[_0x8c6d('0x10')][_0x8c6d('0x11')]);return _0x1496ba(_0x3cecc1[_0x8c6d('0x10')]['message']);}else{logger[_0x8c6d('0xa')]('Attachment,\x20%s,\x20%s',_0x98cae4,_0x8c6d('0xc'));_0x1496ba(_0x3cecc1['result'][_0x8c6d('0x11')]);}})[_0x8c6d('0x12')](function(_0x52ed7b){logger[_0x8c6d('0x10')](_0x8c6d('0xb'),_0x98cae4,_0x52ed7b);_0x75c49f(_0x52ed7b);});});}exports['CreateAttachment']=function(_0x3e5495){var _0x5a22de=this;return new Promise(function(_0x4c2f8d,_0x21b8ee){return db['Attachment'][_0x8c6d('0x13')](_0x3e5495[_0x8c6d('0x14')],{'raw':_0x3e5495[_0x8c6d('0x15')]?_0x3e5495[_0x8c6d('0x15')][_0x8c6d('0x16')]===undefined?!![]:![]:!![]})['then'](function(_0x5512be){logger['info'](_0x8c6d('0x17'),_0x3e5495);logger['debug'](_0x8c6d('0x17'),_0x3e5495,JSON['stringify'](_0x5512be));_0x4c2f8d(_0x5512be);})['catch'](function(_0x37fd7c){logger[_0x8c6d('0x10')]('CreateAttachment',_0x37fd7c['message'],_0x3e5495);_0x21b8ee(_0x5a22de['error'](0x1f4,_0x37fd7c['message']));});});};