Built motion from commit 47436d59.|2.6.7
[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 _0x24cd=['http','request','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateAttachment','Attachment','create','options','raw','then','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client'];(function(_0x5220d7,_0x5b77d7){var _0x374b43=function(_0x59eb2c){while(--_0x59eb2c){_0x5220d7['push'](_0x5220d7['shift']());}};_0x374b43(++_0x5b77d7);}(_0x24cd,0x83));var _0xd24c=function(_0x4650d2,_0x1dbc2f){_0x4650d2=_0x4650d2-0x0;var _0x5ae544=_0x24cd[_0x4650d2];return _0x5ae544;};'use strict';var _=require(_0xd24c('0x0'));var util=require(_0xd24c('0x1'));var moment=require('moment');var BPromise=require(_0xd24c('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xd24c('0x3'));var db=require(_0xd24c('0x4'))['db'];var utils=require(_0xd24c('0x5'));var logger=require('../../config/logger')(_0xd24c('0x6'));var config=require(_0xd24c('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xd24c('0x8')][_0xd24c('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2a432a,_0x95eb94,_0x3d4d20){return new BPromise(function(_0x411706,_0x3df525){return client[_0xd24c('0xa')](_0x2a432a,_0x3d4d20)['then'](function(_0x4c4455){logger[_0xd24c('0xb')](_0xd24c('0xc'),_0x95eb94,_0xd24c('0xd'));logger[_0xd24c('0xe')](_0xd24c('0xf'),_0x95eb94,_0xd24c('0xd'),JSON[_0xd24c('0x10')](_0x4c4455));if(_0x4c4455[_0xd24c('0x11')]){if(_0x4c4455['error'][_0xd24c('0x12')]===0x1f4){logger[_0xd24c('0x11')]('Attachment,\x20%s,\x20%s',_0x95eb94,_0x4c4455[_0xd24c('0x11')][_0xd24c('0x13')]);return _0x3df525(_0x4c4455[_0xd24c('0x11')][_0xd24c('0x13')]);}logger[_0xd24c('0x11')](_0xd24c('0xc'),_0x95eb94,_0x4c4455[_0xd24c('0x11')][_0xd24c('0x13')]);return _0x411706(_0x4c4455['error'][_0xd24c('0x13')]);}else{logger[_0xd24c('0xb')]('Attachment,\x20%s,\x20%s',_0x95eb94,_0xd24c('0xd'));_0x411706(_0x4c4455[_0xd24c('0x14')][_0xd24c('0x13')]);}})[_0xd24c('0x15')](function(_0x509992){logger['error'](_0xd24c('0xc'),_0x95eb94,_0x509992);_0x3df525(_0x509992);});});}exports[_0xd24c('0x16')]=function(_0x170d59){var _0x524158=this;return new Promise(function(_0x9f2d2d,_0x190fc1){return db[_0xd24c('0x17')][_0xd24c('0x18')](_0x170d59['body'],{'raw':_0x170d59[_0xd24c('0x19')]?_0x170d59['options'][_0xd24c('0x1a')]===undefined?!![]:![]:!![]})[_0xd24c('0x1b')](function(_0x1b3a2f){logger[_0xd24c('0xb')](_0xd24c('0x16'),_0x170d59);logger[_0xd24c('0xe')](_0xd24c('0x16'),_0x170d59,JSON[_0xd24c('0x10')](_0x1b3a2f));_0x9f2d2d(_0x1b3a2f);})[_0xd24c('0x15')](function(_0x206ce7){logger['error'](_0xd24c('0x16'),_0x206ce7[_0xd24c('0x13')],_0x170d59);_0x190fc1(_0x524158[_0xd24c('0x11')](0x1f4,_0x206ce7['message']));});});};