Built motion from commit (unavailable).|2.3.1
[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 _0xe5c7=['result','catch','Attachment','body','options','raw','CreateAttachment','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x4a29a9,_0x58cd04){var _0x386570=function(_0x1d2d09){while(--_0x1d2d09){_0x4a29a9['push'](_0x4a29a9['shift']());}};_0x386570(++_0x58cd04);}(_0xe5c7,0x1d8));var _0x7e5c=function(_0x48adca,_0x340611){_0x48adca=_0x48adca-0x0;var _0x49f030=_0xe5c7[_0x48adca];return _0x49f030;};'use strict';var _=require(_0x7e5c('0x0'));var util=require(_0x7e5c('0x1'));var moment=require(_0x7e5c('0x2'));var BPromise=require(_0x7e5c('0x3'));var rs=require(_0x7e5c('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7e5c('0x5'))['db'];var utils=require(_0x7e5c('0x6'));var logger=require(_0x7e5c('0x7'))(_0x7e5c('0x8'));var config=require(_0x7e5c('0x9'));var jayson=require(_0x7e5c('0xa'));var client=jayson[_0x7e5c('0xb')][_0x7e5c('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x276ec9,_0x2eac84,_0x39e5be){return new BPromise(function(_0x2fc5bc,_0x467787){return client[_0x7e5c('0xd')](_0x276ec9,_0x39e5be)[_0x7e5c('0xe')](function(_0x11aac8){logger[_0x7e5c('0xf')](_0x7e5c('0x10'),_0x2eac84,_0x7e5c('0x11'));logger[_0x7e5c('0x12')](_0x7e5c('0x13'),_0x2eac84,_0x7e5c('0x11'),JSON[_0x7e5c('0x14')](_0x11aac8));if(_0x11aac8[_0x7e5c('0x15')]){if(_0x11aac8[_0x7e5c('0x15')][_0x7e5c('0x16')]===0x1f4){logger['error'](_0x7e5c('0x10'),_0x2eac84,_0x11aac8[_0x7e5c('0x15')]['message']);return _0x467787(_0x11aac8[_0x7e5c('0x15')][_0x7e5c('0x17')]);}logger[_0x7e5c('0x15')]('Attachment,\x20%s,\x20%s',_0x2eac84,_0x11aac8[_0x7e5c('0x15')]['message']);return _0x2fc5bc(_0x11aac8[_0x7e5c('0x15')]['message']);}else{logger['info'](_0x7e5c('0x10'),_0x2eac84,'request\x20sent');_0x2fc5bc(_0x11aac8[_0x7e5c('0x18')][_0x7e5c('0x17')]);}})[_0x7e5c('0x19')](function(_0x17de6a){logger[_0x7e5c('0x15')](_0x7e5c('0x10'),_0x2eac84,_0x17de6a);_0x467787(_0x17de6a);});});}exports['CreateAttachment']=function(_0xa796d6){var _0x49de03=this;return new Promise(function(_0x307b31,_0x1a4a9b){return db[_0x7e5c('0x1a')]['create'](_0xa796d6[_0x7e5c('0x1b')],{'raw':_0xa796d6[_0x7e5c('0x1c')]?_0xa796d6[_0x7e5c('0x1c')][_0x7e5c('0x1d')]===undefined?!![]:![]:!![]})[_0x7e5c('0xe')](function(_0x2fb8e0){logger['info'](_0x7e5c('0x1e'),_0xa796d6);logger[_0x7e5c('0x12')](_0x7e5c('0x1e'),_0xa796d6,JSON['stringify'](_0x2fb8e0));_0x307b31(_0x2fb8e0);})[_0x7e5c('0x19')](function(_0x269133){logger[_0x7e5c('0x15')]('CreateAttachment',_0x269133[_0x7e5c('0x17')],_0xa796d6);_0x1a4a9b(_0x49de03[_0x7e5c('0x15')](0x1f4,_0x269133[_0x7e5c('0x17')]));});});};