Built motion from commit (unavailable).|2.5.23
[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 _0xbc51=['http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','Attachment','create','body','options','raw','CreateAttachment','stringify','lodash','util','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client'];(function(_0x1599b5,_0x28b24b){var _0x22b161=function(_0x3d936e){while(--_0x3d936e){_0x1599b5['push'](_0x1599b5['shift']());}};_0x22b161(++_0x28b24b);}(_0xbc51,0x164));var _0x1bc5=function(_0x215e65,_0x183f97){_0x215e65=_0x215e65-0x0;var _0xa85842=_0xbc51[_0x215e65];return _0xa85842;};'use strict';var _=require(_0x1bc5('0x0'));var util=require(_0x1bc5('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x1bc5('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1bc5('0x3'))['db'];var utils=require(_0x1bc5('0x4'));var logger=require(_0x1bc5('0x5'))('rpc');var config=require(_0x1bc5('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x1bc5('0x7')][_0x1bc5('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x3fec37,_0x524878,_0x33ffe7){return new BPromise(function(_0x454312,_0xb98fcf){return client[_0x1bc5('0x9')](_0x3fec37,_0x33ffe7)[_0x1bc5('0xa')](function(_0x5b8714){logger[_0x1bc5('0xb')](_0x1bc5('0xc'),_0x524878,_0x1bc5('0xd'));logger[_0x1bc5('0xe')](_0x1bc5('0xf'),_0x524878,_0x1bc5('0xd'),JSON['stringify'](_0x5b8714));if(_0x5b8714[_0x1bc5('0x10')]){if(_0x5b8714[_0x1bc5('0x10')][_0x1bc5('0x11')]===0x1f4){logger[_0x1bc5('0x10')](_0x1bc5('0xc'),_0x524878,_0x5b8714[_0x1bc5('0x10')][_0x1bc5('0x12')]);return _0xb98fcf(_0x5b8714['error'][_0x1bc5('0x12')]);}logger[_0x1bc5('0x10')]('Attachment,\x20%s,\x20%s',_0x524878,_0x5b8714[_0x1bc5('0x10')][_0x1bc5('0x12')]);return _0x454312(_0x5b8714[_0x1bc5('0x10')][_0x1bc5('0x12')]);}else{logger['info'](_0x1bc5('0xc'),_0x524878,_0x1bc5('0xd'));_0x454312(_0x5b8714[_0x1bc5('0x13')][_0x1bc5('0x12')]);}})[_0x1bc5('0x14')](function(_0x48bb27){logger[_0x1bc5('0x10')](_0x1bc5('0xc'),_0x524878,_0x48bb27);_0xb98fcf(_0x48bb27);});});}exports['CreateAttachment']=function(_0x5c4bb0){var _0x51556f=this;return new Promise(function(_0x148545,_0x431322){return db[_0x1bc5('0x15')][_0x1bc5('0x16')](_0x5c4bb0[_0x1bc5('0x17')],{'raw':_0x5c4bb0[_0x1bc5('0x18')]?_0x5c4bb0[_0x1bc5('0x18')][_0x1bc5('0x19')]===undefined?!![]:![]:!![]})[_0x1bc5('0xa')](function(_0x46a245){logger[_0x1bc5('0xb')]('CreateAttachment',_0x5c4bb0);logger[_0x1bc5('0xe')](_0x1bc5('0x1a'),_0x5c4bb0,JSON[_0x1bc5('0x1b')](_0x46a245));_0x148545(_0x46a245);})['catch'](function(_0x21ba03){logger[_0x1bc5('0x10')](_0x1bc5('0x1a'),_0x21ba03[_0x1bc5('0x12')],_0x5c4bb0);_0x431322(_0x51556f[_0x1bc5('0x10')](0x1f4,_0x21ba03[_0x1bc5('0x12')]));});});};