bb11ace7277c89b9093017fbef1698a65368ecfd
[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 _0x9990=['request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateAttachment','Attachment','create','body','options','raw','debug','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','request','then','info','Attachment,\x20%s,\x20%s'];(function(_0x1420f9,_0x15a8c9){var _0x5e5de8=function(_0x3c7b69){while(--_0x3c7b69){_0x1420f9['push'](_0x1420f9['shift']());}};_0x5e5de8(++_0x15a8c9);}(_0x9990,0xf6));var _0x0999=function(_0x1feffd,_0x10faf0){_0x1feffd=_0x1feffd-0x0;var _0x35eb9a=_0x9990[_0x1feffd];return _0x35eb9a;};'use strict';var _=require('lodash');var util=require(_0x0999('0x0'));var moment=require(_0x0999('0x1'));var BPromise=require(_0x0999('0x2'));var rs=require(_0x0999('0x3'));var fs=require('fs');var Redis=require(_0x0999('0x4'));var db=require(_0x0999('0x5'))['db'];var utils=require(_0x0999('0x6'));var logger=require(_0x0999('0x7'))('rpc');var config=require(_0x0999('0x8'));var jayson=require(_0x0999('0x9'));var client=jayson[_0x0999('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1a6f23,_0xb1d8f9,_0x3fe805){return new BPromise(function(_0x304f75,_0x384a4e){return client[_0x0999('0xb')](_0x1a6f23,_0x3fe805)[_0x0999('0xc')](function(_0x52d196){logger[_0x0999('0xd')](_0x0999('0xe'),_0xb1d8f9,_0x0999('0xf'));logger['debug'](_0x0999('0x10'),_0xb1d8f9,_0x0999('0xf'),JSON[_0x0999('0x11')](_0x52d196));if(_0x52d196['error']){if(_0x52d196[_0x0999('0x12')]['code']===0x1f4){logger[_0x0999('0x12')](_0x0999('0xe'),_0xb1d8f9,_0x52d196[_0x0999('0x12')][_0x0999('0x13')]);return _0x384a4e(_0x52d196[_0x0999('0x12')]['message']);}logger[_0x0999('0x12')](_0x0999('0xe'),_0xb1d8f9,_0x52d196[_0x0999('0x12')][_0x0999('0x13')]);return _0x304f75(_0x52d196[_0x0999('0x12')]['message']);}else{logger[_0x0999('0xd')](_0x0999('0xe'),_0xb1d8f9,_0x0999('0xf'));_0x304f75(_0x52d196[_0x0999('0x14')][_0x0999('0x13')]);}})[_0x0999('0x15')](function(_0x2fa43e){logger['error'](_0x0999('0xe'),_0xb1d8f9,_0x2fa43e);_0x384a4e(_0x2fa43e);});});}exports[_0x0999('0x16')]=function(_0x4f6440){var _0x107573=this;return new Promise(function(_0x5b14a3,_0x56373e){return db[_0x0999('0x17')][_0x0999('0x18')](_0x4f6440[_0x0999('0x19')],{'raw':_0x4f6440[_0x0999('0x1a')]?_0x4f6440[_0x0999('0x1a')][_0x0999('0x1b')]===undefined?!![]:![]:!![]})[_0x0999('0xc')](function(_0x113017){logger[_0x0999('0xd')]('CreateAttachment',_0x4f6440);logger[_0x0999('0x1c')](_0x0999('0x16'),_0x4f6440,JSON['stringify'](_0x113017));_0x5b14a3(_0x113017);})['catch'](function(_0x19ddc0){logger[_0x0999('0x12')](_0x0999('0x16'),_0x19ddc0[_0x0999('0x13')],_0x4f6440);_0x56373e(_0x107573[_0x0999('0x12')](0x1f4,_0x19ddc0[_0x0999('0x13')]));});});};