2aae846d79c9cd06576bd52223832168e02681cb
[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 _0xd6f7=['body','options','raw','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','Attachment,\x20%s,\x20%s','message','CreateAttachment','create'];(function(_0x42245d,_0x51758f){var _0x4b211a=function(_0x2634e){while(--_0x2634e){_0x42245d['push'](_0x42245d['shift']());}};_0x4b211a(++_0x51758f);}(_0xd6f7,0x1a8));var _0x7d6f=function(_0x489b87,_0xd51c93){_0x489b87=_0x489b87-0x0;var _0x1823b6=_0xd6f7[_0x489b87];return _0x1823b6;};'use strict';var _=require(_0x7d6f('0x0'));var util=require(_0x7d6f('0x1'));var moment=require(_0x7d6f('0x2'));var BPromise=require('bluebird');var rs=require(_0x7d6f('0x3'));var fs=require('fs');var Redis=require(_0x7d6f('0x4'));var db=require(_0x7d6f('0x5'))['db'];var utils=require(_0x7d6f('0x6'));var logger=require('../../config/logger')(_0x7d6f('0x7'));var config=require(_0x7d6f('0x8'));var jayson=require(_0x7d6f('0x9'));var client=jayson[_0x7d6f('0xa')][_0x7d6f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x94315a,_0x41253d,_0x4bb562){return new BPromise(function(_0x1bb5cc,_0x2f59e9){return client[_0x7d6f('0xc')](_0x94315a,_0x4bb562)[_0x7d6f('0xd')](function(_0x13bba0){logger[_0x7d6f('0xe')]('Attachment,\x20%s,\x20%s',_0x41253d,_0x7d6f('0xf'));logger[_0x7d6f('0x10')](_0x7d6f('0x11'),_0x41253d,_0x7d6f('0xf'),JSON[_0x7d6f('0x12')](_0x13bba0));if(_0x13bba0['error']){if(_0x13bba0[_0x7d6f('0x13')]['code']===0x1f4){logger[_0x7d6f('0x13')]('Attachment,\x20%s,\x20%s',_0x41253d,_0x13bba0[_0x7d6f('0x13')]['message']);return _0x2f59e9(_0x13bba0[_0x7d6f('0x13')]['message']);}logger['error'](_0x7d6f('0x14'),_0x41253d,_0x13bba0[_0x7d6f('0x13')][_0x7d6f('0x15')]);return _0x1bb5cc(_0x13bba0[_0x7d6f('0x13')]['message']);}else{logger[_0x7d6f('0xe')]('Attachment,\x20%s,\x20%s',_0x41253d,_0x7d6f('0xf'));_0x1bb5cc(_0x13bba0['result'][_0x7d6f('0x15')]);}})['catch'](function(_0x4aa40a){logger['error']('Attachment,\x20%s,\x20%s',_0x41253d,_0x4aa40a);_0x2f59e9(_0x4aa40a);});});}exports[_0x7d6f('0x16')]=function(_0x4e5e0c){var _0x42339e=this;return new Promise(function(_0x1617f0,_0x2b3b19){return db['Attachment'][_0x7d6f('0x17')](_0x4e5e0c[_0x7d6f('0x18')],{'raw':_0x4e5e0c['options']?_0x4e5e0c[_0x7d6f('0x19')][_0x7d6f('0x1a')]===undefined?!![]:![]:!![]})[_0x7d6f('0xd')](function(_0x80102b){logger[_0x7d6f('0xe')](_0x7d6f('0x16'),_0x4e5e0c);logger['debug'](_0x7d6f('0x16'),_0x4e5e0c,JSON[_0x7d6f('0x12')](_0x80102b));_0x1617f0(_0x80102b);})[_0x7d6f('0x1b')](function(_0x441cd2){logger[_0x7d6f('0x13')](_0x7d6f('0x16'),_0x441cd2[_0x7d6f('0x15')],_0x4e5e0c);_0x2b3b19(_0x42339e[_0x7d6f('0x13')](0x1f4,_0x441cd2[_0x7d6f('0x15')]));});});};