adamsaghy commented on code in PR #5439:
URL: https://github.com/apache/fineract/pull/5439#discussion_r2822944168


##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/service/SmsCampaignWritePlatformServiceJpaImpl.java:
##########
@@ -104,20 +105,32 @@ public class SmsCampaignWritePlatformServiceJpaImpl 
implements SmsCampaignWriteP
     @Transactional
     @Override
     public CommandProcessingResult create(JsonCommand command) {
-        final AppUser currentUser = this.context.authenticatedUser();
-        this.smsCampaignValidator.validateCreate(command.json());
-        final Long runReportId = 
command.longValueOfParameterNamed(SmsCampaignValidator.runReportId);
-        Report report = 
this.reportRepository.findById(runReportId).orElseThrow(() -> new 
ReportNotFoundException(runReportId));
-        LocalDateTime tenantDateTime = DateUtils.getLocalDateTimeOfTenant();
-        SmsCampaign smsCampaign = SmsCampaign.instance(currentUser, report, 
command);
-        LocalDateTime recurrenceStartDate = 
smsCampaign.getRecurrenceStartDate();
-        if (recurrenceStartDate != null && 
DateUtils.isBefore(recurrenceStartDate, tenantDateTime)) {
-            throw new 
GeneralPlatformDomainRuleException("error.msg.campaign.recurrenceStartDate.in.the.past",
-                    "Recurrence start date cannot be the past date.", 
recurrenceStartDate);
-        }
-        this.smsCampaignRepository.saveAndFlush(smsCampaign);
+        try {
+            final AppUser currentUser = this.context.authenticatedUser();
+            this.smsCampaignValidator.validateCreate(command.json());
 
-        return new 
CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(smsCampaign.getId()).build();
+            final String campaignName = 
command.stringValueOfParameterNamed(SmsCampaignValidator.campaignName);
+            if (this.smsCampaignRepository.existsByCampaignName(campaignName)) 
{
+                throw new SmsCampaignNameAlreadyExistsException(campaignName);
+            }

Review Comment:
   The mentioned unique constraint is not existing. It's mentioned on the 
entity, but in reality it does not exist. Please add this missing unique 
constraint.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to