2803ad92ba93c27d8f356bfe787b51147b3875c9
[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 _0x5a42=['info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateAttachment','Attachment','create','body','options','lodash','util','moment','bluebird','ioredis','../../mysqldb','rpc','jayson/promise','client'];(function(_0xae7c2f,_0xf31e04){var _0x5d7001=function(_0x4eeadb){while(--_0x4eeadb){_0xae7c2f['push'](_0xae7c2f['shift']());}};_0x5d7001(++_0xf31e04);}(_0x5a42,0x177));var _0x25a4=function(_0x52fcba,_0x91545d){_0x52fcba=_0x52fcba-0x0;var _0x139875=_0x5a42[_0x52fcba];return _0x139875;};'use strict';var _=require(_0x25a4('0x0'));var util=require(_0x25a4('0x1'));var moment=require(_0x25a4('0x2'));var BPromise=require(_0x25a4('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x25a4('0x4'));var db=require(_0x25a4('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x25a4('0x6'));var config=require('../../config/environment');var jayson=require(_0x25a4('0x7'));var client=jayson[_0x25a4('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x21bb89,_0x3c996f,_0x164b1b){return new BPromise(function(_0x75b6cf,_0x54d5cb){return client['request'](_0x21bb89,_0x164b1b)['then'](function(_0x5942cc){logger[_0x25a4('0x9')](_0x25a4('0xa'),_0x3c996f,_0x25a4('0xb'));logger[_0x25a4('0xc')](_0x25a4('0xd'),_0x3c996f,_0x25a4('0xb'),JSON[_0x25a4('0xe')](_0x5942cc));if(_0x5942cc[_0x25a4('0xf')]){if(_0x5942cc[_0x25a4('0xf')]['code']===0x1f4){logger['error'](_0x25a4('0xa'),_0x3c996f,_0x5942cc[_0x25a4('0xf')]['message']);return _0x54d5cb(_0x5942cc[_0x25a4('0xf')][_0x25a4('0x10')]);}logger['error'](_0x25a4('0xa'),_0x3c996f,_0x5942cc[_0x25a4('0xf')][_0x25a4('0x10')]);return _0x75b6cf(_0x5942cc[_0x25a4('0xf')][_0x25a4('0x10')]);}else{logger[_0x25a4('0x9')](_0x25a4('0xa'),_0x3c996f,'request\x20sent');_0x75b6cf(_0x5942cc[_0x25a4('0x11')][_0x25a4('0x10')]);}})[_0x25a4('0x12')](function(_0x1acc00){logger[_0x25a4('0xf')](_0x25a4('0xa'),_0x3c996f,_0x1acc00);_0x54d5cb(_0x1acc00);});});}exports[_0x25a4('0x13')]=function(_0x4faefa){var _0x18efcf=this;return new Promise(function(_0x15c44c,_0x4f6dd8){return db[_0x25a4('0x14')][_0x25a4('0x15')](_0x4faefa[_0x25a4('0x16')],{'raw':_0x4faefa[_0x25a4('0x17')]?_0x4faefa[_0x25a4('0x17')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x34fde7){logger['info']('CreateAttachment',_0x4faefa);logger[_0x25a4('0xc')](_0x25a4('0x13'),_0x4faefa,JSON['stringify'](_0x34fde7));_0x15c44c(_0x34fde7);})[_0x25a4('0x12')](function(_0x221f82){logger[_0x25a4('0xf')](_0x25a4('0x13'),_0x221f82[_0x25a4('0x10')],_0x4faefa);_0x4f6dd8(_0x18efcf[_0x25a4('0xf')](0x1f4,_0x221f82[_0x25a4('0x10')]));});});};