Built motion from commit (unavailable).|2.4.4
[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 _0xb9b4=['util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','then','request\x20sent','debug','stringify','error','code','Attachment,\x20%s,\x20%s','message','info','catch','CreateAttachment','Attachment','create','body','options','raw','lodash'];(function(_0x2e3a2b,_0x59b466){var _0x3d416f=function(_0x19a3e3){while(--_0x19a3e3){_0x2e3a2b['push'](_0x2e3a2b['shift']());}};_0x3d416f(++_0x59b466);}(_0xb9b4,0x137));var _0x4b9b=function(_0x2df939,_0x277258){_0x2df939=_0x2df939-0x0;var _0x471dad=_0xb9b4[_0x2df939];return _0x471dad;};'use strict';var _=require(_0x4b9b('0x0'));var util=require(_0x4b9b('0x1'));var moment=require(_0x4b9b('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4b9b('0x3'));var db=require(_0x4b9b('0x4'))['db'];var utils=require(_0x4b9b('0x5'));var logger=require(_0x4b9b('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0x4b9b('0x7'));var client=jayson[_0x4b9b('0x8')][_0x4b9b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x535ef0,_0x54eb6b,_0x2807ef){return new BPromise(function(_0x279e96,_0x3d3f17){return client['request'](_0x535ef0,_0x2807ef)[_0x4b9b('0xa')](function(_0x57c2aa){logger['info']('Attachment,\x20%s,\x20%s',_0x54eb6b,_0x4b9b('0xb'));logger[_0x4b9b('0xc')]('Attachment,\x20%s,\x20%s,\x20%s',_0x54eb6b,'request\x20sent',JSON[_0x4b9b('0xd')](_0x57c2aa));if(_0x57c2aa[_0x4b9b('0xe')]){if(_0x57c2aa[_0x4b9b('0xe')][_0x4b9b('0xf')]===0x1f4){logger['error'](_0x4b9b('0x10'),_0x54eb6b,_0x57c2aa[_0x4b9b('0xe')]['message']);return _0x3d3f17(_0x57c2aa[_0x4b9b('0xe')][_0x4b9b('0x11')]);}logger['error'](_0x4b9b('0x10'),_0x54eb6b,_0x57c2aa[_0x4b9b('0xe')]['message']);return _0x279e96(_0x57c2aa[_0x4b9b('0xe')][_0x4b9b('0x11')]);}else{logger[_0x4b9b('0x12')](_0x4b9b('0x10'),_0x54eb6b,_0x4b9b('0xb'));_0x279e96(_0x57c2aa['result'][_0x4b9b('0x11')]);}})[_0x4b9b('0x13')](function(_0x2be6ed){logger[_0x4b9b('0xe')]('Attachment,\x20%s,\x20%s',_0x54eb6b,_0x2be6ed);_0x3d3f17(_0x2be6ed);});});}exports[_0x4b9b('0x14')]=function(_0x2fc540){var _0x1d564e=this;return new Promise(function(_0x114a39,_0x55b163){return db[_0x4b9b('0x15')][_0x4b9b('0x16')](_0x2fc540[_0x4b9b('0x17')],{'raw':_0x2fc540[_0x4b9b('0x18')]?_0x2fc540[_0x4b9b('0x18')][_0x4b9b('0x19')]===undefined?!![]:![]:!![]})[_0x4b9b('0xa')](function(_0x30b29d){logger['info'](_0x4b9b('0x14'),_0x2fc540);logger[_0x4b9b('0xc')](_0x4b9b('0x14'),_0x2fc540,JSON[_0x4b9b('0xd')](_0x30b29d));_0x114a39(_0x30b29d);})[_0x4b9b('0x13')](function(_0x51399e){logger[_0x4b9b('0xe')](_0x4b9b('0x14'),_0x51399e[_0x4b9b('0x11')],_0x2fc540);_0x55b163(_0x1d564e['error'](0x1f4,_0x51399e['message']));});});};