20f852b8df9e01d2988055324c77a922c1532c20
[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 _0x4522=['code','Attachment,\x20%s,\x20%s','message','result','catch','CreateAttachment','Attachment','body','options','raw','info','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','request\x20sent','stringify','error'];(function(_0x548654,_0x9f385){var _0x24ec47=function(_0x3c224f){while(--_0x3c224f){_0x548654['push'](_0x548654['shift']());}};_0x24ec47(++_0x9f385);}(_0x4522,0x1a0));var _0x2452=function(_0x4906f6,_0x3a9b5d){_0x4906f6=_0x4906f6-0x0;var _0x4542e9=_0x4522[_0x4906f6];return _0x4542e9;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x2452('0x0'));var BPromise=require(_0x2452('0x1'));var rs=require(_0x2452('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2452('0x3'))['db'];var utils=require(_0x2452('0x4'));var logger=require(_0x2452('0x5'))(_0x2452('0x6'));var config=require(_0x2452('0x7'));var jayson=require(_0x2452('0x8'));var client=jayson[_0x2452('0x9')][_0x2452('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2f0139,_0x149807,_0x3bc193){return new BPromise(function(_0x33b935,_0x24073f){return client[_0x2452('0xb')](_0x2f0139,_0x3bc193)[_0x2452('0xc')](function(_0x2995b5){logger['info']('Attachment,\x20%s,\x20%s',_0x149807,_0x2452('0xd'));logger['debug']('Attachment,\x20%s,\x20%s,\x20%s',_0x149807,_0x2452('0xd'),JSON[_0x2452('0xe')](_0x2995b5));if(_0x2995b5[_0x2452('0xf')]){if(_0x2995b5[_0x2452('0xf')][_0x2452('0x10')]===0x1f4){logger[_0x2452('0xf')](_0x2452('0x11'),_0x149807,_0x2995b5[_0x2452('0xf')]['message']);return _0x24073f(_0x2995b5['error']['message']);}logger[_0x2452('0xf')]('Attachment,\x20%s,\x20%s',_0x149807,_0x2995b5[_0x2452('0xf')]['message']);return _0x33b935(_0x2995b5[_0x2452('0xf')][_0x2452('0x12')]);}else{logger['info'](_0x2452('0x11'),_0x149807,'request\x20sent');_0x33b935(_0x2995b5[_0x2452('0x13')][_0x2452('0x12')]);}})[_0x2452('0x14')](function(_0xdede20){logger['error'](_0x2452('0x11'),_0x149807,_0xdede20);_0x24073f(_0xdede20);});});}exports[_0x2452('0x15')]=function(_0x59d89a){var _0x4802ad=this;return new Promise(function(_0x1bfb44,_0x37c6a6){return db[_0x2452('0x16')]['create'](_0x59d89a[_0x2452('0x17')],{'raw':_0x59d89a[_0x2452('0x18')]?_0x59d89a[_0x2452('0x18')][_0x2452('0x19')]===undefined?!![]:![]:!![]})[_0x2452('0xc')](function(_0x1c70cb){logger[_0x2452('0x1a')](_0x2452('0x15'),_0x59d89a);logger['debug']('CreateAttachment',_0x59d89a,JSON[_0x2452('0xe')](_0x1c70cb));_0x1bfb44(_0x1c70cb);})[_0x2452('0x14')](function(_0x4bb3ff){logger[_0x2452('0xf')](_0x2452('0x15'),_0x4bb3ff[_0x2452('0x12')],_0x59d89a);_0x37c6a6(_0x4802ad[_0x2452('0xf')](0x1f4,_0x4bb3ff[_0x2452('0x12')]));});});};