Built motion from commit f0a64034.|2.6.11
[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 _0x68fc=['options','raw','catch','lodash','util','moment','ioredis','../../config/utils','../../config/environment','jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','CreateAttachment','Attachment','create','body'];(function(_0xdc7196,_0x4e811c){var _0x3c9120=function(_0x34d7f6){while(--_0x34d7f6){_0xdc7196['push'](_0xdc7196['shift']());}};_0x3c9120(++_0x4e811c);}(_0x68fc,0xa5));var _0xc68f=function(_0x4113f6,_0x239402){_0x4113f6=_0x4113f6-0x0;var _0x502c3f=_0x68fc[_0x4113f6];return _0x502c3f;};'use strict';var _=require(_0xc68f('0x0'));var util=require(_0xc68f('0x1'));var moment=require(_0xc68f('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xc68f('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xc68f('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0xc68f('0x5'));var jayson=require(_0xc68f('0x6'));var client=jayson[_0xc68f('0x7')][_0xc68f('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x4fcce4,_0x4a6f7d,_0x9f2705){return new BPromise(function(_0x2bf3fd,_0x370977){return client[_0xc68f('0x9')](_0x4fcce4,_0x9f2705)[_0xc68f('0xa')](function(_0x1ee022){logger[_0xc68f('0xb')](_0xc68f('0xc'),_0x4a6f7d,_0xc68f('0xd'));logger[_0xc68f('0xe')]('Attachment,\x20%s,\x20%s,\x20%s',_0x4a6f7d,_0xc68f('0xd'),JSON[_0xc68f('0xf')](_0x1ee022));if(_0x1ee022[_0xc68f('0x10')]){if(_0x1ee022[_0xc68f('0x10')][_0xc68f('0x11')]===0x1f4){logger[_0xc68f('0x10')](_0xc68f('0xc'),_0x4a6f7d,_0x1ee022[_0xc68f('0x10')][_0xc68f('0x12')]);return _0x370977(_0x1ee022[_0xc68f('0x10')][_0xc68f('0x12')]);}logger['error'](_0xc68f('0xc'),_0x4a6f7d,_0x1ee022[_0xc68f('0x10')][_0xc68f('0x12')]);return _0x2bf3fd(_0x1ee022[_0xc68f('0x10')][_0xc68f('0x12')]);}else{logger[_0xc68f('0xb')](_0xc68f('0xc'),_0x4a6f7d,_0xc68f('0xd'));_0x2bf3fd(_0x1ee022[_0xc68f('0x13')]['message']);}})['catch'](function(_0x3a6c06){logger[_0xc68f('0x10')](_0xc68f('0xc'),_0x4a6f7d,_0x3a6c06);_0x370977(_0x3a6c06);});});}exports[_0xc68f('0x14')]=function(_0x2d9d85){var _0x2c7261=this;return new Promise(function(_0x50fab4,_0x385dbe){return db[_0xc68f('0x15')][_0xc68f('0x16')](_0x2d9d85[_0xc68f('0x17')],{'raw':_0x2d9d85[_0xc68f('0x18')]?_0x2d9d85[_0xc68f('0x18')][_0xc68f('0x19')]===undefined?!![]:![]:!![]})[_0xc68f('0xa')](function(_0x582301){logger[_0xc68f('0xb')](_0xc68f('0x14'),_0x2d9d85);logger[_0xc68f('0xe')]('CreateAttachment',_0x2d9d85,JSON[_0xc68f('0xf')](_0x582301));_0x50fab4(_0x582301);})[_0xc68f('0x1a')](function(_0x116203){logger[_0xc68f('0x10')](_0xc68f('0x14'),_0x116203[_0xc68f('0x12')],_0x2d9d85);_0x385dbe(_0x2c7261[_0xc68f('0x10')](0x1f4,_0x116203['message']));});});};