Update various configuration files, components, and assets; enhance notification system and API endpoints; improve documentation and styles across the application.
This commit is contained in:
65
server/api/notifications/delivery/push-config.get.js
Normal file
65
server/api/notifications/delivery/push-config.get.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import prisma from "~/server/utils/prisma";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
// Get current user from auth middleware
|
||||
const user = event.context.user;
|
||||
if (!user) {
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "Authentication required",
|
||||
});
|
||||
}
|
||||
|
||||
// Get push notification configuration
|
||||
const pushConfig = await prisma.notification_delivery_config.findFirst({
|
||||
where: {
|
||||
channel_type: 'push'
|
||||
},
|
||||
select: {
|
||||
is_enabled: true,
|
||||
provider: true,
|
||||
provider_config: true,
|
||||
status: true,
|
||||
success_rate: true,
|
||||
created_at: true,
|
||||
updated_at: true
|
||||
}
|
||||
});
|
||||
|
||||
if (!pushConfig) {
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
enabled: false,
|
||||
provider: 'firebase',
|
||||
status: 'Not Configured',
|
||||
successRate: 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
enabled: pushConfig.is_enabled,
|
||||
provider: pushConfig.provider,
|
||||
status: pushConfig.status,
|
||||
successRate: pushConfig.success_rate,
|
||||
config: pushConfig.provider_config
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error fetching push configuration:', error);
|
||||
|
||||
if (error.statusCode) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Failed to fetch push configuration'
|
||||
});
|
||||
} finally {
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user