26879a5f777d9664494ac6e18df098bcb290fcdc
[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 _0x0381=['ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','CreateAttachment','create','body','options','raw','lodash','util','bluebird','randomstring'];(function(_0x2327a4,_0x4ac0ce){var _0x44de36=function(_0x5e3183){while(--_0x5e3183){_0x2327a4['push'](_0x2327a4['shift']());}};_0x44de36(++_0x4ac0ce);}(_0x0381,0x1c7));var _0x1038=function(_0x5e45f8,_0x336669){_0x5e45f8=_0x5e45f8-0x0;var _0x418888=_0x0381[_0x5e45f8];return _0x418888;};'use strict';var _=require(_0x1038('0x0'));var util=require(_0x1038('0x1'));var moment=require('moment');var BPromise=require(_0x1038('0x2'));var rs=require(_0x1038('0x3'));var fs=require('fs');var Redis=require(_0x1038('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x1038('0x5'));var logger=require(_0x1038('0x6'))(_0x1038('0x7'));var config=require(_0x1038('0x8'));var jayson=require(_0x1038('0x9'));var client=jayson['client'][_0x1038('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x265f51,_0x44dc20,_0x30744a){return new BPromise(function(_0x3b987d,_0x2c6630){return client['request'](_0x265f51,_0x30744a)[_0x1038('0xb')](function(_0x38b9aa){logger[_0x1038('0xc')](_0x1038('0xd'),_0x44dc20,_0x1038('0xe'));logger[_0x1038('0xf')](_0x1038('0x10'),_0x44dc20,_0x1038('0xe'),JSON[_0x1038('0x11')](_0x38b9aa));if(_0x38b9aa[_0x1038('0x12')]){if(_0x38b9aa['error'][_0x1038('0x13')]===0x1f4){logger[_0x1038('0x12')](_0x1038('0xd'),_0x44dc20,_0x38b9aa[_0x1038('0x12')]['message']);return _0x2c6630(_0x38b9aa[_0x1038('0x12')]['message']);}logger[_0x1038('0x12')](_0x1038('0xd'),_0x44dc20,_0x38b9aa[_0x1038('0x12')][_0x1038('0x14')]);return _0x3b987d(_0x38b9aa[_0x1038('0x12')]['message']);}else{logger[_0x1038('0xc')](_0x1038('0xd'),_0x44dc20,_0x1038('0xe'));_0x3b987d(_0x38b9aa['result'][_0x1038('0x14')]);}})[_0x1038('0x15')](function(_0x538bcb){logger['error'](_0x1038('0xd'),_0x44dc20,_0x538bcb);_0x2c6630(_0x538bcb);});});}exports[_0x1038('0x16')]=function(_0x4a0e28){var _0x557964=this;return new Promise(function(_0x300295,_0x539e67){return db['Attachment'][_0x1038('0x17')](_0x4a0e28[_0x1038('0x18')],{'raw':_0x4a0e28[_0x1038('0x19')]?_0x4a0e28[_0x1038('0x19')][_0x1038('0x1a')]===undefined?!![]:![]:!![]})[_0x1038('0xb')](function(_0x5dbd2f){logger['info'](_0x1038('0x16'),_0x4a0e28);logger[_0x1038('0xf')](_0x1038('0x16'),_0x4a0e28,JSON[_0x1038('0x11')](_0x5dbd2f));_0x300295(_0x5dbd2f);})[_0x1038('0x15')](function(_0x43b148){logger['error'](_0x1038('0x16'),_0x43b148['message'],_0x4a0e28);_0x539e67(_0x557964[_0x1038('0x12')](0x1f4,_0x43b148['message']));});});};