feat: Add email signature feature
- Add email_signatures table to schema - Add email signature service, controller, routes - Users can create/edit signature in Profile - Toggle to include signature when sending email replies Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
42
src/routes/email-signature.routes.js
Normal file
42
src/routes/email-signature.routes.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import express from 'express';
|
||||
import * as emailSignatureController from '../controllers/email-signature.controller.js';
|
||||
import { authenticate } from '../middlewares/auth/authMiddleware.js';
|
||||
import { validateBody } from '../middlewares/security/validateInput.js';
|
||||
import { z } from 'zod';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// All routes require authentication
|
||||
router.use(authenticate);
|
||||
|
||||
// Validation schemas
|
||||
const signatureSchema = z.object({
|
||||
fullName: z.string().max(255).optional().or(z.literal('')).or(z.null()),
|
||||
position: z.string().max(255).optional().or(z.literal('')).or(z.null()),
|
||||
phone: z.string().max(50).optional().or(z.literal('')).or(z.null()),
|
||||
email: z.string().email('Neplatný formát emailu').max(255).optional().or(z.literal('')).or(z.null()),
|
||||
companyName: z.string().max(255).optional().or(z.literal('')).or(z.null()),
|
||||
website: z.string().max(255).optional().or(z.literal('')).or(z.null()),
|
||||
isEnabled: z.boolean().optional(),
|
||||
});
|
||||
|
||||
const toggleSchema = z.object({
|
||||
isEnabled: z.boolean(),
|
||||
});
|
||||
|
||||
// Get user's signature
|
||||
router.get('/', emailSignatureController.getSignature);
|
||||
|
||||
// Get formatted signature text
|
||||
router.get('/formatted', emailSignatureController.getFormattedSignature);
|
||||
|
||||
// Create or update signature
|
||||
router.post('/', validateBody(signatureSchema), emailSignatureController.upsertSignature);
|
||||
|
||||
// Toggle signature on/off
|
||||
router.patch('/toggle', validateBody(toggleSchema), emailSignatureController.toggleSignature);
|
||||
|
||||
// Delete signature
|
||||
router.delete('/', emailSignatureController.deleteSignature);
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user