Built motion from commit f25620e4.|2.6.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 _0x3a25=['jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateAttachment','Attachment','options','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x3c29bd,_0x3b2dd){var _0x451ecd=function(_0x2b6033){while(--_0x2b6033){_0x3c29bd['push'](_0x3c29bd['shift']());}};_0x451ecd(++_0x3b2dd);}(_0x3a25,0x15d));var _0x53a2=function(_0x23fc84,_0x2faf64){_0x23fc84=_0x23fc84-0x0;var _0x81fb8=_0x3a25[_0x23fc84];return _0x81fb8;};'use strict';var _=require(_0x53a2('0x0'));var util=require(_0x53a2('0x1'));var moment=require(_0x53a2('0x2'));var BPromise=require(_0x53a2('0x3'));var rs=require(_0x53a2('0x4'));var fs=require('fs');var Redis=require(_0x53a2('0x5'));var db=require(_0x53a2('0x6'))['db'];var utils=require(_0x53a2('0x7'));var logger=require(_0x53a2('0x8'))(_0x53a2('0x9'));var config=require(_0x53a2('0xa'));var jayson=require(_0x53a2('0xb'));var client=jayson[_0x53a2('0xc')][_0x53a2('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x409fff,_0x4d53b8,_0x3ee956){return new BPromise(function(_0x5dc70e,_0x17aa09){return client[_0x53a2('0xe')](_0x409fff,_0x3ee956)[_0x53a2('0xf')](function(_0x42bf42){logger[_0x53a2('0x10')](_0x53a2('0x11'),_0x4d53b8,_0x53a2('0x12'));logger[_0x53a2('0x13')](_0x53a2('0x14'),_0x4d53b8,_0x53a2('0x12'),JSON['stringify'](_0x42bf42));if(_0x42bf42['error']){if(_0x42bf42[_0x53a2('0x15')][_0x53a2('0x16')]===0x1f4){logger['error']('Attachment,\x20%s,\x20%s',_0x4d53b8,_0x42bf42['error'][_0x53a2('0x17')]);return _0x17aa09(_0x42bf42[_0x53a2('0x15')][_0x53a2('0x17')]);}logger['error']('Attachment,\x20%s,\x20%s',_0x4d53b8,_0x42bf42['error'][_0x53a2('0x17')]);return _0x5dc70e(_0x42bf42[_0x53a2('0x15')][_0x53a2('0x17')]);}else{logger[_0x53a2('0x10')]('Attachment,\x20%s,\x20%s',_0x4d53b8,_0x53a2('0x12'));_0x5dc70e(_0x42bf42[_0x53a2('0x18')][_0x53a2('0x17')]);}})[_0x53a2('0x19')](function(_0x34c7de){logger['error']('Attachment,\x20%s,\x20%s',_0x4d53b8,_0x34c7de);_0x17aa09(_0x34c7de);});});}exports[_0x53a2('0x1a')]=function(_0x446b71){var _0x443c6e=this;return new Promise(function(_0x104fb6,_0x1d23f2){return db[_0x53a2('0x1b')]['create'](_0x446b71['body'],{'raw':_0x446b71[_0x53a2('0x1c')]?_0x446b71[_0x53a2('0x1c')]['raw']===undefined?!![]:![]:!![]})[_0x53a2('0xf')](function(_0x3fb15b){logger[_0x53a2('0x10')](_0x53a2('0x1a'),_0x446b71);logger['debug'](_0x53a2('0x1a'),_0x446b71,JSON[_0x53a2('0x1d')](_0x3fb15b));_0x104fb6(_0x3fb15b);})[_0x53a2('0x19')](function(_0x2cda68){logger[_0x53a2('0x15')](_0x53a2('0x1a'),_0x2cda68[_0x53a2('0x17')],_0x446b71);_0x1d23f2(_0x443c6e[_0x53a2('0x15')](0x1f4,_0x2cda68['message']));});});};