public contact send changes

This commit is contained in:
Efstratios Giannopoulos 2024-01-11 18:23:21 +02:00
parent ab8ad0be51
commit 4d60698327
5 changed files with 26 additions and 6 deletions

View File

@ -31,6 +31,7 @@ public class NotificationPersist {
private NotificationContactType contactTypeHint;
public static final String _contactHint = "contactHint";
private String contactHint;
private String data;
@ -205,8 +206,13 @@ public class NotificationPersist {
.must(() -> !this.isValidHash(item.getHash()))
.failOn(NotificationPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> this.isEmpty(item.getContactHint()))
.must(() -> this.isValidGuid(item.getUserId()))
.failOn(NotificationPersist._userId).failWith(messageSource.getMessage("Validation_Required", new Object[]{NotificationPersist._userId}, LocaleContextHolder.getLocale()))
.failOn(NotificationPersist._userId).failWith(messageSource.getMessage("Validation_Required", new Object[]{NotificationPersist._userId}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isValidGuid(item.getUserId()))
.must(() -> !this.isEmpty(item.getContactHint()))
.failOn(NotificationPersist._userId).failWith(messageSource.getMessage("Validation_Required", new Object[]{NotificationPersist._contactHint}, LocaleContextHolder.getLocale()))
);
}
}

View File

@ -92,7 +92,7 @@ public class ContactSupportServiceImpl implements ContactSupportService {
@Override
public void sendPublicContactEmail(PublicContactSupportPersist model) throws InvalidApplicationException {
logger.debug(new MapLogEntry("public send contact email").And("model", model));
this.authorizationService.authorizeForce(Permission.SendContactSupport);
this.authorizationService.authorizeForce(Permission.PublicSendContactSupport);
NotificationIntegrationEvent event = new NotificationIntegrationEvent();

View File

@ -65,7 +65,7 @@ public class NotificationServiceImpl implements NotificationService {
public void persist(NotificationPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting notification").And("model", model).And("fields", fields));
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
this.authorizationService.authorizeForce(Permission.PublicRole);
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());

View File

@ -23,6 +23,7 @@ import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@ -67,10 +68,10 @@ public class ContactSupportController {
@PostMapping("public/send")
@PostMapping(path = "public/send", consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
@Transactional
@ValidationFilterAnnotation(validator = PublicContactSupportPersist.PublicContactSupportPersistValidator.ValidatorName, argumentName ="model")
public void sendPublicContactEmail(@RequestBody PublicContactSupportPersist model) throws InvalidApplicationException {
public void sendPublicContactEmail(@ModelAttribute PublicContactSupportPersist model) throws InvalidApplicationException {
logger.debug(new MapLogEntry("send public support email").And("model", model));
this.contactSupportService.sendPublicContactEmail(model);
@ -81,4 +82,17 @@ public class ContactSupportController {
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
}
@PostMapping("public/send")
@Transactional
@ValidationFilterAnnotation(validator = PublicContactSupportPersist.PublicContactSupportPersistValidator.ValidatorName, argumentName ="model")
public void sendPublicContactEmailJson(@RequestBody PublicContactSupportPersist model) throws InvalidApplicationException {
logger.debug(new MapLogEntry("send public support email").And("model", model));
this.contactSupportService.sendPublicContactEmail(model);
this.auditService.track(AuditableAction.ContactSupport_PublicSent, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("model", model)
));
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
}
}

View File

@ -68,7 +68,7 @@
</div>
<iframe name="hiddenFrame" class="hide"></iframe>
<form class="form" method="POST" action="/api/contactEmail/public" target="hiddenFrame" onsubmit="emailSend()">
<form class="form" method="POST" action="/api/contact-support/public/send" target="hiddenFrame" onsubmit="emailSend()">
<div class="main-contact">
<div class="col page-subtitle">
<div>Contact us to learn more</div>