feat(api): add new reason and userAgent properties to the report endpoint
This commit is contained in:
parent
e17d9b9a62
commit
d178dd839d
@ -2,7 +2,9 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify';
|
|||||||
import { sendMail } from 'services/mailing';
|
import { sendMail } from 'services/mailing';
|
||||||
|
|
||||||
type PostReportBody = {
|
type PostReportBody = {
|
||||||
|
reason?: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
userAgent?: string;
|
||||||
version: string;
|
version: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -13,9 +15,15 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: (
|
|||||||
schema: {
|
schema: {
|
||||||
body: {
|
body: {
|
||||||
properties: {
|
properties: {
|
||||||
|
reason: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
url: {
|
url: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
userAgent: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
version: {
|
version: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
@ -26,8 +34,8 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const { url, version } = request.body;
|
const { reason = 'Unknown', url, userAgent = 'Unknown', version } = request.body;
|
||||||
const html = `<b>Site:</b> ${url}<br/><b>Version:</b> ${version}`;
|
const html = `<b>Site:</b> ${url}<br/><b>Reason: ${reason}<br/></b><b>User-Agent:</b> ${userAgent}<br/><b>Version:</b> ${version}`;
|
||||||
const subject = 'Cookie Dialog Monster Report';
|
const subject = 'Cookie Dialog Monster Report';
|
||||||
const to = 'hello@wanhose.dev';
|
const to = 'hello@wanhose.dev';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user