cfe5c3eb31fa8590e67f0adb690f3d3db4b523f9
[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 _0x83f1=['CreateAttachment','lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','Attachment','create','options','raw'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x83f1,0x1cc));var _0x183f=function(_0x4ca056,_0x5cf0a0){_0x4ca056=_0x4ca056-0x0;var _0x27d6e3=_0x83f1[_0x4ca056];return _0x27d6e3;};'use strict';var _=require(_0x183f('0x0'));var util=require(_0x183f('0x1'));var moment=require(_0x183f('0x2'));var BPromise=require(_0x183f('0x3'));var rs=require(_0x183f('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x183f('0x5'));var logger=require(_0x183f('0x6'))(_0x183f('0x7'));var config=require(_0x183f('0x8'));var jayson=require(_0x183f('0x9'));var client=jayson['client'][_0x183f('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xf702f5,_0x364cc4,_0x5c75c3){return new BPromise(function(_0x434be2,_0x5bdf95){return client[_0x183f('0xb')](_0xf702f5,_0x5c75c3)[_0x183f('0xc')](function(_0x37ed60){logger[_0x183f('0xd')](_0x183f('0xe'),_0x364cc4,_0x183f('0xf'));logger[_0x183f('0x10')]('Attachment,\x20%s,\x20%s,\x20%s',_0x364cc4,_0x183f('0xf'),JSON[_0x183f('0x11')](_0x37ed60));if(_0x37ed60[_0x183f('0x12')]){if(_0x37ed60[_0x183f('0x12')][_0x183f('0x13')]===0x1f4){logger[_0x183f('0x12')](_0x183f('0xe'),_0x364cc4,_0x37ed60['error'][_0x183f('0x14')]);return _0x5bdf95(_0x37ed60['error']['message']);}logger[_0x183f('0x12')](_0x183f('0xe'),_0x364cc4,_0x37ed60[_0x183f('0x12')][_0x183f('0x14')]);return _0x434be2(_0x37ed60[_0x183f('0x12')]['message']);}else{logger[_0x183f('0xd')]('Attachment,\x20%s,\x20%s',_0x364cc4,_0x183f('0xf'));_0x434be2(_0x37ed60[_0x183f('0x15')][_0x183f('0x14')]);}})['catch'](function(_0xe9c5d9){logger[_0x183f('0x12')](_0x183f('0xe'),_0x364cc4,_0xe9c5d9);_0x5bdf95(_0xe9c5d9);});});}exports['CreateAttachment']=function(_0x284244){var _0x2b819e=this;return new Promise(function(_0x2c3468,_0x3f713f){return db[_0x183f('0x16')][_0x183f('0x17')](_0x284244['body'],{'raw':_0x284244[_0x183f('0x18')]?_0x284244[_0x183f('0x18')][_0x183f('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x26a103){logger['info'](_0x183f('0x1a'),_0x284244);logger[_0x183f('0x10')](_0x183f('0x1a'),_0x284244,JSON[_0x183f('0x11')](_0x26a103));_0x2c3468(_0x26a103);})['catch'](function(_0x3a1bec){logger[_0x183f('0x12')](_0x183f('0x1a'),_0x3a1bec[_0x183f('0x14')],_0x284244);_0x3f713f(_0x2b819e[_0x183f('0x12')](0x1f4,_0x3a1bec[_0x183f('0x14')]));});});};