diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/domain/notification/GroupNotificationFactory.java b/src/main/java/de/tum/cit/aet/artemis/communication/domain/notification/GroupNotificationFactory.java index 62af1c1ea18a..5c73ce127e07 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/domain/notification/GroupNotificationFactory.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/domain/notification/GroupNotificationFactory.java @@ -242,16 +242,18 @@ public static GroupNotification createAnnouncementNotification(Post post, User a GroupNotification notification; title = NotificationConstants.NEW_ANNOUNCEMENT_POST_TITLE; text = NotificationConstants.NEW_ANNOUNCEMENT_POST_TEXT; + var imageUrl = post.getAuthor().getImageUrl() == null ? "" : post.getAuthor().getImageUrl(); placeholderValues = createPlaceholdersNewAnnouncementPost(course.getTitle(), post.getTitle(), Jsoup.parse(post.getContent()).text(), post.getCreationDate().toString(), - post.getAuthor().getName()); + post.getAuthor().getName(), imageUrl, post.getAuthor().getId().toString(), post.getId().toString()); notification = new GroupNotification(course, title, text, true, placeholderValues, author, groupNotificationType); notification.setTransientAndStringTarget(createCoursePostTarget(post, course)); return notification; } @NotificationPlaceholderCreator(values = { NEW_ANNOUNCEMENT_POST }) - public static String[] createPlaceholdersNewAnnouncementPost(String courseTitle, String postTitle, String postContent, String postCreationDate, String postAuthorName) { - return new String[] { courseTitle, postTitle, postContent, postCreationDate, postAuthorName }; + public static String[] createPlaceholdersNewAnnouncementPost(String courseTitle, String postTitle, String postContent, String postCreationDate, String postAuthorName, + String imageUrl, String authorId, String postId) { + return new String[] { courseTitle, postTitle, postContent, postCreationDate, postAuthorName, imageUrl, authorId, postId }; } /** diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/domain/notification/SingleUserNotificationFactory.java b/src/main/java/de/tum/cit/aet/artemis/communication/domain/notification/SingleUserNotificationFactory.java index 71dc52ae4e93..301cb1bf955b 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/domain/notification/SingleUserNotificationFactory.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/domain/notification/SingleUserNotificationFactory.java @@ -321,9 +321,11 @@ public static SingleUserNotification createNotification(AnswerPost answerPost, N } Conversation conversation = answerPost.getPost().getConversation(); + var imageUrl = answerPost.getAuthor().getImageUrl() != null ? answerPost.getAuthor().getImageUrl() : ""; var placeholders = createPlaceholdersNewReply(conversation.getCourse().getTitle(), answerPost.getPost().getContent(), answerPost.getPost().getCreationDate().toString(), answerPost.getPost().getAuthor().getName(), answerPost.getContent(), answerPost.getCreationDate().toString(), answerPost.getAuthor().getName(), - conversation.getHumanReadableNameForReceiver(answerPost.getAuthor())); + conversation.getHumanReadableNameForReceiver(answerPost.getAuthor()), imageUrl, answerPost.getAuthor().getId().toString(), answerPost.getId().toString(), + answerPost.getPost().getId().toString()); String messageReplyTextType = MESSAGE_REPLY_IN_CONVERSATION_TEXT; @@ -340,8 +342,9 @@ public static SingleUserNotification createNotification(AnswerPost answerPost, N @NotificationPlaceholderCreator(values = { NEW_REPLY_FOR_EXERCISE_POST, NEW_REPLY_FOR_LECTURE_POST, NEW_REPLY_FOR_COURSE_POST, NEW_REPLY_FOR_EXAM_POST, CONVERSATION_NEW_REPLY_MESSAGE, CONVERSATION_USER_MENTIONED }) public static String[] createPlaceholdersNewReply(String courseTitle, String postContent, String postCreationData, String postAuthorName, String answerPostContent, - String answerPostCreationDate, String authorName, String conversationName) { - return new String[] { courseTitle, postContent, postCreationData, postAuthorName, answerPostContent, answerPostCreationDate, authorName, conversationName }; + String answerPostCreationDate, String authorName, String conversationName, String imageUrl, String userId, String postingId, String parentPostId) { + return new String[] { courseTitle, postContent, postCreationData, postAuthorName, answerPostContent, answerPostCreationDate, authorName, conversationName, imageUrl, userId, + postingId, parentPostId }; } /** diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/domain/push_notification/PushNotificationApiType.java b/src/main/java/de/tum/cit/aet/artemis/communication/domain/push_notification/PushNotificationApiType.java new file mode 100644 index 000000000000..f191a4a08645 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/communication/domain/push_notification/PushNotificationApiType.java @@ -0,0 +1,23 @@ +package de.tum.cit.aet.artemis.communication.domain.push_notification; + +import java.util.Arrays; + +public enum PushNotificationApiType { + + DEFAULT((short) 0), IOS_V2((short) 1); + + private final short databaseKey; + + PushNotificationApiType(short databaseKey) { + this.databaseKey = databaseKey; + } + + public short getDatabaseKey() { + return databaseKey; + } + + public static PushNotificationApiType fromDatabaseKey(short databaseKey) { + return Arrays.stream(PushNotificationApiType.values()).filter(type -> type.getDatabaseKey() == databaseKey).findFirst() + .orElseThrow(() -> new IllegalArgumentException("Unknown database key: " + databaseKey)); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/domain/push_notification/PushNotificationDeviceConfiguration.java b/src/main/java/de/tum/cit/aet/artemis/communication/domain/push_notification/PushNotificationDeviceConfiguration.java index b9a911ce6194..8c0aafae5cea 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/domain/push_notification/PushNotificationDeviceConfiguration.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/domain/push_notification/PushNotificationDeviceConfiguration.java @@ -6,6 +6,7 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.Enumerated; import jakarta.persistence.Id; import jakarta.persistence.IdClass; import jakarta.persistence.JoinColumn; @@ -34,6 +35,10 @@ public class PushNotificationDeviceConfiguration { @Column(name = "device_type") private PushNotificationDeviceType deviceType; + @Enumerated + @Column(name = "api_type") + private PushNotificationApiType apiType; + @Column(name = "expiration_date") private Date expirationDate; @@ -53,6 +58,16 @@ public PushNotificationDeviceConfiguration(String token, PushNotificationDeviceT this.owner = owner; } + public PushNotificationDeviceConfiguration(String token, PushNotificationDeviceType deviceType, Date expirationDate, byte[] secretKey, User owner, + PushNotificationApiType apiType) { + this.token = token; + this.deviceType = deviceType; + this.expirationDate = expirationDate; + this.secretKey = secretKey; + this.owner = owner; + this.apiType = apiType; + } + public PushNotificationDeviceConfiguration() { // needed for JPA } @@ -97,6 +112,10 @@ public void setOwner(User owner) { this.owner = owner; } + public PushNotificationApiType getApiType() { + return apiType; + } + @Override public boolean equals(Object object) { if (this == object) { diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/dto/PushNotificationRegisterBody.java b/src/main/java/de/tum/cit/aet/artemis/communication/dto/PushNotificationRegisterBody.java index 985039d9fba8..7455e2e7d530 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/dto/PushNotificationRegisterBody.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/dto/PushNotificationRegisterBody.java @@ -1,6 +1,11 @@ package de.tum.cit.aet.artemis.communication.dto; +import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationApiType; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceType; -public record PushNotificationRegisterBody(String token, PushNotificationDeviceType deviceType) { +public record PushNotificationRegisterBody(String token, PushNotificationDeviceType deviceType, PushNotificationApiType apiType) { + + public PushNotificationRegisterBody(String token, PushNotificationDeviceType deviceType) { + this(token, deviceType, PushNotificationApiType.DEFAULT); + } } diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/ConversationNotificationService.java b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/ConversationNotificationService.java index cf5cc2c67cc8..91cc23d2f6f3 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/ConversationNotificationService.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/ConversationNotificationService.java @@ -84,8 +84,10 @@ public ConversationNotification createNotification(Post createdMessage, Conversa } default -> throw new IllegalStateException("Unexpected value: " + conversation); } + var imageUrl = createdMessage.getAuthor().getImageUrl() == null ? "" : createdMessage.getAuthor().getImageUrl(); String[] placeholders = createPlaceholdersNewMessageChannelText(course.getTitle(), createdMessage.getContent(), createdMessage.getCreationDate().toString(), - conversationName, createdMessage.getAuthor().getName(), conversationType); + conversationName, createdMessage.getAuthor().getName(), conversationType, imageUrl, createdMessage.getAuthor().getId().toString(), + createdMessage.getId().toString()); ConversationNotification notification = createConversationMessageNotification(course.getId(), createdMessage, notificationType, notificationText, true, placeholders); save(notification, mentionedUsers, placeholders, createdMessage); return notification; @@ -93,8 +95,8 @@ public ConversationNotification createNotification(Post createdMessage, Conversa @NotificationPlaceholderCreator(values = { CONVERSATION_NEW_MESSAGE }) public static String[] createPlaceholdersNewMessageChannelText(String courseTitle, String messageContent, String messageCreationDate, String conversationName, - String authorName, String conversationType) { - return new String[] { courseTitle, messageContent, messageCreationDate, conversationName, authorName, conversationType }; + String authorName, String conversationType, String imageUrl, String userId, String postId) { + return new String[] { courseTitle, messageContent, messageCreationDate, conversationName, authorName, conversationType, imageUrl, userId, postId }; } private void save(ConversationNotification notification, Set mentionedUsers, String[] placeHolders, Post createdMessage) { diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/GroupNotificationService.java b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/GroupNotificationService.java index 6e48ec307044..4ee87d9c0173 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/GroupNotificationService.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/GroupNotificationService.java @@ -120,6 +120,7 @@ private void notifyGroupsWithNotificationType(GroupNotificationType[] groups, No * @param author is the user who initiated the process of the notifications. Can be null if not specified * @param onlySave whether the notification should only be saved and not sent to users */ + @SuppressWarnings("unchecked") private void notifyGroupsWithNotificationType(GroupNotificationType[] groups, NotificationType notificationType, Object notificationSubject, Object typeSpecificInformation, User author, boolean onlySave) { for (GroupNotificationType group : groups) { diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/push_notifications/PushNotificationService.java b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/push_notifications/PushNotificationService.java index 3892421894ee..22c2a1d54413 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/push_notifications/PushNotificationService.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/push_notifications/PushNotificationService.java @@ -155,11 +155,11 @@ public void sendNotification(Notification notification, Set users, Object } final String date = Instant.now().toString(); - var notificationData = new PushNotificationData(notification.getTransientPlaceholderValuesAsArray(), notification.getTarget(), type.name(), date, - Constants.PUSH_NOTIFICATION_VERSION); try { - final String payload = mapper.writeValueAsString(notificationData); + var notificationData = new PushNotificationData(notification.getTransientPlaceholderValuesAsArray(), notification.getTarget(), type.name(), date, + Constants.PUSH_NOTIFICATION_VERSION); + var payload = mapper.writeValueAsString(notificationData); final byte[] initializationVector = new byte[16]; List notificationRequests = userDeviceConfigurations.stream().flatMap(deviceConfiguration -> { @@ -170,7 +170,8 @@ public void sendNotification(Notification notification, Set users, Object String ivAsString = Base64.getEncoder().encodeToString(initializationVector); Optional payloadCiphertext = encrypt(payload, key, initializationVector); - return payloadCiphertext.stream().map(s -> new RelayNotificationRequest(ivAsString, s, deviceConfiguration.getToken())); + return payloadCiphertext.stream() + .map(s -> new RelayNotificationRequest(ivAsString, s, deviceConfiguration.getToken(), deviceConfiguration.getApiType().getDatabaseKey())); }).toList(); sendNotificationRequestsToEndpoint(notificationRequests, relayServerBaseUrl.get()); diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/push_notifications/RelayNotificationRequest.java b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/push_notifications/RelayNotificationRequest.java index 3cbe5695ccc8..91f43d2b9088 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/push_notifications/RelayNotificationRequest.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/push_notifications/RelayNotificationRequest.java @@ -1,4 +1,4 @@ package de.tum.cit.aet.artemis.communication.service.notifications.push_notifications; -public record RelayNotificationRequest(String initializationVector, String payloadCipherText, String token) { +public record RelayNotificationRequest(String initializationVector, String payloadCipherText, String token, short apiType) { } diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/web/PushNotificationResource.java b/src/main/java/de/tum/cit/aet/artemis/communication/web/PushNotificationResource.java index b64fdf4c6af5..3078e9f3d6cd 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/web/PushNotificationResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/web/PushNotificationResource.java @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationApiType; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceConfiguration; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceConfigurationId; import de.tum.cit.aet.artemis.communication.dto.PushNotificationRegisterBody; @@ -100,10 +101,12 @@ public ResponseEntity register(@Valid @RequestBody return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } + PushNotificationApiType apiType = pushNotificationRegisterBody.apiType() != null ? pushNotificationRegisterBody.apiType() : PushNotificationApiType.DEFAULT; + User user = userRepository.getUser(); PushNotificationDeviceConfiguration deviceConfiguration = new PushNotificationDeviceConfiguration(pushNotificationRegisterBody.token(), - pushNotificationRegisterBody.deviceType(), expirationDate, newKey.getEncoded(), user); + pushNotificationRegisterBody.deviceType(), expirationDate, newKey.getEncoded(), user, apiType); pushNotificationDeviceConfigurationRepository.save(deviceConfiguration); var encodedKey = Base64.getEncoder().encodeToString(newKey.getEncoded()); diff --git a/src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java b/src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java index 6ddd70dad841..35d6fea8ec18 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java @@ -376,6 +376,11 @@ public final class Constants { */ public static final int PUSH_NOTIFICATION_VERSION = 1; + /** + * The value of the version field we send with each push notification to the native clients (Android & iOS). + */ + public static final int PUSH_NOTIFICATION_MINOR_VERSION = 2; + /** * The directory in the docker container in which the build script is executed */ diff --git a/src/main/resources/config/liquibase/changelog/20241114122713_changelog.xml b/src/main/resources/config/liquibase/changelog/20241114122713_changelog.xml new file mode 100644 index 000000000000..a723075a6cde --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20241114122713_changelog.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index e8f58b18d024..59c5a80582d0 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -36,6 +36,7 @@ + diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationFactoryTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationFactoryTest.java index fd2cdc919724..1bb03f00d9ad 100644 --- a/src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationFactoryTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationFactoryTest.java @@ -121,12 +121,16 @@ class GroupNotificationFactoryTest { private static final String POST_TITLE = "post title"; + private static final Long POST_ID = 1L; + private static final String POST_CONTENT = "post content"; private static final String ANSWER_POST_CONTENT = "answer post content"; private static User user = new User(); + private static final Long USER_ID = 1L; + private String expectedTitle; private String expectedText; @@ -196,8 +200,10 @@ static void setUp() { user = new User(); user.setFirstName("John"); user.setLastName("Smith"); + user.setId(USER_ID); post = new Post(); + post.setId(POST_ID); post.setConversation(new Channel()); post.setAuthor(user); post.setTitle(POST_TITLE); diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderSignatureTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderSignatureTest.java index 2c6639cac9e2..e4b0c6d70511 100644 --- a/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderSignatureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderSignatureTest.java @@ -30,12 +30,12 @@ class NotificationPlaceholderSignatureTest extends AbstractSpringIntegrationInde * 2. The database becomes inconsistent. The placeholders are stored as JSON in the database. * You must now do the following: * 1. Check if you really need to change these placeholders. If not, revert your changes. - * 2. Write a database migration for the old placeholder JSON strings, such that they match your new signature. - * 3. Increment the {{@link Constants#PUSH_NOTIFICATION_VERSION}}. This ensures that old versions of the native apps discard your new + * 2a. In case of breaking changes, increment the {{@link Constants#PUSH_NOTIFICATION_VERSION}}. This ensures that old versions of the native apps discard your new * notifications. - * 4. Update both the Android and iOS app. Only merge this server PR after they have been updated and released to the stores. Otherwise, notifications no longer work for + * 2b. In case of non-breaking changes, increment the {{@link Constants#PUSH_NOTIFICATION_MINOR_VERSION}} for better traceability + * 3. Update both the Android and iOS app. Only merge this server PR after they have been updated and released to the stores. Otherwise, notifications no longer work for * end users. - * 5. Execute the Gradle task generatePlaceholderRevisionSignatures to make this test pass again. + * 4. Execute the Gradle task generatePlaceholderRevisionSignatures to make this test pass again. */ @Test void testSignatureHasNotChanged() throws URISyntaxException, IOException { diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationServiceTest.java index 347438c89a97..e30b73f91e5b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationServiceTest.java @@ -215,6 +215,7 @@ void setUp() { channel.setCreationDate(ZonedDateTime.now()); post = new Post(); + post.setId(1L); post.setAuthor(userTwo); post.setConversation(channel); post.setTitle(POST_TITLE); @@ -223,7 +224,9 @@ void setUp() { Post answerPostPost = new Post(); answerPostPost.setConversation(channel); answerPostPost.setAuthor(userTwo); + answerPostPost.setId(2L); answerPost = new AnswerPost(); + answerPost.setId(1L); answerPost.setPost(answerPostPost); answerPost.setAuthor(userThree); answerPost.setContent(ANSWER_POST_CONTENT); @@ -464,11 +467,13 @@ void testConversationNotificationsChannel(NotificationType notificationType, Str @Test void testConversationNotificationsNewMessageReply() { Post post = new Post(); + post.setId(1L); post.setAuthor(user); post.setCreationDate(ZonedDateTime.now()); post.setConversation(groupChat); AnswerPost answerPost = new AnswerPost(); + answerPost.setId(1L); answerPost.setAuthor(userTwo); answerPost.setCreationDate(ZonedDateTime.now().plusSeconds(5)); answerPost.setPost(post); diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/push_notifications/AppleFirebasePushNotificationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/push_notifications/AppleFirebasePushNotificationServiceTest.java index 40ec1dd07e09..ced8575aa4e4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/push_notifications/AppleFirebasePushNotificationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/push_notifications/AppleFirebasePushNotificationServiceTest.java @@ -28,6 +28,7 @@ import de.tum.cit.aet.artemis.communication.domain.notification.GroupNotification; import de.tum.cit.aet.artemis.communication.domain.notification.Notification; import de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants; +import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationApiType; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceConfiguration; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceType; import de.tum.cit.aet.artemis.communication.repository.PushNotificationDeviceConfigurationRepository; @@ -70,9 +71,9 @@ void setUp() { String token = "test"; byte[] payload = HexFormat.of().parseHex("e04fd020ea3a6910a2d808002b30309d"); PushNotificationDeviceConfiguration applePushNotificationDeviceConfiguration = new PushNotificationDeviceConfiguration(token, PushNotificationDeviceType.APNS, new Date(), - payload, student); + payload, student, PushNotificationApiType.IOS_V2); PushNotificationDeviceConfiguration firebasePushNotificationDeviceConfiguration = new PushNotificationDeviceConfiguration(token, PushNotificationDeviceType.FIREBASE, - new Date(), payload, student); + new Date(), payload, student, PushNotificationApiType.DEFAULT); when(repositoryMock.findByUserIn(anySet(), eq(PushNotificationDeviceType.APNS))).thenReturn(Collections.singletonList(applePushNotificationDeviceConfiguration)); when(repositoryMock.findByUserIn(anySet(), eq(PushNotificationDeviceType.FIREBASE))).thenReturn(Collections.singletonList(firebasePushNotificationDeviceConfiguration)); diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/service/PushNotificationDeviceConfigurationCleanupServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/service/PushNotificationDeviceConfigurationCleanupServiceTest.java index c8b142c4dc59..33cb896a8d37 100644 --- a/src/test/java/de/tum/cit/aet/artemis/communication/service/PushNotificationDeviceConfigurationCleanupServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/service/PushNotificationDeviceConfigurationCleanupServiceTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationApiType; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceConfiguration; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceType; import de.tum.cit.aet.artemis.communication.repository.PushNotificationDeviceConfigurationRepository; @@ -41,10 +42,10 @@ void setupUser() { @Test void cleanupTest() { final PushNotificationDeviceConfiguration valid = new PushNotificationDeviceConfiguration("token1", PushNotificationDeviceType.FIREBASE, - Date.from(Instant.now().plus(10, ChronoUnit.DAYS)), new byte[10], user); + Date.from(Instant.now().plus(10, ChronoUnit.DAYS)), new byte[10], user, PushNotificationApiType.DEFAULT); final PushNotificationDeviceConfiguration expired = new PushNotificationDeviceConfiguration("token2", PushNotificationDeviceType.FIREBASE, - Date.from(Instant.now().minus(10, ChronoUnit.DAYS)), new byte[10], user); + Date.from(Instant.now().minus(10, ChronoUnit.DAYS)), new byte[10], user, PushNotificationApiType.DEFAULT); deviceConfigurationRepository.save(valid); deviceConfigurationRepository.save(expired); diff --git a/src/test/resources/placeholder-signatures.json b/src/test/resources/placeholder-signatures.json index 49fb7814743f..5e06e3b26080 100644 --- a/src/test/resources/placeholder-signatures.json +++ b/src/test/resources/placeholder-signatures.json @@ -75,6 +75,15 @@ }, { "fieldName" : "conversationType", "fieldType" : "java.lang.String" + }, { + "fieldName" : "imageUrl", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "userId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "postId", + "fieldType" : "java.lang.String" } ] }, { "notificationType" : "CONVERSATION_NEW_REPLY_MESSAGE", @@ -102,6 +111,18 @@ }, { "fieldName" : "conversationName", "fieldType" : "java.lang.String" + }, { + "fieldName" : "imageUrl", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "userId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "postingId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "parentPostId", + "fieldType" : "java.lang.String" } ] }, { "notificationType" : "CONVERSATION_REMOVE_USER_CHANNEL", @@ -150,6 +171,18 @@ }, { "fieldName" : "conversationName", "fieldType" : "java.lang.String" + }, { + "fieldName" : "imageUrl", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "userId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "postingId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "parentPostId", + "fieldType" : "java.lang.String" } ] }, { "notificationType" : "COURSE_ARCHIVE_FAILED", @@ -297,6 +330,15 @@ }, { "fieldName" : "postAuthorName", "fieldType" : "java.lang.String" + }, { + "fieldName" : "imageUrl", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "authorId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "postId", + "fieldType" : "java.lang.String" } ] }, { "notificationType" : "NEW_CPC_PLAGIARISM_CASE_STUDENT", @@ -357,6 +399,18 @@ }, { "fieldName" : "conversationName", "fieldType" : "java.lang.String" + }, { + "fieldName" : "imageUrl", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "userId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "postingId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "parentPostId", + "fieldType" : "java.lang.String" } ] }, { "notificationType" : "NEW_REPLY_FOR_EXAM_POST", @@ -384,6 +438,18 @@ }, { "fieldName" : "conversationName", "fieldType" : "java.lang.String" + }, { + "fieldName" : "imageUrl", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "userId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "postingId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "parentPostId", + "fieldType" : "java.lang.String" } ] }, { "notificationType" : "NEW_REPLY_FOR_EXERCISE_POST", @@ -411,6 +477,18 @@ }, { "fieldName" : "conversationName", "fieldType" : "java.lang.String" + }, { + "fieldName" : "imageUrl", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "userId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "postingId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "parentPostId", + "fieldType" : "java.lang.String" } ] }, { "notificationType" : "NEW_REPLY_FOR_LECTURE_POST", @@ -438,6 +516,18 @@ }, { "fieldName" : "conversationName", "fieldType" : "java.lang.String" + }, { + "fieldName" : "imageUrl", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "userId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "postingId", + "fieldType" : "java.lang.String" + }, { + "fieldName" : "parentPostId", + "fieldType" : "java.lang.String" } ] }, { "notificationType" : "PLAGIARISM_CASE_VERDICT_STUDENT",