Built motion from commit e6806ed6.|2.6.0
[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 _0x80d9=['code','Attachment,\x20%s,\x20%s','message','result','catch','Attachment','create','body','options','raw','CreateAttachment','stringify','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','http','request','then','info','Attachment,\x20%s,\x20%s,\x20%s','request\x20sent','error'];(function(_0x42eda0,_0x389a6e){var _0x18682c=function(_0x2bd947){while(--_0x2bd947){_0x42eda0['push'](_0x42eda0['shift']());}};_0x18682c(++_0x389a6e);}(_0x80d9,0x15c));var _0x980d=function(_0x5a4e96,_0x429838){_0x5a4e96=_0x5a4e96-0x0;var _0x389d65=_0x80d9[_0x5a4e96];return _0x389d65;};'use strict';var _=require(_0x980d('0x0'));var util=require('util');var moment=require(_0x980d('0x1'));var BPromise=require(_0x980d('0x2'));var rs=require(_0x980d('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x980d('0x4'))['db'];var utils=require(_0x980d('0x5'));var logger=require(_0x980d('0x6'))(_0x980d('0x7'));var config=require(_0x980d('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0x980d('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x50854e,_0x5d9eb0,_0x7e96f7){return new BPromise(function(_0x758fc3,_0x2b8e2c){return client[_0x980d('0xa')](_0x50854e,_0x7e96f7)[_0x980d('0xb')](function(_0xef5778){logger[_0x980d('0xc')]('Attachment,\x20%s,\x20%s',_0x5d9eb0,'request\x20sent');logger['debug'](_0x980d('0xd'),_0x5d9eb0,_0x980d('0xe'),JSON['stringify'](_0xef5778));if(_0xef5778[_0x980d('0xf')]){if(_0xef5778['error'][_0x980d('0x10')]===0x1f4){logger['error'](_0x980d('0x11'),_0x5d9eb0,_0xef5778[_0x980d('0xf')][_0x980d('0x12')]);return _0x2b8e2c(_0xef5778[_0x980d('0xf')][_0x980d('0x12')]);}logger[_0x980d('0xf')](_0x980d('0x11'),_0x5d9eb0,_0xef5778[_0x980d('0xf')]['message']);return _0x758fc3(_0xef5778[_0x980d('0xf')][_0x980d('0x12')]);}else{logger[_0x980d('0xc')](_0x980d('0x11'),_0x5d9eb0,_0x980d('0xe'));_0x758fc3(_0xef5778[_0x980d('0x13')]['message']);}})[_0x980d('0x14')](function(_0x393ae2){logger['error'](_0x980d('0x11'),_0x5d9eb0,_0x393ae2);_0x2b8e2c(_0x393ae2);});});}exports['CreateAttachment']=function(_0x23f64c){var _0x1bc7e4=this;return new Promise(function(_0x39192b,_0x3c06c5){return db[_0x980d('0x15')][_0x980d('0x16')](_0x23f64c[_0x980d('0x17')],{'raw':_0x23f64c[_0x980d('0x18')]?_0x23f64c[_0x980d('0x18')][_0x980d('0x19')]===undefined?!![]:![]:!![]})[_0x980d('0xb')](function(_0x550741){logger['info'](_0x980d('0x1a'),_0x23f64c);logger['debug']('CreateAttachment',_0x23f64c,JSON[_0x980d('0x1b')](_0x550741));_0x39192b(_0x550741);})[_0x980d('0x14')](function(_0x45d698){logger[_0x980d('0xf')]('CreateAttachment',_0x45d698['message'],_0x23f64c);_0x3c06c5(_0x1bc7e4[_0x980d('0xf')](0x1f4,_0x45d698['message']));});});};