Skip to content

Commit

Permalink
Add places to notifications (#416)
Browse files Browse the repository at this point in the history
* Done.

* Remove change place status email.

* Change name.

* Fix tests.
  • Loading branch information
IliaWithHat authored Oct 11, 2024
1 parent 9b510f4 commit b9ebfc1
Show file tree
Hide file tree
Showing 17 changed files with 13 additions and 393 deletions.
8 changes: 1 addition & 7 deletions core/src/main/java/greencity/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
"/ownSecurity/register",
"/email/sendReport",
"/email/sendHabitNotification",
"/email/sendInterestingEcoNews",
"/email/changePlaceStatus",
"/email/general/notification",
"/email/sendHabitAssignNotification",
"/email/taggedUserInComment/notification",
"/email/userReceivedComment/notification",
"/email/userReceivedCommentReply/notification")
"/email/sendInterestingEcoNews")
.hasAnyRole(ADMIN)
.requestMatchers(HttpMethod.PATCH,
"/user/status",
Expand Down
15 changes: 0 additions & 15 deletions core/src/main/java/greencity/controller/EmailController.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,6 @@ public ResponseEntity<Object> sendReport(@RequestBody SendReportEmailMessage mes
return ResponseEntity.ok().build();
}

/**
* Method for sending simple notification to {@code User} about status change.
*
* @param message - object with all necessary data for sending email
*/
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = HttpStatuses.OK),
@ApiResponse(responseCode = "400", description = HttpStatuses.BAD_REQUEST),
})
@PostMapping("/changePlaceStatus")
public ResponseEntity<Object> changePlaceStatus(@RequestBody @Valid ChangePlaceStatusDto message) {
emailService.sendChangePlaceStatusEmail(message);
return ResponseEntity.ok().build();
}

/**
* Sends email notification about not marked habits during 3 last days.
*
Expand Down

This file was deleted.

39 changes: 1 addition & 38 deletions core/src/test/java/greencity/controller/EmailControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import greencity.dto.econews.InterestingEcoNewsDto;
import greencity.dto.violation.UserViolationMailDto;
import greencity.message.ScheduledEmailMessage;
import greencity.message.ChangePlaceStatusDto;
import greencity.message.SendHabitNotification;
import greencity.message.SendReportEmailMessage;
import greencity.service.EmailService;
Expand Down Expand Up @@ -100,7 +99,7 @@ void sendReport() throws Exception {
}
]
},
"emailNotification": "WEEKLY",
"periodicity": "WEEKLY",
"subscribers": [
{
"email": "string",
Expand All @@ -118,42 +117,6 @@ void sendReport() throws Exception {
verify(emailService).sendAddedNewPlacesReportEmail(message);
}

@Test
void changePlaceStatus() throws Exception {
String content = """
{\
"authorEmail":"string",\
"authorFirstName":"string",\
"placeName":"string",\
"placeStatus":"APPROVED",\
"authorLanguage":"en"\
}\
""";

mockPerform(content, "/changePlaceStatus");

ChangePlaceStatusDto message = new ObjectMapper().readValue(content, ChangePlaceStatusDto.class);

verify(emailService).sendChangePlaceStatusEmail(message);
}

@Test
void changePlaceStatusInvalidPlaceStatus() throws Exception {
String content = """
{\
"authorEmail":"string",\
"authorFirstName":"string",\
"placeName":"string",\
"placeStatus":"ggggggg"\
}\
""";

mockMvc.perform(post(LINK + "/changePlaceStatus")
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}

@Test
void sendHabitNotification() throws Exception {
String content = """
Expand Down
3 changes: 2 additions & 1 deletion dao/src/main/java/greencity/enums/EmailPreference.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public enum EmailPreference {
SYSTEM,
LIKES,
COMMENTS,
INVITES
INVITES,
PLACES
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@UtilityClass
public class EmailConstants {
// subjects
public static final String CHANGE_PLACE_STATUS = "change.place.status.subject";
public static final String NEW_PLACES = "New places";
public static final String INTERESTING_ECO_NEWS = "interesting.news.subject";
public static final String VERIFY_EMAIL = "verify.email";
Expand All @@ -23,8 +22,6 @@ public class EmailConstants {
public static final String VERIFY_ADDRESS = "verifyAddress";
public static final String RESTORE_PASS = "restorePassword";
public static final String APPROVE_REGISTRATION = "approveRegistration";
public static final String PLACE_NAME = "placeName";
public static final String STATUS = "status";
public static final String RESULT = "result";
public static final String REPORT_TYPE = "reportType";
public static final String UNSUBSCRIBE_LINK = "unsubscribeLink";
Expand All @@ -42,7 +39,6 @@ public class EmailConstants {
public static final String CRETE_PASSWORD_PAGE = "create-employee-password-page";
public static final String SUCCESS_RESTORED_PASSWORD_PAGE = "success-restored-password-page";
public static final String USER_APPROVAL_EMAIL_PAGE = "user-approval-email-page";
public static final String CHANGE_PLACE_STATUS_EMAIL_PAGE = "change-place-status-email-page";
public static final String NEW_PLACES_REPORT_EMAIL_PAGE = "new-places-report-email-page";
public static final String REASONS_OF_DEACTIVATION_PAGE = "user-reasons-of-deactivation-page";
public static final String ACTIVATION_PAGE = "user-activation-page";
Expand Down

This file was deleted.

42 changes: 0 additions & 42 deletions service-api/src/main/java/greencity/message/CommentMessage.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import greencity.dto.category.CategoryDto;
import greencity.dto.place.PlaceNotificationDto;
import greencity.dto.user.SubscriberDto;
import greencity.enums.EmailNotification;
import greencity.enums.EmailPreferencePeriodicity;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
Expand All @@ -18,5 +18,5 @@
public class SendReportEmailMessage {
private List<SubscriberDto> subscribers;
private Map<CategoryDto, List<PlaceNotificationDto>> categoriesDtoWithPlacesDtoMap;
private EmailNotification emailNotification;
private EmailPreferencePeriodicity periodicity;
}

This file was deleted.

Loading

0 comments on commit b9ebfc1

Please sign in to comment.