Built motion from commit (unavailable).|2.5.30
[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 _0x4bb8=['rpc','../../config/environment','client','http','request','then','Attachment,\x20%s,\x20%s','debug','Attachment,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','info','CreateAttachment','Attachment','body','options','raw','stringify','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x1f3d9a,_0x524425){var _0x530872=function(_0x3950b1){while(--_0x3950b1){_0x1f3d9a['push'](_0x1f3d9a['shift']());}};_0x530872(++_0x524425);}(_0x4bb8,0x18e));var _0x84bb=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0x4bb8[_0x397e5f];return _0x5302b8;};'use strict';var _=require(_0x84bb('0x0'));var util=require('util');var moment=require(_0x84bb('0x1'));var BPromise=require(_0x84bb('0x2'));var rs=require(_0x84bb('0x3'));var fs=require('fs');var Redis=require(_0x84bb('0x4'));var db=require(_0x84bb('0x5'))['db'];var utils=require(_0x84bb('0x6'));var logger=require(_0x84bb('0x7'))(_0x84bb('0x8'));var config=require(_0x84bb('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x84bb('0xa')][_0x84bb('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2a1f7c,_0x4874a8,_0x3431df){return new BPromise(function(_0x29fc99,_0x242999){return client[_0x84bb('0xc')](_0x2a1f7c,_0x3431df)[_0x84bb('0xd')](function(_0x466c72){logger['info'](_0x84bb('0xe'),_0x4874a8,'request\x20sent');logger[_0x84bb('0xf')](_0x84bb('0x10'),_0x4874a8,_0x84bb('0x11'),JSON['stringify'](_0x466c72));if(_0x466c72[_0x84bb('0x12')]){if(_0x466c72[_0x84bb('0x12')][_0x84bb('0x13')]===0x1f4){logger[_0x84bb('0x12')](_0x84bb('0xe'),_0x4874a8,_0x466c72[_0x84bb('0x12')][_0x84bb('0x14')]);return _0x242999(_0x466c72[_0x84bb('0x12')][_0x84bb('0x14')]);}logger[_0x84bb('0x12')](_0x84bb('0xe'),_0x4874a8,_0x466c72[_0x84bb('0x12')][_0x84bb('0x14')]);return _0x29fc99(_0x466c72['error'][_0x84bb('0x14')]);}else{logger[_0x84bb('0x15')](_0x84bb('0xe'),_0x4874a8,_0x84bb('0x11'));_0x29fc99(_0x466c72['result'][_0x84bb('0x14')]);}})['catch'](function(_0x263ff4){logger[_0x84bb('0x12')](_0x84bb('0xe'),_0x4874a8,_0x263ff4);_0x242999(_0x263ff4);});});}exports[_0x84bb('0x16')]=function(_0x34a5eb){var _0x3b54d7=this;return new Promise(function(_0x8467a5,_0x59c043){return db[_0x84bb('0x17')]['create'](_0x34a5eb[_0x84bb('0x18')],{'raw':_0x34a5eb['options']?_0x34a5eb[_0x84bb('0x19')][_0x84bb('0x1a')]===undefined?!![]:![]:!![]})[_0x84bb('0xd')](function(_0x82ad23){logger['info'](_0x84bb('0x16'),_0x34a5eb);logger['debug'](_0x84bb('0x16'),_0x34a5eb,JSON[_0x84bb('0x1b')](_0x82ad23));_0x8467a5(_0x82ad23);})[_0x84bb('0x1c')](function(_0x9781b2){logger['error'](_0x84bb('0x16'),_0x9781b2['message'],_0x34a5eb);_0x59c043(_0x3b54d7[_0x84bb('0x12')](0x1f4,_0x9781b2[_0x84bb('0x14')]));});});};