plugin-communication/routes/notifications.js
2025-11-03 13:59:30 +02:00

38 lines
No EOL
1.1 KiB
JavaScript

const express = require('express');
const router = express.Router();
const { checkPluginPermission } = require('../../../src/middleware/pluginAuth');
const logger = require('../../../src/utils/logger');
// Get all notifications for the current site
router.get('/', checkPluginPermission('read_messages'), async (req, res) => {
try {
const { siteId } = req.user;
// In a real implementation, you'd query the plugin's database schema
const notifications = [
{
id: '1',
title: 'Welcome to Communication Plugin',
message: 'The communication plugin has been successfully installed.',
type: 'info',
is_read: false,
created_at: new Date().toISOString()
}
];
res.json({
success: true,
data: notifications,
message: 'Notifications retrieved successfully'
});
} catch (error) {
logger.error('Failed to get notifications:', error);
res.status(500).json({
success: false,
error: 'Failed to retrieve notifications',
message: error.message
});
}
});
module.exports = router;