Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikron committed Aug 17, 2021
2 parents ef04c76 + bccbdb6 commit e85f7d0
Show file tree
Hide file tree
Showing 83 changed files with 857 additions and 106 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: java
sudo: required
os: linux
git:
depth: false
services:
- docker
jdk:
- oraclejdk8
- oraclejdk11
script: ".travis/build.sh"
cache:
directories:
Expand All @@ -24,9 +24,7 @@ env:
- secure: RdpwVqHPxKqmeb+5/7fechEE9SoVSmy5bU97DDzrV/m74mXw+FbBrWKl5AVAbjwipm02/Oub5OaCA4bg6VEGp4w9/sgoZZr6AzuLsyUDd68mfcDQ75t3aSmfgysQEqK8hFhDTFwk3qMZmr4VjNVssATUVFCVnZEs/OOD2a4sQc2DYUQB1px2NNYhJCxKYYugUJrSTIjkkTt1EaWnepCj2YNoPUYUo/4HTjgUYOpsnrPN7iLO5Sf3SLofOkNnGGHbhs9UTKHeN4tx1MZ4ypcQtv9csliaanK4tu6WWjupkJBJWEW1IBsYxATUhi9APgHp2MG6rxbeamDSMHHjS7xn1sKPqfcEGpxslaxvQU9zAhyaC/s3Fz/Ytwetv3gBDvZdxS4rYhXYJXtSlK9fhDjGmzE4Gns3ycoANwgA+3axQKH/CURCXl+upNXHNwwvxwOVhITBE9eid/IsH4yP9UDh+23eJMwRMpBp5DLXRwoV/Rf73tBN9l+u0NUXSMob9N9Btpr6fvT7mZ+VwWEw1Vy83+O8O1ThkZ/X2PXLD/sV/kM4YTNQ1Sjof5Z4Lha+Vd7OGEgpShgQhjsrnXGB+LzQdmZiwfH7rA2RBM4OoKD4PzggsT/FTw45ueUpER0zqsY/EHCnuDqwpFLgYYbkDdvQnKWlMglhUjD17DvVlxNxBBo=
- secure: Zf+eG4IT/irrYdKrwoyjxq9zIxXNPzV61j9gAyLIGlHLpvHtr9v2kiZAXbS5cxT9QSjnAinq+b2zbWMeNkzIOujGc44RSJ+/DcmexfE2505HbiwzQnl5BDictj3FgJMS4TNzCYRWS5StoL1wP3kGm3lwYBOSpfa1nzSUBiAJgT2zB+QeZTKMdlDFV/XmMUURJs3bQNxZUTTvYwqgIUoLXcQteOs7F1DKKwoUApz1BiDkjpf/bn9ZCdTM1IXjRe0QX5aCP8OQU3YSCPc8/5T/dyJBjPIzUoYIdpV98BZlTyF4peeIPM6wAspttgzOU7GYzedQ/Cun7ngV8A8b0dNtcswNeA8gxxzq7Tb1MRmfTx0sWydq/KnQj+m7cKzKbip0u6+rnusVtcSTMp18rip4fa4UODWT0xW+O7pN33ukLNsV1qBuSg5PLAvMjdwp2gppmRpJC1R9U6buXrdtGF5SD74sXscQ0OlY1eE/ofA8Ak2X8gPXneAXm7OO23OrYz6f1/DA/E54CyIfKv+7H7RjAVJJFlpgn7cLgltbhFd+ASAcH/kf0nfReUKjzGoR/D0jcb7Imceu1FiUCdUWyZPOGC5LHpJ6KdvnEYxWJ9LwI+aA8EcFwWmJNG35FobK2Qo425jT2xUjJAgV9KGwNNqZ+EN8qq2ir/XIpiDYR9iNw34=
before_script:
- openssl aes-256-cbc -K $encrypted_49fa1606db88_key -iv $encrypted_49fa1606db88_iv
-in secret.tar.bz2.enc -out secret.tar.bz2 -d
- docker login --username $DOCKER_USER --password $DOCKERHUB_PASS
before_install:
- openssl aes-256-cbc -K $encrypted_49fa1606db88_key -iv $encrypted_49fa1606db88_iv
- openssl aes-256-cbc -K $encrypted_2f71a228d264_key -iv $encrypted_2f71a228d264_iv
-in secret.tar.bz2.enc -out secret.tar.bz2 -d
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ once the notifier microservice has been started.
## Deployment

Notifier is dockerized and is easy to deploy as a docker container. For more details, see the images on docker hub:
https://hub.docker.com/r/sflpro/notifier & https://hub.docker.com/r/sflpro/notifier-worker
https://hub.docker.com/r/sflpro/notifier-api & https://hub.docker.com/r/sflpro/notifier-worker

## Running the application locally

Expand Down Expand Up @@ -109,4 +109,4 @@ kafka.ssl.endpoint.identification.algorithm=https
kafka.sasl.mechanism=PLAIN
kafka.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="<API_KEY>" password="<API_SECRET>";
kafka.security.protocol=SASL_SSL
```
```
4 changes: 2 additions & 2 deletions api/api-client-library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>com.sflpro.notifier</groupId>
<artifactId>api</artifactId>
<version>1.9.1</version>
<version>1.10.0</version>
</parent>

<artifactId>api-client-library</artifactId>
<version>1.9.1</version>
<version>1.10.0</version>
<packaging>jar</packaging>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions api/api-facade/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<artifactId>api</artifactId>
<groupId>com.sflpro.notifier</groupId>
<version>1.9.1</version>
<version>1.10.0</version>
</parent>

<artifactId>api-facade</artifactId>
<version>1.9.1</version>
<version>1.10.0</version>
<packaging>jar</packaging>

<description>Project is representing facade layer for outgoing gateway of SFL NMS Internal API</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.sflpro.notifier.api.model.notification.NotificationClientType;
import com.sflpro.notifier.api.model.notification.NotificationModel;
import com.sflpro.notifier.api.model.notification.NotificationSendingPriorityClientType;
import com.sflpro.notifier.api.model.notification.NotificationStateClientType;
import com.sflpro.notifier.db.entities.notification.Notification;
import com.sflpro.notifier.db.entities.notification.UserNotification;
Expand Down Expand Up @@ -53,6 +54,7 @@ protected static void setNotificationCommonProperties(final NotificationModel no
notificationModel.setSubject(notification.getSubject());
notificationModel.setType(NotificationClientType.valueOf(notification.getType().name()));
notificationModel.setState(NotificationStateClientType.valueOf(notification.getState().name()));
notificationModel.setSendingPriority(NotificationSendingPriorityClientType.valueOf(notification.getSendingPriority().name()));
}

/* Properties getters and setters */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.sflpro.notifier.api.model.email.EmailNotificationModel;
import com.sflpro.notifier.api.model.notification.NotificationClientType;
import com.sflpro.notifier.api.model.notification.NotificationModel;
import com.sflpro.notifier.api.model.notification.NotificationSendingPriorityClientType;
import com.sflpro.notifier.api.model.notification.NotificationStateClientType;
import com.sflpro.notifier.api.model.push.PushNotificationModel;
import com.sflpro.notifier.api.model.push.PushNotificationRecipientModel;
Expand Down Expand Up @@ -86,6 +87,7 @@ private static void convertToNotificationModel(final Notification notification,
model.setState(NotificationStateClientType.valueOf(notification.getState().name()));
model.setSubject(notification.getSubject());
model.setType(NotificationClientType.valueOf(notification.getType().name()));
model.setSendingPriority(NotificationSendingPriorityClientType.valueOf(notification.getSendingPriority().name()));
}

private static EmailNotificationFileAttachmentModel convertFileAttachment(final EmailNotificationFileAttachment attachment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.sflpro.notifier.api.model.email.request.EmailNotificationFileAttachmentRequest;
import com.sflpro.notifier.api.model.email.response.CreateEmailNotificationResponse;
import com.sflpro.notifier.db.entities.notification.NotificationProviderType;
import com.sflpro.notifier.db.entities.notification.NotificationSendingPriority;
import com.sflpro.notifier.db.entities.notification.email.EmailNotification;
import com.sflpro.notifier.db.entities.notification.email.EmailNotificationFileAttachment;
import com.sflpro.notifier.services.notification.dto.email.EmailNotificationDto;
Expand Down Expand Up @@ -56,7 +57,7 @@ public ResultResponseModel<CreateEmailNotificationResponse> createEmailNotificat
}
final EmailNotificationDto emailNotificationDto = buildDto(request);
final EmailNotification emailNotification = emailNotificationService.createEmailNotification(emailNotificationDto);
applicationEventDistributionService.publishAsynchronousEvent(new StartSendingNotificationEvent(emailNotification.getId(), request.getSecureProperties()));
applicationEventDistributionService.publishAsynchronousEvent(new StartSendingNotificationEvent(emailNotification.getId(), request.getSecureProperties(), emailNotification.getSendingPriority()));
final EmailNotificationModel emailNotificationModel = (EmailNotificationModel) NotificationConverterHelper.convert(emailNotification);
return new ResultResponseModel<>(new CreateEmailNotificationResponse(emailNotificationModel));
}
Expand All @@ -77,6 +78,7 @@ private EmailNotificationDto buildDto(final CreateEmailNotificationRequest reque
emailNotificationDto.setUserUuid(request.getUserUuId());
emailNotificationDto.setHasSecureProperties(!request.getSecureProperties().isEmpty());
emailNotificationDto.setFileAttachments(mapFileAttachments(request.getFileAttachments()));
emailNotificationDto.setSendingPriority(NotificationSendingPriority.valueOf(request.getSendingPriority().name()));
return emailNotificationDto;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.sflpro.notifier.db.entities.device.UserDevice;
import com.sflpro.notifier.db.entities.device.mobile.DeviceOperatingSystemType;
import com.sflpro.notifier.db.entities.notification.NotificationProviderType;
import com.sflpro.notifier.db.entities.notification.NotificationSendingPriority;
import com.sflpro.notifier.db.entities.notification.email.NotificationProperty;
import com.sflpro.notifier.db.entities.notification.push.PushNotification;
import com.sflpro.notifier.db.entities.notification.push.PushNotificationRecipient;
Expand All @@ -36,6 +37,7 @@

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -95,10 +97,11 @@ public ResultResponseModel<CreatePushNotificationResponse> createPushNotificatio
pushNotificationDto.setTemplateName(request.getTemplateName());
pushNotificationDto.setLocale(request.getLocale());
pushNotificationDto.setProperties(request.getProperties());
pushNotificationDto.setSendingPriority(NotificationSendingPriority.valueOf(request.getSendingPriority().name()));
// Create push notifications
final List<PushNotification> pushNotifications = pushNotificationService.createNotificationsForUserActiveRecipients(user.getId(), pushNotificationDto);
// Publish events
pushNotifications.forEach(pushNotification -> applicationEventDistributionService.publishAsynchronousEvent(new StartSendingNotificationEvent(pushNotification.getId())));
pushNotifications.forEach(pushNotification -> applicationEventDistributionService.publishAsynchronousEvent(new StartSendingNotificationEvent(pushNotification.getId(), Collections.emptyMap(), pushNotification.getSendingPriority())));
// Convert to notification models
final List<PushNotificationModel> pushNotificationModels = pushNotifications.stream().map(PushNotificationServiceFacadeImpl::createPushNotificationModel).collect(Collectors.toCollection(ArrayList::new));
// Create response model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.sflpro.notifier.api.model.sms.request.CreateSmsNotificationRequest;
import com.sflpro.notifier.api.model.sms.response.CreateSmsNotificationResponse;
import com.sflpro.notifier.db.entities.notification.NotificationProviderType;
import com.sflpro.notifier.db.entities.notification.NotificationSendingPriority;
import com.sflpro.notifier.db.entities.notification.sms.SmsNotification;
import com.sflpro.notifier.services.notification.dto.sms.SmsNotificationDto;
import com.sflpro.notifier.services.notification.event.sms.StartSendingNotificationEvent;
Expand Down Expand Up @@ -65,10 +66,11 @@ public ResultResponseModel<CreateSmsNotificationResponse> createSmsNotification(
smsNotificationDto.setProperties(request.getProperties());
smsNotificationDto.setHasSecureProperties(!request.getSecureProperties().isEmpty());
smsNotificationDto.setLocale(request.getLocale());
smsNotificationDto.setSendingPriority(NotificationSendingPriority.valueOf(request.getSendingPriority().name()));
final SmsNotification smsNotification = smsNotificationService.createSmsNotification(smsNotificationDto);
associateUserWithNotificationIfRequired(request.getUserUuId(), smsNotification);
// Publish event
applicationEventDistributionService.publishAsynchronousEvent(new StartSendingNotificationEvent(smsNotification.getId(), request.getSecureProperties()));
applicationEventDistributionService.publishAsynchronousEvent(new StartSendingNotificationEvent(smsNotification.getId(), request.getSecureProperties(), smsNotification.getSendingPriority()));
// Create response model
final SmsNotificationModel smsNotificationModel = createSmsNotificationModel(smsNotification);
final CreateSmsNotificationResponse response = new CreateSmsNotificationResponse(smsNotificationModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import com.sflpro.notifier.api.model.email.request.CreateEmailNotificationRequest;
import com.sflpro.notifier.api.model.email.response.CreateEmailNotificationResponse;
import com.sflpro.notifier.api.model.notification.NotificationClientType;
import com.sflpro.notifier.api.model.notification.NotificationSendingPriorityClientType;
import com.sflpro.notifier.api.model.notification.NotificationStateClientType;
import com.sflpro.notifier.api.model.sms.request.CreateSmsNotificationRequest;
import com.sflpro.notifier.api.model.sms.response.CreateSmsNotificationResponse;
import com.sflpro.notifier.db.entities.notification.NotificationProviderType;
import com.sflpro.notifier.db.entities.notification.NotificationSendingPriority;
import com.sflpro.notifier.db.entities.notification.email.EmailNotification;
import com.sflpro.notifier.services.notification.dto.email.EmailNotificationDto;
import com.sflpro.notifier.services.notification.email.EmailNotificationService;
Expand Down Expand Up @@ -57,6 +59,7 @@ public void prepare() {
public void testCreateEmailNotification() {
final EmailNotification emailNotification = new EmailNotification();
final CreateEmailNotificationRequest request = getServiceFacadeImplTestHelper().createCreateEmailNotificationRequest();
request.setSendingPriority(NotificationSendingPriorityClientType.LOW);
emailNotification.setId(1L);
emailNotification.setProviderType(providerType);
emailNotification.setRecipientEmail(request.getRecipientEmail());
Expand All @@ -65,6 +68,7 @@ public void testCreateEmailNotification() {
emailNotification.setContent(request.getBody());
emailNotification.setSubject(request.getSubject());
emailNotification.setFileAttachments(Collections.emptySet());
emailNotification.setSendingPriority(NotificationSendingPriority.LOW);
final EmailNotificationDto emailNotificationDto = new EmailNotificationDto(
request.getRecipientEmail(),
request.getSenderEmail(),
Expand All @@ -78,9 +82,10 @@ public void testCreateEmailNotification() {
emailNotificationDto.setUserUuid(request.getUserUuId());
emailNotificationDto.setProperties(request.getProperties());
emailNotificationDto.setFileAttachments(Collections.emptySet());
emailNotificationDto.setSendingPriority(NotificationSendingPriority.LOW);
// Expectations
expect(emailNotificationService.createEmailNotification(emailNotificationDto)).andReturn(emailNotification);
applicationEventDistributionService.publishAsynchronousEvent(new StartSendingNotificationEvent(emailNotification.getId(), request.getSecureProperties()));
applicationEventDistributionService.publishAsynchronousEvent(new StartSendingNotificationEvent(emailNotification.getId(), request.getSecureProperties(), NotificationSendingPriority.LOW));
expectLastCall();
// Replay
replayAll();
Expand All @@ -92,7 +97,8 @@ public void testCreateEmailNotification() {
.hasFieldOrPropertyWithValue("subject", request.getSubject())
.hasFieldOrPropertyWithValue("body", request.getBody())
.hasFieldOrPropertyWithValue("state", NotificationStateClientType.CREATED)
.hasFieldOrPropertyWithValue("type", NotificationClientType.EMAIL);
.hasFieldOrPropertyWithValue("type", NotificationClientType.EMAIL)
.hasFieldOrPropertyWithValue("sendingPriority", NotificationSendingPriorityClientType.LOW);
verifyAll();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import com.sflpro.notifier.api.internal.facade.test.AbstractFacadeUnitTest;
import com.sflpro.notifier.api.model.common.result.ErrorType;
import com.sflpro.notifier.api.model.common.result.ResultResponseModel;
import com.sflpro.notifier.api.model.notification.NotificationSendingPriorityClientType;
import com.sflpro.notifier.api.model.push.request.CreatePushNotificationRequest;
import com.sflpro.notifier.api.model.push.request.UpdatePushNotificationSubscriptionRequest;
import com.sflpro.notifier.api.model.push.response.CreatePushNotificationResponse;
import com.sflpro.notifier.api.model.push.response.UpdatePushNotificationSubscriptionResponse;
import com.sflpro.notifier.db.entities.device.UserDevice;
import com.sflpro.notifier.db.entities.device.mobile.DeviceOperatingSystemType;
import com.sflpro.notifier.db.entities.notification.NotificationSendingPriority;
import com.sflpro.notifier.db.entities.notification.email.NotificationProperty;
import com.sflpro.notifier.db.entities.notification.push.PushNotification;
import com.sflpro.notifier.db.entities.notification.push.PushNotificationRecipient;
Expand Down Expand Up @@ -189,6 +191,7 @@ public void testCreatePushNotificationsWithValidationErrors() {
public void testCreatePushNotifications() {
// Test data
final CreatePushNotificationRequest request = getServiceFacadeImplTestHelper().createCreatePushNotificationRequest();
request.setSendingPriority(NotificationSendingPriorityClientType.MEDIUM);
// Create user
final Long userId = 1L;
final User user = getServiceFacadeImplTestHelper().createUser();
Expand All @@ -197,6 +200,7 @@ public void testCreatePushNotifications() {
// Expected push notification DTO
final PushNotificationDto pushNotificationDto = new PushNotificationDto(request.getBody(), request.getSubject(), request.getClientIpAddress());
pushNotificationDto.setProperties(request.getProperties());
pushNotificationDto.setSendingPriority(NotificationSendingPriority.MEDIUM);
final List<PushNotification> pushNotifications = createPushNotifications(10);
// Reset
resetAll();
Expand Down
Loading

0 comments on commit e85f7d0

Please sign in to comment.