Built motion from commit 9d0783e6.|2.6.13
[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 _0xb377=['catch','CreateAttachment','Attachment','options','raw','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x4c94d1,_0x573a4f){var _0x48c2c3=function(_0x326bcc){while(--_0x326bcc){_0x4c94d1['push'](_0x4c94d1['shift']());}};_0x48c2c3(++_0x573a4f);}(_0xb377,0x1b6));var _0x7b37=function(_0x54986a,_0x1bbed2){_0x54986a=_0x54986a-0x0;var _0x4ac7d9=_0xb377[_0x54986a];return _0x4ac7d9;};'use strict';var _=require(_0x7b37('0x0'));var util=require(_0x7b37('0x1'));var moment=require(_0x7b37('0x2'));var BPromise=require(_0x7b37('0x3'));var rs=require(_0x7b37('0x4'));var fs=require('fs');var Redis=require(_0x7b37('0x5'));var db=require(_0x7b37('0x6'))['db'];var utils=require(_0x7b37('0x7'));var logger=require(_0x7b37('0x8'))(_0x7b37('0x9'));var config=require(_0x7b37('0xa'));var jayson=require(_0x7b37('0xb'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x409d34,_0x4cb89b,_0x5afdb8){return new BPromise(function(_0x3de992,_0x3df40f){return client[_0x7b37('0xc')](_0x409d34,_0x5afdb8)[_0x7b37('0xd')](function(_0x1d435b){logger[_0x7b37('0xe')](_0x7b37('0xf'),_0x4cb89b,_0x7b37('0x10'));logger['debug'](_0x7b37('0x11'),_0x4cb89b,_0x7b37('0x10'),JSON['stringify'](_0x1d435b));if(_0x1d435b['error']){if(_0x1d435b[_0x7b37('0x12')][_0x7b37('0x13')]===0x1f4){logger[_0x7b37('0x12')](_0x7b37('0xf'),_0x4cb89b,_0x1d435b[_0x7b37('0x12')][_0x7b37('0x14')]);return _0x3df40f(_0x1d435b[_0x7b37('0x12')][_0x7b37('0x14')]);}logger[_0x7b37('0x12')](_0x7b37('0xf'),_0x4cb89b,_0x1d435b[_0x7b37('0x12')][_0x7b37('0x14')]);return _0x3de992(_0x1d435b[_0x7b37('0x12')][_0x7b37('0x14')]);}else{logger[_0x7b37('0xe')](_0x7b37('0xf'),_0x4cb89b,_0x7b37('0x10'));_0x3de992(_0x1d435b['result']['message']);}})[_0x7b37('0x15')](function(_0x5b06f9){logger['error'](_0x7b37('0xf'),_0x4cb89b,_0x5b06f9);_0x3df40f(_0x5b06f9);});});}exports[_0x7b37('0x16')]=function(_0x1447aa){var _0x487f5c=this;return new Promise(function(_0x29a9dd,_0x46955a){return db[_0x7b37('0x17')]['create'](_0x1447aa['body'],{'raw':_0x1447aa[_0x7b37('0x18')]?_0x1447aa[_0x7b37('0x18')][_0x7b37('0x19')]===undefined?!![]:![]:!![]})[_0x7b37('0xd')](function(_0x30bf66){logger['info']('CreateAttachment',_0x1447aa);logger['debug'](_0x7b37('0x16'),_0x1447aa,JSON[_0x7b37('0x1a')](_0x30bf66));_0x29a9dd(_0x30bf66);})[_0x7b37('0x15')](function(_0x200f17){logger[_0x7b37('0x12')](_0x7b37('0x16'),_0x200f17[_0x7b37('0x14')],_0x1447aa);_0x46955a(_0x487f5c['error'](0x1f4,_0x200f17[_0x7b37('0x14')]));});});};