Built motion from commit (unavailable).|2.4.20
[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 _0x9c75=['Attachment,\x20%s,\x20%s','request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','error','code','message','Attachment','options','raw','debug','CreateAttachment','stringify','catch','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','http','request','then','info'];(function(_0x521de1,_0x23e812){var _0x49f370=function(_0x183d4e){while(--_0x183d4e){_0x521de1['push'](_0x521de1['shift']());}};_0x49f370(++_0x23e812);}(_0x9c75,0x19d));var _0x59c7=function(_0x4f67f1,_0x3d02bf){_0x4f67f1=_0x4f67f1-0x0;var _0x52c611=_0x9c75[_0x4f67f1];return _0x52c611;};'use strict';var _=require(_0x59c7('0x0'));var util=require(_0x59c7('0x1'));var moment=require(_0x59c7('0x2'));var BPromise=require(_0x59c7('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x59c7('0x4'))['db'];var utils=require(_0x59c7('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x59c7('0x6'));var jayson=require(_0x59c7('0x7'));var client=jayson['client'][_0x59c7('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2b4138,_0x9f0e21,_0x18a0ac){return new BPromise(function(_0x3008fa,_0x32b961){return client[_0x59c7('0x9')](_0x2b4138,_0x18a0ac)[_0x59c7('0xa')](function(_0x25c5f0){logger[_0x59c7('0xb')](_0x59c7('0xc'),_0x9f0e21,_0x59c7('0xd'));logger['debug'](_0x59c7('0xe'),_0x9f0e21,'request\x20sent',JSON['stringify'](_0x25c5f0));if(_0x25c5f0[_0x59c7('0xf')]){if(_0x25c5f0[_0x59c7('0xf')][_0x59c7('0x10')]===0x1f4){logger[_0x59c7('0xf')](_0x59c7('0xc'),_0x9f0e21,_0x25c5f0[_0x59c7('0xf')][_0x59c7('0x11')]);return _0x32b961(_0x25c5f0['error'][_0x59c7('0x11')]);}logger[_0x59c7('0xf')](_0x59c7('0xc'),_0x9f0e21,_0x25c5f0['error']['message']);return _0x3008fa(_0x25c5f0['error'][_0x59c7('0x11')]);}else{logger[_0x59c7('0xb')](_0x59c7('0xc'),_0x9f0e21,_0x59c7('0xd'));_0x3008fa(_0x25c5f0['result'][_0x59c7('0x11')]);}})['catch'](function(_0x15bf1b){logger[_0x59c7('0xf')](_0x59c7('0xc'),_0x9f0e21,_0x15bf1b);_0x32b961(_0x15bf1b);});});}exports['CreateAttachment']=function(_0x271c89){var _0x2e62c7=this;return new Promise(function(_0x156d42,_0x3ce296){return db[_0x59c7('0x12')]['create'](_0x271c89['body'],{'raw':_0x271c89[_0x59c7('0x13')]?_0x271c89[_0x59c7('0x13')][_0x59c7('0x14')]===undefined?!![]:![]:!![]})[_0x59c7('0xa')](function(_0x3289c1){logger[_0x59c7('0xb')]('CreateAttachment',_0x271c89);logger[_0x59c7('0x15')](_0x59c7('0x16'),_0x271c89,JSON[_0x59c7('0x17')](_0x3289c1));_0x156d42(_0x3289c1);})[_0x59c7('0x18')](function(_0x48ee4e){logger[_0x59c7('0xf')]('CreateAttachment',_0x48ee4e['message'],_0x271c89);_0x3ce296(_0x2e62c7[_0x59c7('0xf')](0x1f4,_0x48ee4e['message']));});});};