Built motion from commit (unavailable).|2.5.15
[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 _0xee11=['lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','request','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','CreateAttachment','Attachment','options','raw'];(function(_0x55cd61,_0x3164d1){var _0x4c7080=function(_0x7b2728){while(--_0x7b2728){_0x55cd61['push'](_0x55cd61['shift']());}};_0x4c7080(++_0x3164d1);}(_0xee11,0xea));var _0x1ee1=function(_0x4ab8af,_0x1b426c){_0x4ab8af=_0x4ab8af-0x0;var _0x70272c=_0xee11[_0x4ab8af];return _0x70272c;};'use strict';var _=require(_0x1ee1('0x0'));var util=require(_0x1ee1('0x1'));var moment=require(_0x1ee1('0x2'));var BPromise=require(_0x1ee1('0x3'));var rs=require(_0x1ee1('0x4'));var fs=require('fs');var Redis=require(_0x1ee1('0x5'));var db=require(_0x1ee1('0x6'))['db'];var utils=require(_0x1ee1('0x7'));var logger=require('../../config/logger')(_0x1ee1('0x8'));var config=require('../../config/environment');var jayson=require(_0x1ee1('0x9'));var client=jayson[_0x1ee1('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4c1180,_0x1356fa,_0x370cbb){return new BPromise(function(_0x366e26,_0x2f4963){return client[_0x1ee1('0xb')](_0x4c1180,_0x370cbb)['then'](function(_0x21f5d9){logger[_0x1ee1('0xc')](_0x1ee1('0xd'),_0x1356fa,_0x1ee1('0xe'));logger[_0x1ee1('0xf')](_0x1ee1('0x10'),_0x1356fa,_0x1ee1('0xe'),JSON[_0x1ee1('0x11')](_0x21f5d9));if(_0x21f5d9[_0x1ee1('0x12')]){if(_0x21f5d9[_0x1ee1('0x12')][_0x1ee1('0x13')]===0x1f4){logger[_0x1ee1('0x12')]('Attachment,\x20%s,\x20%s',_0x1356fa,_0x21f5d9[_0x1ee1('0x12')][_0x1ee1('0x14')]);return _0x2f4963(_0x21f5d9['error']['message']);}logger['error'](_0x1ee1('0xd'),_0x1356fa,_0x21f5d9[_0x1ee1('0x12')][_0x1ee1('0x14')]);return _0x366e26(_0x21f5d9[_0x1ee1('0x12')][_0x1ee1('0x14')]);}else{logger[_0x1ee1('0xc')]('Attachment,\x20%s,\x20%s',_0x1356fa,_0x1ee1('0xe'));_0x366e26(_0x21f5d9[_0x1ee1('0x15')]['message']);}})['catch'](function(_0x2ebbfe){logger['error']('Attachment,\x20%s,\x20%s',_0x1356fa,_0x2ebbfe);_0x2f4963(_0x2ebbfe);});});}exports[_0x1ee1('0x16')]=function(_0x2f8859){var _0x226d61=this;return new Promise(function(_0x5b1f8c,_0x2d7621){return db[_0x1ee1('0x17')]['create'](_0x2f8859['body'],{'raw':_0x2f8859[_0x1ee1('0x18')]?_0x2f8859[_0x1ee1('0x18')][_0x1ee1('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x1d779d){logger[_0x1ee1('0xc')](_0x1ee1('0x16'),_0x2f8859);logger[_0x1ee1('0xf')](_0x1ee1('0x16'),_0x2f8859,JSON[_0x1ee1('0x11')](_0x1d779d));_0x5b1f8c(_0x1d779d);})['catch'](function(_0x5d7223){logger[_0x1ee1('0x12')](_0x1ee1('0x16'),_0x5d7223[_0x1ee1('0x14')],_0x2f8859);_0x2d7621(_0x226d61[_0x1ee1('0x12')](0x1f4,_0x5d7223['message']));});});};