e041e44dfe5c48c9e0f3f0e407df5913a655cd4a
[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 _0xa1e2=['info','result','catch','create','body','options','CreateAttachment','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','error','code','Attachment,\x20%s,\x20%s','message'];(function(_0x1834be,_0x22a86a){var _0x6b78de=function(_0x266984){while(--_0x266984){_0x1834be['push'](_0x1834be['shift']());}};_0x6b78de(++_0x22a86a);}(_0xa1e2,0x116));var _0x2a1e=function(_0x1baec2,_0x18bdb4){_0x1baec2=_0x1baec2-0x0;var _0x5c2861=_0xa1e2[_0x1baec2];return _0x5c2861;};'use strict';var _=require(_0x2a1e('0x0'));var util=require(_0x2a1e('0x1'));var moment=require(_0x2a1e('0x2'));var BPromise=require(_0x2a1e('0x3'));var rs=require(_0x2a1e('0x4'));var fs=require('fs');var Redis=require(_0x2a1e('0x5'));var db=require(_0x2a1e('0x6'))['db'];var utils=require(_0x2a1e('0x7'));var logger=require(_0x2a1e('0x8'))(_0x2a1e('0x9'));var config=require(_0x2a1e('0xa'));var jayson=require(_0x2a1e('0xb'));var client=jayson[_0x2a1e('0xc')]['http']({'port':0x232a});function respondWithRpcPromise(_0x53a9c6,_0x100d81,_0x5d0682){return new BPromise(function(_0x46ea04,_0x235190){return client[_0x2a1e('0xd')](_0x53a9c6,_0x5d0682)[_0x2a1e('0xe')](function(_0x17282d){logger['info']('Attachment,\x20%s,\x20%s',_0x100d81,_0x2a1e('0xf'));logger[_0x2a1e('0x10')](_0x2a1e('0x11'),_0x100d81,_0x2a1e('0xf'),JSON['stringify'](_0x17282d));if(_0x17282d[_0x2a1e('0x12')]){if(_0x17282d[_0x2a1e('0x12')][_0x2a1e('0x13')]===0x1f4){logger[_0x2a1e('0x12')](_0x2a1e('0x14'),_0x100d81,_0x17282d[_0x2a1e('0x12')][_0x2a1e('0x15')]);return _0x235190(_0x17282d[_0x2a1e('0x12')][_0x2a1e('0x15')]);}logger[_0x2a1e('0x12')]('Attachment,\x20%s,\x20%s',_0x100d81,_0x17282d[_0x2a1e('0x12')][_0x2a1e('0x15')]);return _0x46ea04(_0x17282d['error'][_0x2a1e('0x15')]);}else{logger[_0x2a1e('0x16')]('Attachment,\x20%s,\x20%s',_0x100d81,_0x2a1e('0xf'));_0x46ea04(_0x17282d[_0x2a1e('0x17')][_0x2a1e('0x15')]);}})[_0x2a1e('0x18')](function(_0x30fdda){logger[_0x2a1e('0x12')](_0x2a1e('0x14'),_0x100d81,_0x30fdda);_0x235190(_0x30fdda);});});}exports['CreateAttachment']=function(_0x49a5cc){var _0x48917b=this;return new Promise(function(_0x8f189b,_0x1f0e0e){return db['Attachment'][_0x2a1e('0x19')](_0x49a5cc[_0x2a1e('0x1a')],{'raw':_0x49a5cc['options']?_0x49a5cc[_0x2a1e('0x1b')]['raw']===undefined?!![]:![]:!![]})[_0x2a1e('0xe')](function(_0x3bdfa0){logger[_0x2a1e('0x16')](_0x2a1e('0x1c'),_0x49a5cc);logger['debug'](_0x2a1e('0x1c'),_0x49a5cc,JSON[_0x2a1e('0x1d')](_0x3bdfa0));_0x8f189b(_0x3bdfa0);})[_0x2a1e('0x18')](function(_0x4d0360){logger[_0x2a1e('0x12')]('CreateAttachment',_0x4d0360[_0x2a1e('0x15')],_0x49a5cc);_0x1f0e0e(_0x48917b[_0x2a1e('0x12')](0x1f4,_0x4d0360[_0x2a1e('0x15')]));});});};