7f53c99cac0638a6d5e835c1932f587c470f097e
[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 _0x7df4=['addLogo','root','server/files/images/avatars/','file','addAvatar','/:id/customer_avatar','single','addCustomerAvatar','addSystemAvatar','/:id/notify','notify','server/files','attachments','replace','/:id/offline','any','offline','put','update','delete','destroy','/:id/dispositions','removeDispositions','removeAnswers','/:id/users','exports','multer','util','connect-timeout','fs-extra','../../components/auth/service','../../components/interaction/service','./chatWebsite.controller','get','isAuthenticated','index','/describe','describe','/:id','show','getDispositions','/:id/canned_answers','/:id/logo','getLogo','/:id/avatar','getAvatar','getCustomerAvatar','/:id/system_avatar','getSystemAvatar','/:id/interactions','getInteractions','/:id/snippet','getSnippet','/:id/applications','getApplications','/:id/proactive_actions','getProactiveActions','/:id/fields','getFields','/:id/offline_messages','getOfflineMessages','getAgents','post','create','addDisposition','addAnswer','diskStorage','join','format','%s-%s','now','originalname'];(function(_0x48c790,_0x2dc331){var _0x3fb1b9=function(_0x271ed1){while(--_0x271ed1){_0x48c790['push'](_0x48c790['shift']());}};_0x3fb1b9(++_0x2dc331);}(_0x7df4,0x182));var _0x47df=function(_0x474241,_0xaa4c69){_0x474241=_0x474241-0x0;var _0x510a20=_0x7df4[_0x474241];return _0x510a20;};'use strict';var multer=require(_0x47df('0x0'));var util=require(_0x47df('0x1'));var path=require('path');var timeout=require(_0x47df('0x2'));var express=require('express');var router=express['Router']();var fs_extra=require(_0x47df('0x3'));var auth=require(_0x47df('0x4'));var interaction=require(_0x47df('0x5'));var config=require('../../config/environment');var controller=require(_0x47df('0x6'));router[_0x47df('0x7')]('/',auth[_0x47df('0x8')](),controller[_0x47df('0x9')]);router['get'](_0x47df('0xa'),auth[_0x47df('0x8')](),controller[_0x47df('0xb')]);router['get'](_0x47df('0xc'),auth[_0x47df('0x8')](),controller[_0x47df('0xd')]);router[_0x47df('0x7')]('/:id/dispositions',auth[_0x47df('0x8')](),controller[_0x47df('0xe')]);router[_0x47df('0x7')](_0x47df('0xf'),auth[_0x47df('0x8')](),controller['getAnswers']);router['get'](_0x47df('0x10'),controller[_0x47df('0x11')]);router[_0x47df('0x7')](_0x47df('0x12'),controller[_0x47df('0x13')]);router['get']('/:id/customer_avatar',controller[_0x47df('0x14')]);router[_0x47df('0x7')](_0x47df('0x15'),controller[_0x47df('0x16')]);router[_0x47df('0x7')](_0x47df('0x17'),auth['isAuthenticated'](),controller[_0x47df('0x18')]);router[_0x47df('0x7')](_0x47df('0x19'),controller[_0x47df('0x1a')]);router[_0x47df('0x7')](_0x47df('0x1b'),auth[_0x47df('0x8')](),controller[_0x47df('0x1c')]);router[_0x47df('0x7')](_0x47df('0x1d'),auth[_0x47df('0x8')](),controller[_0x47df('0x1e')]);router[_0x47df('0x7')](_0x47df('0x1f'),controller[_0x47df('0x20')]);router[_0x47df('0x7')](_0x47df('0x21'),auth[_0x47df('0x8')](),controller[_0x47df('0x22')]);router['get']('/:id/users',auth[_0x47df('0x8')](),controller[_0x47df('0x23')]);router[_0x47df('0x24')]('/',auth[_0x47df('0x8')](),controller[_0x47df('0x25')]);router['post']('/:id/dispositions',auth['isAuthenticated'](),controller[_0x47df('0x26')]);router[_0x47df('0x24')](_0x47df('0xf'),auth[_0x47df('0x8')](),controller[_0x47df('0x27')]);var upload=multer({'storage':multer[_0x47df('0x28')]({'destination':function(_0x13db9e,_0x2af8af,_0x1888c6){_0x1888c6(null,path[_0x47df('0x29')](config['root'],'server/files/images/logos/'));},'filename':function(_0x26de3e,_0x319b23,_0x276ae9){_0x276ae9(null,util[_0x47df('0x2a')](_0x47df('0x2b'),Date[_0x47df('0x2c')](),_0x319b23[_0x47df('0x2d')]));}})});router[_0x47df('0x24')](_0x47df('0x10'),upload['single']('file'),controller[_0x47df('0x2e')]);var upload=multer({'storage':multer[_0x47df('0x28')]({'destination':function(_0x35d61b,_0xa4c7f,_0x46f262){_0x46f262(null,path[_0x47df('0x29')](config[_0x47df('0x2f')],_0x47df('0x30')));},'filename':function(_0x1ef1f1,_0x37f00d,_0x256bea){_0x256bea(null,util['format'](_0x47df('0x2b'),Date[_0x47df('0x2c')](),_0x37f00d[_0x47df('0x2d')]));}})});router[_0x47df('0x24')](_0x47df('0x12'),upload['single'](_0x47df('0x31')),controller[_0x47df('0x32')]);var upload=multer({'storage':multer[_0x47df('0x28')]({'destination':function(_0x4526a7,_0x4f2620,_0x298685){_0x298685(null,path[_0x47df('0x29')](config[_0x47df('0x2f')],'server/files/images/avatars/'));},'filename':function(_0x2c498d,_0x9113c,_0x63d332){_0x63d332(null,util[_0x47df('0x2a')]('%s-%s',Date['now'](),_0x9113c[_0x47df('0x2d')]));}})});router[_0x47df('0x24')](_0x47df('0x33'),upload[_0x47df('0x34')]('file'),controller[_0x47df('0x35')]);var upload=multer({'storage':multer[_0x47df('0x28')]({'destination':function(_0x1f74d2,_0x5775d6,_0x18254a){_0x18254a(null,path['join'](config[_0x47df('0x2f')],'server/files/images/avatars/'));},'filename':function(_0x4481df,_0x2d4010,_0x5ec4a4){_0x5ec4a4(null,util[_0x47df('0x2a')](_0x47df('0x2b'),Date[_0x47df('0x2c')](),_0x2d4010[_0x47df('0x2d')]));}})});router[_0x47df('0x24')](_0x47df('0x15'),upload['single'](_0x47df('0x31')),controller[_0x47df('0x36')]);router[_0x47df('0x24')](_0x47df('0x37'),controller[_0x47df('0x38')]);const offlineUploadMulter=multer({'storage':multer['diskStorage']({'destination':function(_0x89f3fa,_0x480655,_0x3dee6b){const _0x46c98f=path[_0x47df('0x29')](config[_0x47df('0x2f')],_0x47df('0x39'),_0x47df('0x3a'),'offline-chat');fs_extra['ensureDir'](_0x46c98f,function(){_0x3dee6b(null,_0x46c98f);});},'filename':function(_0x4c8c9e,_0x4e12bc,_0x22f7a0){const _0x39c34f=_0x4e12bc[_0x47df('0x2d')][_0x47df('0x3b')](/[+@&\/\\#,+()$~%'":*?<>{}\s\\|]/g,'-');const _0x2ad9b6=path['extname'](_0x39c34f);const _0x1d72f2=Date[_0x47df('0x2c')]()+'-'+_0x39c34f[_0x47df('0x3b')](_0x2ad9b6,'')+_0x2ad9b6;_0x22f7a0(null,_0x1d72f2);}})});router['post'](_0x47df('0x3c'),offlineUploadMulter[_0x47df('0x3d')](),controller[_0x47df('0x3e')]);router[_0x47df('0x24')](_0x47df('0x17'),auth[_0x47df('0x8')](),controller['addInteraction']);router[_0x47df('0x24')](_0x47df('0x1b'),auth[_0x47df('0x8')](),controller['addApplications']);router['post'](_0x47df('0x1d'),auth[_0x47df('0x8')](),controller['addProactiveActions']);router[_0x47df('0x24')]('/:id/users',auth['isAuthenticated'](),controller['addAgents']);router[_0x47df('0x3f')](_0x47df('0xc'),auth['isAuthenticated'](),controller[_0x47df('0x40')]);router[_0x47df('0x41')](_0x47df('0xc'),auth[_0x47df('0x8')](),controller[_0x47df('0x42')]);router['delete'](_0x47df('0x43'),auth[_0x47df('0x8')](),controller[_0x47df('0x44')]);router[_0x47df('0x41')](_0x47df('0xf'),auth['isAuthenticated'](),controller[_0x47df('0x45')]);router[_0x47df('0x41')](_0x47df('0x46'),auth[_0x47df('0x8')](),controller['removeAgents']);module[_0x47df('0x47')]=router;