UNPKG

@opengis/admin

Version:

This project Softpro Admin

36 lines (28 loc) 830 B
import { config } from '@opengis/fastify-table/utils.js'; import { sendNotification } from '../../../../utils.js'; export default async function testNotification({ pg, query = {}, user = {}, }) { const { local } = config || {}; if (!user?.user_type?.includes('admin') && !local) { return { message: 'Forbidden', status: 403 }; } const date = new Date().toISOString().split('T')[0]; if (!query.to) { return { message: 'param to is required', status: 400 }; } const { to, template, table, id, nocache, } = query; const data = await sendNotification({ pg, to, template, title: `Test Softpro ${date}`, table, nocache, id, message: `Test mail Softpro ${date} Lorem Ipsum Lorem Ipsum`, }); return { message: data || 'ok' }; }