79074245b05255b50e720401c982ce229d475eb9
[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 _0xe43c=['Attachment','create','body','options','raw','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','info','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','Attachment,\x20%s,\x20%s','message','request\x20sent','result','catch','CreateAttachment'];(function(_0x371b64,_0x67b4bb){var _0x3cf3b1=function(_0x362941){while(--_0x362941){_0x371b64['push'](_0x371b64['shift']());}};_0x3cf3b1(++_0x67b4bb);}(_0xe43c,0x180));var _0xce43=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0xe43c[_0x42cae2];return _0x5f256f;};'use strict';var _=require(_0xce43('0x0'));var util=require(_0xce43('0x1'));var moment=require(_0xce43('0x2'));var BPromise=require(_0xce43('0x3'));var rs=require(_0xce43('0x4'));var fs=require('fs');var Redis=require(_0xce43('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xce43('0x6'));var logger=require('../../config/logger')(_0xce43('0x7'));var config=require(_0xce43('0x8'));var jayson=require(_0xce43('0x9'));var client=jayson[_0xce43('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x20bd99,_0x5ddbba,_0x1cbd0b){return new BPromise(function(_0x5c4af2,_0x3affb9){return client['request'](_0x20bd99,_0x1cbd0b)['then'](function(_0x9efc57){logger[_0xce43('0xb')]('Attachment,\x20%s,\x20%s',_0x5ddbba,'request\x20sent');logger['debug'](_0xce43('0xc'),_0x5ddbba,'request\x20sent',JSON[_0xce43('0xd')](_0x9efc57));if(_0x9efc57['error']){if(_0x9efc57[_0xce43('0xe')]['code']===0x1f4){logger[_0xce43('0xe')](_0xce43('0xf'),_0x5ddbba,_0x9efc57[_0xce43('0xe')][_0xce43('0x10')]);return _0x3affb9(_0x9efc57[_0xce43('0xe')][_0xce43('0x10')]);}logger[_0xce43('0xe')]('Attachment,\x20%s,\x20%s',_0x5ddbba,_0x9efc57[_0xce43('0xe')][_0xce43('0x10')]);return _0x5c4af2(_0x9efc57[_0xce43('0xe')][_0xce43('0x10')]);}else{logger['info']('Attachment,\x20%s,\x20%s',_0x5ddbba,_0xce43('0x11'));_0x5c4af2(_0x9efc57[_0xce43('0x12')][_0xce43('0x10')]);}})[_0xce43('0x13')](function(_0xd5282){logger[_0xce43('0xe')]('Attachment,\x20%s,\x20%s',_0x5ddbba,_0xd5282);_0x3affb9(_0xd5282);});});}exports[_0xce43('0x14')]=function(_0xbe5b91){var _0xbc38f0=this;return new Promise(function(_0x4444d7,_0x4c6a1b){return db[_0xce43('0x15')][_0xce43('0x16')](_0xbe5b91[_0xce43('0x17')],{'raw':_0xbe5b91[_0xce43('0x18')]?_0xbe5b91[_0xce43('0x18')][_0xce43('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x5bd459){logger[_0xce43('0xb')]('CreateAttachment',_0xbe5b91);logger[_0xce43('0x1a')](_0xce43('0x14'),_0xbe5b91,JSON[_0xce43('0xd')](_0x5bd459));_0x4444d7(_0x5bd459);})['catch'](function(_0x57dcd4){logger[_0xce43('0xe')](_0xce43('0x14'),_0x57dcd4[_0xce43('0x10')],_0xbe5b91);_0x4c6a1b(_0xbc38f0[_0xce43('0xe')](0x1f4,_0x57dcd4[_0xce43('0x10')]));});});};