- More options how to send test emails. - Fixed problems with pausing a campaign (#593) - Started rework of transactional sender of templates (#606), however this contains functionality regression at the moment because it does not interpret templates as HBS. It needs HBS option for templates as described in https://github.com/Mailtrain-org/mailtrain/issues/611#issuecomment-502345227 TODO: - detect sending errors connected to not able to contact the mailer and pause/retry campaing and queued sending - don't mark the recipients as BOUNCED - add FAILED campaign state and fall into it if sending to campaign consistently fails (i.e. the error with sending is not temporary) - if the same happends for queued email, delete the message
		
			
				
	
	
		
			41 lines
		
	
	
		
			No EOL
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			No EOL
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const passport = require('../../lib/passport');
 | |
| const templates = require('../../models/templates');
 | |
| 
 | |
| const router = require('../../lib/router-async').create();
 | |
| const {castToInteger} = require('../../lib/helpers');
 | |
| 
 | |
| 
 | |
| router.getAsync('/templates/:templateId', passport.loggedIn, async (req, res) => {
 | |
|     const template = await templates.getById(req.context, castToInteger(req.params.templateId));
 | |
|     template.hash = templates.hash(template);
 | |
|     return res.json(template);
 | |
| });
 | |
| 
 | |
| router.postAsync('/templates', passport.loggedIn, passport.csrfProtection, async (req, res) => {
 | |
|     return res.json(await templates.create(req.context, req.body));
 | |
| });
 | |
| 
 | |
| router.putAsync('/templates/:templateId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
 | |
|     const template = req.body;
 | |
|     template.id = castToInteger(req.params.templateId);
 | |
| 
 | |
|     await templates.updateWithConsistencyCheck(req.context, template);
 | |
|     return res.json();
 | |
| });
 | |
| 
 | |
| router.deleteAsync('/templates/:templateId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
 | |
|     await templates.remove(req.context, castToInteger(req.params.templateId));
 | |
|     return res.json();
 | |
| });
 | |
| 
 | |
| router.postAsync('/templates-table', passport.loggedIn, async (req, res) => {
 | |
|     return res.json(await templates.listDTAjax(req.context, req.body));
 | |
| });
 | |
| 
 | |
| router.postAsync('/templates-by-namespace-table/:namespaceId', passport.loggedIn, async (req, res) => {
 | |
|     return res.json(await templates.listByNamespaceDTAjax(req.context, castToInteger(req.params.namespaceId), req.body));
 | |
| });
 | |
| 
 | |
| module.exports = router; |