60a7e63156c2b0890cfaaa0ad7d59bafe1facf67
[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 _0xf047=['body','options','then','CreateAttachment','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','Attachment','create'];(function(_0x554f80,_0x34e8f2){var _0x343538=function(_0x5169c4){while(--_0x5169c4){_0x554f80['push'](_0x554f80['shift']());}};_0x343538(++_0x34e8f2);}(_0xf047,0x17d));var _0x7f04=function(_0x1b3c51,_0x3d9de6){_0x1b3c51=_0x1b3c51-0x0;var _0x1a455f=_0xf047[_0x1b3c51];return _0x1a455f;};'use strict';var _=require(_0x7f04('0x0'));var util=require(_0x7f04('0x1'));var moment=require(_0x7f04('0x2'));var BPromise=require(_0x7f04('0x3'));var rs=require(_0x7f04('0x4'));var fs=require('fs');var Redis=require(_0x7f04('0x5'));var db=require(_0x7f04('0x6'))['db'];var utils=require(_0x7f04('0x7'));var logger=require('../../config/logger')(_0x7f04('0x8'));var config=require(_0x7f04('0x9'));var jayson=require(_0x7f04('0xa'));var client=jayson[_0x7f04('0xb')][_0x7f04('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x52e21e,_0x443ab7,_0x208bb6){return new BPromise(function(_0x9a67f0,_0x369107){return client[_0x7f04('0xd')](_0x52e21e,_0x208bb6)['then'](function(_0x3fa68d){logger[_0x7f04('0xe')](_0x7f04('0xf'),_0x443ab7,_0x7f04('0x10'));logger[_0x7f04('0x11')]('Attachment,\x20%s,\x20%s,\x20%s',_0x443ab7,'request\x20sent',JSON[_0x7f04('0x12')](_0x3fa68d));if(_0x3fa68d[_0x7f04('0x13')]){if(_0x3fa68d[_0x7f04('0x13')][_0x7f04('0x14')]===0x1f4){logger[_0x7f04('0x13')](_0x7f04('0xf'),_0x443ab7,_0x3fa68d[_0x7f04('0x13')][_0x7f04('0x15')]);return _0x369107(_0x3fa68d[_0x7f04('0x13')][_0x7f04('0x15')]);}logger[_0x7f04('0x13')]('Attachment,\x20%s,\x20%s',_0x443ab7,_0x3fa68d[_0x7f04('0x13')][_0x7f04('0x15')]);return _0x9a67f0(_0x3fa68d[_0x7f04('0x13')][_0x7f04('0x15')]);}else{logger[_0x7f04('0xe')](_0x7f04('0xf'),_0x443ab7,_0x7f04('0x10'));_0x9a67f0(_0x3fa68d['result'][_0x7f04('0x15')]);}})[_0x7f04('0x16')](function(_0x4f2689){logger[_0x7f04('0x13')](_0x7f04('0xf'),_0x443ab7,_0x4f2689);_0x369107(_0x4f2689);});});}exports['CreateAttachment']=function(_0x49e396){var _0x63e606=this;return new Promise(function(_0x56befc,_0x5adb17){return db[_0x7f04('0x17')][_0x7f04('0x18')](_0x49e396[_0x7f04('0x19')],{'raw':_0x49e396[_0x7f04('0x1a')]?_0x49e396[_0x7f04('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0x7f04('0x1b')](function(_0x36d0a8){logger[_0x7f04('0xe')](_0x7f04('0x1c'),_0x49e396);logger[_0x7f04('0x11')]('CreateAttachment',_0x49e396,JSON['stringify'](_0x36d0a8));_0x56befc(_0x36d0a8);})[_0x7f04('0x16')](function(_0x334ee5){logger[_0x7f04('0x13')](_0x7f04('0x1c'),_0x334ee5[_0x7f04('0x15')],_0x49e396);_0x5adb17(_0x63e606[_0x7f04('0x13')](0x1f4,_0x334ee5['message']));});});};