0e20806c40859a77b13d59ee8347238329475c4a
[motion2.git] / server / api / chatWebsite / index.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 _0x0f54=['/:id/customer_avatar','getCustomerAvatar','/:id/system_avatar','getInteractions','/:id/snippet','getSnippet','/:id/applications','getApplications','/:id/proactive_actions','getProactiveActions','/:id/fields','getFields','getOfflineMessages','/:id/users','post','create','/:id/dispositions','addAnswer','diskStorage','join','root','format','now','originalname','/:id/logo','single','file','addLogo','%s-%s','/:id/avatar','addAvatar','server/files/images/avatars/','addCustomerAvatar','notify','server/files','attachments','ensureDir','replace','/:id/offline','offline','/:id/interactions','addInteraction','addApplications','addProactiveActions','addAgents','put','update','delete','destroy','removeAnswers','removeAgents','exports','multer','path','../../components/auth/service','../../components/interaction/service','../../config/environment','./chatWebsite.controller','get','isAuthenticated','index','/describe','describe','/:id','/:id/canned_answers','getAnswers','getLogo','getAvatar'];(function(_0x108a76,_0x160eee){var _0x495260=function(_0x1e9008){while(--_0x1e9008){_0x108a76['push'](_0x108a76['shift']());}};_0x495260(++_0x160eee);}(_0x0f54,0x100));var _0x40f5=function(_0x10f3f8,_0x114a4f){_0x10f3f8=_0x10f3f8-0x0;var _0x59dec6=_0x0f54[_0x10f3f8];return _0x59dec6;};'use strict';var multer=require(_0x40f5('0x0'));var util=require('util');var path=require(_0x40f5('0x1'));var timeout=require('connect-timeout');var express=require('express');var router=express['Router']();var fs_extra=require('fs-extra');var auth=require(_0x40f5('0x2'));var interaction=require(_0x40f5('0x3'));var config=require(_0x40f5('0x4'));var controller=require(_0x40f5('0x5'));router[_0x40f5('0x6')]('/',auth[_0x40f5('0x7')](),controller[_0x40f5('0x8')]);router[_0x40f5('0x6')](_0x40f5('0x9'),auth['isAuthenticated'](),controller[_0x40f5('0xa')]);router[_0x40f5('0x6')](_0x40f5('0xb'),auth[_0x40f5('0x7')](),controller['show']);router[_0x40f5('0x6')]('/:id/dispositions',auth[_0x40f5('0x7')](),controller['getDispositions']);router['get'](_0x40f5('0xc'),auth['isAuthenticated'](),controller[_0x40f5('0xd')]);router[_0x40f5('0x6')]('/:id/logo',controller[_0x40f5('0xe')]);router[_0x40f5('0x6')]('/:id/avatar',controller[_0x40f5('0xf')]);router[_0x40f5('0x6')](_0x40f5('0x10'),controller[_0x40f5('0x11')]);router[_0x40f5('0x6')](_0x40f5('0x12'),controller['getSystemAvatar']);router['get']('/:id/interactions',auth[_0x40f5('0x7')](),controller[_0x40f5('0x13')]);router[_0x40f5('0x6')](_0x40f5('0x14'),controller[_0x40f5('0x15')]);router[_0x40f5('0x6')](_0x40f5('0x16'),auth[_0x40f5('0x7')](),controller[_0x40f5('0x17')]);router[_0x40f5('0x6')](_0x40f5('0x18'),auth['isAuthenticated'](),controller[_0x40f5('0x19')]);router[_0x40f5('0x6')](_0x40f5('0x1a'),controller[_0x40f5('0x1b')]);router['get']('/:id/offline_messages',auth[_0x40f5('0x7')](),controller[_0x40f5('0x1c')]);router[_0x40f5('0x6')](_0x40f5('0x1d'),auth[_0x40f5('0x7')](),controller['getAgents']);router[_0x40f5('0x1e')]('/',auth['isAuthenticated'](),controller[_0x40f5('0x1f')]);router['post'](_0x40f5('0x20'),auth[_0x40f5('0x7')](),controller['addDisposition']);router[_0x40f5('0x1e')](_0x40f5('0xc'),auth['isAuthenticated'](),controller[_0x40f5('0x21')]);var upload=multer({'storage':multer[_0x40f5('0x22')]({'destination':function(_0x12a6c7,_0x3fee45,_0x594f05){_0x594f05(null,path[_0x40f5('0x23')](config[_0x40f5('0x24')],'server/files/images/logos/'));},'filename':function(_0x7c5269,_0x40920f,_0x31b74e){_0x31b74e(null,util[_0x40f5('0x25')]('%s-%s',Date[_0x40f5('0x26')](),_0x40920f[_0x40f5('0x27')]));}})});router[_0x40f5('0x1e')](_0x40f5('0x28'),upload[_0x40f5('0x29')](_0x40f5('0x2a')),controller[_0x40f5('0x2b')]);var upload=multer({'storage':multer['diskStorage']({'destination':function(_0xbd172f,_0x35e78f,_0x27278f){_0x27278f(null,path[_0x40f5('0x23')](config[_0x40f5('0x24')],'server/files/images/avatars/'));},'filename':function(_0x48227d,_0x430764,_0x1d8a3f){_0x1d8a3f(null,util[_0x40f5('0x25')](_0x40f5('0x2c'),Date[_0x40f5('0x26')](),_0x430764[_0x40f5('0x27')]));}})});router[_0x40f5('0x1e')](_0x40f5('0x2d'),upload[_0x40f5('0x29')](_0x40f5('0x2a')),controller[_0x40f5('0x2e')]);var upload=multer({'storage':multer[_0x40f5('0x22')]({'destination':function(_0x522a19,_0x290fac,_0x2cfe46){_0x2cfe46(null,path[_0x40f5('0x23')](config[_0x40f5('0x24')],_0x40f5('0x2f')));},'filename':function(_0xa30319,_0x4aa451,_0x2a16e4){_0x2a16e4(null,util['format'](_0x40f5('0x2c'),Date['now'](),_0x4aa451[_0x40f5('0x27')]));}})});router[_0x40f5('0x1e')](_0x40f5('0x10'),upload['single'](_0x40f5('0x2a')),controller[_0x40f5('0x30')]);var upload=multer({'storage':multer[_0x40f5('0x22')]({'destination':function(_0x1a9a91,_0xad35f8,_0x2e664f){_0x2e664f(null,path[_0x40f5('0x23')](config['root'],'server/files/images/avatars/'));},'filename':function(_0x30feca,_0x53fda4,_0x3d4280){_0x3d4280(null,util[_0x40f5('0x25')](_0x40f5('0x2c'),Date[_0x40f5('0x26')](),_0x53fda4[_0x40f5('0x27')]));}})});router[_0x40f5('0x1e')](_0x40f5('0x12'),upload[_0x40f5('0x29')](_0x40f5('0x2a')),controller['addSystemAvatar']);router[_0x40f5('0x1e')]('/:id/notify',controller[_0x40f5('0x31')]);const offlineUploadMulter=multer({'storage':multer[_0x40f5('0x22')]({'destination':function(_0x2a83ef,_0x329e60,_0x46148f){const _0x5a2913=path['join'](config[_0x40f5('0x24')],_0x40f5('0x32'),_0x40f5('0x33'),'offline-chat');fs_extra[_0x40f5('0x34')](_0x5a2913,function(){_0x46148f(null,_0x5a2913);});},'filename':function(_0x19934d,_0x4239df,_0x192d47){const _0x1abb2b=_0x4239df[_0x40f5('0x27')][_0x40f5('0x35')](/[+@&\/\\#,+()$~%'":*?<>{}\s\\|]/g,'-');const _0x2c763a=path['extname'](_0x1abb2b);const _0x5433eb=Date[_0x40f5('0x26')]()+'-'+_0x1abb2b[_0x40f5('0x35')](_0x2c763a,'')+_0x2c763a;_0x192d47(null,_0x5433eb);}})});router[_0x40f5('0x1e')](_0x40f5('0x36'),offlineUploadMulter['any'](),controller[_0x40f5('0x37')]);router[_0x40f5('0x1e')](_0x40f5('0x38'),auth['isAuthenticated'](),controller[_0x40f5('0x39')]);router[_0x40f5('0x1e')]('/:id/applications',auth[_0x40f5('0x7')](),controller[_0x40f5('0x3a')]);router[_0x40f5('0x1e')]('/:id/proactive_actions',auth[_0x40f5('0x7')](),controller[_0x40f5('0x3b')]);router['post']('/:id/users',auth['isAuthenticated'](),controller[_0x40f5('0x3c')]);router[_0x40f5('0x3d')](_0x40f5('0xb'),auth[_0x40f5('0x7')](),controller[_0x40f5('0x3e')]);router[_0x40f5('0x3f')]('/:id',auth['isAuthenticated'](),controller[_0x40f5('0x40')]);router['delete'](_0x40f5('0x20'),auth[_0x40f5('0x7')](),controller['removeDispositions']);router[_0x40f5('0x3f')]('/:id/canned_answers',auth[_0x40f5('0x7')](),controller[_0x40f5('0x41')]);router['delete']('/:id/users',auth[_0x40f5('0x7')](),controller[_0x40f5('0x42')]);module[_0x40f5('0x43')]=router;