Built motion from commit (unavailable).|2.5.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 _0xb904=['../../config/environment','jayson/promise','client','http','then','info','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','Attachment,\x20%s,\x20%s','message','result','catch','CreateAttachment','Attachment','create','body','options','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x2fc7c3,_0x91b05f){var _0x3da068=function(_0x568998){while(--_0x568998){_0x2fc7c3['push'](_0x2fc7c3['shift']());}};_0x3da068(++_0x91b05f);}(_0xb904,0xe0));var _0x4b90=function(_0x34955a,_0x386497){_0x34955a=_0x34955a-0x0;var _0x391918=_0xb904[_0x34955a];return _0x391918;};'use strict';var _=require(_0x4b90('0x0'));var util=require(_0x4b90('0x1'));var moment=require(_0x4b90('0x2'));var BPromise=require('bluebird');var rs=require(_0x4b90('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4b90('0x4'))['db'];var utils=require(_0x4b90('0x5'));var logger=require(_0x4b90('0x6'))(_0x4b90('0x7'));var config=require(_0x4b90('0x8'));var jayson=require(_0x4b90('0x9'));var client=jayson[_0x4b90('0xa')][_0x4b90('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x56d595,_0x35cb29,_0x4af021){return new BPromise(function(_0x31390d,_0x429f04){return client['request'](_0x56d595,_0x4af021)[_0x4b90('0xc')](function(_0x1c2405){logger[_0x4b90('0xd')]('Attachment,\x20%s,\x20%s',_0x35cb29,_0x4b90('0xe'));logger[_0x4b90('0xf')](_0x4b90('0x10'),_0x35cb29,_0x4b90('0xe'),JSON[_0x4b90('0x11')](_0x1c2405));if(_0x1c2405[_0x4b90('0x12')]){if(_0x1c2405[_0x4b90('0x12')][_0x4b90('0x13')]===0x1f4){logger['error'](_0x4b90('0x14'),_0x35cb29,_0x1c2405[_0x4b90('0x12')][_0x4b90('0x15')]);return _0x429f04(_0x1c2405[_0x4b90('0x12')][_0x4b90('0x15')]);}logger[_0x4b90('0x12')](_0x4b90('0x14'),_0x35cb29,_0x1c2405[_0x4b90('0x12')][_0x4b90('0x15')]);return _0x31390d(_0x1c2405[_0x4b90('0x12')]['message']);}else{logger['info'](_0x4b90('0x14'),_0x35cb29,_0x4b90('0xe'));_0x31390d(_0x1c2405[_0x4b90('0x16')]['message']);}})[_0x4b90('0x17')](function(_0x22f090){logger[_0x4b90('0x12')]('Attachment,\x20%s,\x20%s',_0x35cb29,_0x22f090);_0x429f04(_0x22f090);});});}exports[_0x4b90('0x18')]=function(_0x3da74f){var _0x2a2ed1=this;return new Promise(function(_0x11ec1d,_0x1f4c13){return db[_0x4b90('0x19')][_0x4b90('0x1a')](_0x3da74f[_0x4b90('0x1b')],{'raw':_0x3da74f[_0x4b90('0x1c')]?_0x3da74f[_0x4b90('0x1c')]['raw']===undefined?!![]:![]:!![]})[_0x4b90('0xc')](function(_0x855991){logger['info'](_0x4b90('0x18'),_0x3da74f);logger['debug'](_0x4b90('0x18'),_0x3da74f,JSON[_0x4b90('0x11')](_0x855991));_0x11ec1d(_0x855991);})[_0x4b90('0x17')](function(_0x393dc3){logger[_0x4b90('0x12')](_0x4b90('0x18'),_0x393dc3[_0x4b90('0x15')],_0x3da74f);_0x1f4c13(_0x2a2ed1['error'](0x1f4,_0x393dc3['message']));});});};