a74ba97c27670da5ce78b49a723f2affe97b8833
[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 _0xe40e=['stringify','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','error','code','message','CreateAttachment','Attachment','create','body','options','raw','debug'];(function(_0x1a4dd7,_0x5487e5){var _0x48c2af=function(_0x30fb77){while(--_0x30fb77){_0x1a4dd7['push'](_0x1a4dd7['shift']());}};_0x48c2af(++_0x5487e5);}(_0xe40e,0x139));var _0xee40=function(_0x4850de,_0x43657e){_0x4850de=_0x4850de-0x0;var _0x71dbbb=_0xe40e[_0x4850de];return _0x71dbbb;};'use strict';var _=require(_0xee40('0x0'));var util=require(_0xee40('0x1'));var moment=require('moment');var BPromise=require(_0xee40('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xee40('0x3'));var db=require(_0xee40('0x4'))['db'];var utils=require(_0xee40('0x5'));var logger=require(_0xee40('0x6'))(_0xee40('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xee40('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2646a9,_0x473a56,_0x5077dc){return new BPromise(function(_0x45dc2d,_0x4318aa){return client[_0xee40('0x9')](_0x2646a9,_0x5077dc)[_0xee40('0xa')](function(_0x32d0b9){logger[_0xee40('0xb')](_0xee40('0xc'),_0x473a56,_0xee40('0xd'));logger['debug'](_0xee40('0xe'),_0x473a56,_0xee40('0xd'),JSON['stringify'](_0x32d0b9));if(_0x32d0b9[_0xee40('0xf')]){if(_0x32d0b9[_0xee40('0xf')][_0xee40('0x10')]===0x1f4){logger[_0xee40('0xf')](_0xee40('0xc'),_0x473a56,_0x32d0b9['error'][_0xee40('0x11')]);return _0x4318aa(_0x32d0b9[_0xee40('0xf')]['message']);}logger['error'](_0xee40('0xc'),_0x473a56,_0x32d0b9[_0xee40('0xf')]['message']);return _0x45dc2d(_0x32d0b9[_0xee40('0xf')]['message']);}else{logger[_0xee40('0xb')](_0xee40('0xc'),_0x473a56,_0xee40('0xd'));_0x45dc2d(_0x32d0b9['result']['message']);}})['catch'](function(_0x3916bf){logger[_0xee40('0xf')]('Attachment,\x20%s,\x20%s',_0x473a56,_0x3916bf);_0x4318aa(_0x3916bf);});});}exports[_0xee40('0x12')]=function(_0x41cc5b){var _0x2c0033=this;return new Promise(function(_0x3d1c92,_0x2383f8){return db[_0xee40('0x13')][_0xee40('0x14')](_0x41cc5b[_0xee40('0x15')],{'raw':_0x41cc5b[_0xee40('0x16')]?_0x41cc5b[_0xee40('0x16')][_0xee40('0x17')]===undefined?!![]:![]:!![]})['then'](function(_0x4339d0){logger['info'](_0xee40('0x12'),_0x41cc5b);logger[_0xee40('0x18')]('CreateAttachment',_0x41cc5b,JSON[_0xee40('0x19')](_0x4339d0));_0x3d1c92(_0x4339d0);})['catch'](function(_0x34e118){logger['error'](_0xee40('0x12'),_0x34e118[_0xee40('0x11')],_0x41cc5b);_0x2383f8(_0x2c0033[_0xee40('0xf')](0x1f4,_0x34e118[_0xee40('0x11')]));});});};