Built motion from commit 9d0783e6.|2.6.13
[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 _0xe13a=['request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','message','CreateAttachment','Attachment','body','options','raw','debug','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s'];(function(_0x119260,_0x565904){var _0x341137=function(_0x488905){while(--_0x488905){_0x119260['push'](_0x119260['shift']());}};_0x341137(++_0x565904);}(_0xe13a,0x178));var _0xae13=function(_0x59c7f3,_0x4f5e95){_0x59c7f3=_0x59c7f3-0x0;var _0x2c6aa0=_0xe13a[_0x59c7f3];return _0x2c6aa0;};'use strict';var _=require('lodash');var util=require(_0xae13('0x0'));var moment=require(_0xae13('0x1'));var BPromise=require(_0xae13('0x2'));var rs=require(_0xae13('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xae13('0x4'))['db'];var utils=require(_0xae13('0x5'));var logger=require(_0xae13('0x6'))(_0xae13('0x7'));var config=require(_0xae13('0x8'));var jayson=require(_0xae13('0x9'));var client=jayson[_0xae13('0xa')][_0xae13('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x341ba4,_0x4ae51f,_0x2f6d10){return new BPromise(function(_0x2b2e1f,_0x27fefd){return client[_0xae13('0xc')](_0x341ba4,_0x2f6d10)[_0xae13('0xd')](function(_0x41bf44){logger[_0xae13('0xe')](_0xae13('0xf'),_0x4ae51f,_0xae13('0x10'));logger['debug'](_0xae13('0x11'),_0x4ae51f,_0xae13('0x10'),JSON[_0xae13('0x12')](_0x41bf44));if(_0x41bf44[_0xae13('0x13')]){if(_0x41bf44[_0xae13('0x13')][_0xae13('0x14')]===0x1f4){logger[_0xae13('0x13')]('Attachment,\x20%s,\x20%s',_0x4ae51f,_0x41bf44[_0xae13('0x13')][_0xae13('0x15')]);return _0x27fefd(_0x41bf44['error']['message']);}logger['error']('Attachment,\x20%s,\x20%s',_0x4ae51f,_0x41bf44['error'][_0xae13('0x15')]);return _0x2b2e1f(_0x41bf44[_0xae13('0x13')][_0xae13('0x15')]);}else{logger[_0xae13('0xe')](_0xae13('0xf'),_0x4ae51f,_0xae13('0x10'));_0x2b2e1f(_0x41bf44['result'][_0xae13('0x15')]);}})['catch'](function(_0xe10aab){logger[_0xae13('0x13')](_0xae13('0xf'),_0x4ae51f,_0xe10aab);_0x27fefd(_0xe10aab);});});}exports[_0xae13('0x16')]=function(_0x1a9c07){var _0x1b33b7=this;return new Promise(function(_0x32dcbe,_0x326471){return db[_0xae13('0x17')]['create'](_0x1a9c07[_0xae13('0x18')],{'raw':_0x1a9c07['options']?_0x1a9c07[_0xae13('0x19')][_0xae13('0x1a')]===undefined?!![]:![]:!![]})['then'](function(_0x25a195){logger[_0xae13('0xe')](_0xae13('0x16'),_0x1a9c07);logger[_0xae13('0x1b')](_0xae13('0x16'),_0x1a9c07,JSON[_0xae13('0x12')](_0x25a195));_0x32dcbe(_0x25a195);})['catch'](function(_0x520692){logger[_0xae13('0x13')](_0xae13('0x16'),_0x520692['message'],_0x1a9c07);_0x326471(_0x1b33b7[_0xae13('0x13')](0x1f4,_0x520692['message']));});});};