Built motion from commit (unavailable).|2.5.14
[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 _0x3a20=['client','http','request','then','info','request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','Attachment,\x20%s,\x20%s','message','catch','CreateAttachment','create','body','options','util','moment','bluebird','randomstring','../../config/utils','rpc','../../config/environment','jayson/promise'];(function(_0x520b04,_0x157710){var _0x2732a0=function(_0x3b68e6){while(--_0x3b68e6){_0x520b04['push'](_0x520b04['shift']());}};_0x2732a0(++_0x157710);}(_0x3a20,0x124));var _0x03a2=function(_0x20d6e9,_0x182436){_0x20d6e9=_0x20d6e9-0x0;var _0x4b5f9d=_0x3a20[_0x20d6e9];return _0x4b5f9d;};'use strict';var _=require('lodash');var util=require(_0x03a2('0x0'));var moment=require(_0x03a2('0x1'));var BPromise=require(_0x03a2('0x2'));var rs=require(_0x03a2('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x03a2('0x4'));var logger=require('../../config/logger')(_0x03a2('0x5'));var config=require(_0x03a2('0x6'));var jayson=require(_0x03a2('0x7'));var client=jayson[_0x03a2('0x8')][_0x03a2('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4b7546,_0xe70511,_0x4a8e14){return new BPromise(function(_0x400f20,_0x45e2b8){return client[_0x03a2('0xa')](_0x4b7546,_0x4a8e14)[_0x03a2('0xb')](function(_0x4a358c){logger[_0x03a2('0xc')]('Attachment,\x20%s,\x20%s',_0xe70511,_0x03a2('0xd'));logger['debug'](_0x03a2('0xe'),_0xe70511,_0x03a2('0xd'),JSON[_0x03a2('0xf')](_0x4a358c));if(_0x4a358c[_0x03a2('0x10')]){if(_0x4a358c['error'][_0x03a2('0x11')]===0x1f4){logger[_0x03a2('0x10')](_0x03a2('0x12'),_0xe70511,_0x4a358c['error'][_0x03a2('0x13')]);return _0x45e2b8(_0x4a358c['error']['message']);}logger['error'](_0x03a2('0x12'),_0xe70511,_0x4a358c['error'][_0x03a2('0x13')]);return _0x400f20(_0x4a358c['error'][_0x03a2('0x13')]);}else{logger['info']('Attachment,\x20%s,\x20%s',_0xe70511,_0x03a2('0xd'));_0x400f20(_0x4a358c['result'][_0x03a2('0x13')]);}})[_0x03a2('0x14')](function(_0x4336d2){logger['error'](_0x03a2('0x12'),_0xe70511,_0x4336d2);_0x45e2b8(_0x4336d2);});});}exports[_0x03a2('0x15')]=function(_0x1f24fb){var _0x58771e=this;return new Promise(function(_0x6106f0,_0x3cf1d3){return db['Attachment'][_0x03a2('0x16')](_0x1f24fb[_0x03a2('0x17')],{'raw':_0x1f24fb[_0x03a2('0x18')]?_0x1f24fb[_0x03a2('0x18')]['raw']===undefined?!![]:![]:!![]})[_0x03a2('0xb')](function(_0x261028){logger[_0x03a2('0xc')]('CreateAttachment',_0x1f24fb);logger['debug'](_0x03a2('0x15'),_0x1f24fb,JSON[_0x03a2('0xf')](_0x261028));_0x6106f0(_0x261028);})['catch'](function(_0x1cabe8){logger[_0x03a2('0x10')](_0x03a2('0x15'),_0x1cabe8[_0x03a2('0x13')],_0x1f24fb);_0x3cf1d3(_0x58771e[_0x03a2('0x10')](0x1f4,_0x1cabe8['message']));});});};