Built motion from commit (unavailable).|2.0.75
[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 _0x390a=['create','options','raw','debug','CreateAttachment','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','Attachment,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch'];(function(_0x35fcb7,_0x3734c0){var _0x30f28a=function(_0x1da8bd){while(--_0x1da8bd){_0x35fcb7['push'](_0x35fcb7['shift']());}};_0x30f28a(++_0x3734c0);}(_0x390a,0xc9));var _0xa390=function(_0x15ebe1,_0x43733d){_0x15ebe1=_0x15ebe1-0x0;var _0x4a1897=_0x390a[_0x15ebe1];return _0x4a1897;};'use strict';var _=require(_0xa390('0x0'));var util=require(_0xa390('0x1'));var moment=require(_0xa390('0x2'));var BPromise=require(_0xa390('0x3'));var rs=require('randomstring');var fs=require('fs');var db=require(_0xa390('0x4'))['db'];var utils=require(_0xa390('0x5'));var logger=require(_0xa390('0x6'))(_0xa390('0x7'));var config=require('../../config/environment');var jayson=require(_0xa390('0x8'));var client=jayson[_0xa390('0x9')][_0xa390('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4ac9f5,_0x2d49cc,_0x1f9de0){return new BPromise(function(_0x53bfb4,_0x492418){return client[_0xa390('0xb')](_0x4ac9f5,_0x1f9de0)[_0xa390('0xc')](function(_0x321bae){logger[_0xa390('0xd')](_0xa390('0xe'),_0x2d49cc,'request\x20sent');logger['debug'](_0xa390('0xf'),_0x2d49cc,_0xa390('0x10'),JSON[_0xa390('0x11')](_0x321bae));if(_0x321bae['error']){if(_0x321bae[_0xa390('0x12')][_0xa390('0x13')]===0x1f4){logger['error'](_0xa390('0xe'),_0x2d49cc,_0x321bae[_0xa390('0x12')]['message']);return _0x492418(_0x321bae['error'][_0xa390('0x14')]);}logger[_0xa390('0x12')]('Attachment,\x20%s,\x20%s',_0x2d49cc,_0x321bae[_0xa390('0x12')]['message']);return _0x53bfb4(_0x321bae['error']['message']);}else{logger[_0xa390('0xd')]('Attachment,\x20%s,\x20%s',_0x2d49cc,_0xa390('0x10'));_0x53bfb4(_0x321bae[_0xa390('0x15')]['message']);}})[_0xa390('0x16')](function(_0x180429){logger['error'](_0xa390('0xe'),_0x2d49cc,_0x180429);_0x492418(_0x180429);});});}exports['CreateAttachment']=function(_0x228c83){var _0x225e2c=this;return new Promise(function(_0x23bb5d,_0x3905b3){return db['Attachment'][_0xa390('0x17')](_0x228c83['body'],{'raw':_0x228c83['options']?_0x228c83[_0xa390('0x18')][_0xa390('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x3815bd){logger[_0xa390('0xd')]('CreateAttachment',_0x228c83);logger[_0xa390('0x1a')](_0xa390('0x1b'),_0x228c83,JSON['stringify'](_0x3815bd));_0x23bb5d(_0x3815bd);})['catch'](function(_0x18a0f0){logger[_0xa390('0x12')](_0xa390('0x1b'),_0x18a0f0['message'],_0x228c83);_0x3905b3(_0x225e2c['error'](0x1f4,_0x18a0f0[_0xa390('0x14')]));});});};