Add endpoint for getting unread notifications count
This commit is contained in:
parent
024b39b306
commit
6754d8eddb
@ -182,6 +182,17 @@ public class NotificationController extends BaseController {
|
||||
return notificationService.findNotificationsByRecipientIdAndReadStatus(user.getTenantId(), deliveryMethod, user.getId(), unreadOnly, pageLink);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Get unread notifications count (getUnreadNotificationsCount)",
|
||||
notes = "Returns unread notifications count for chosen delivery method." +
|
||||
AVAILABLE_FOR_ANY_AUTHORIZED_USER)
|
||||
@GetMapping("/notifications/unread/count")
|
||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||
public Integer getUnreadNotificationsCount(@ApiParam(value = "Delivery method", allowableValues = DELIVERY_METHOD_ALLOWABLE_VALUES)
|
||||
@RequestParam(defaultValue = "MOBILE_APP") NotificationDeliveryMethod deliveryMethod,
|
||||
@AuthenticationPrincipal SecurityUser user) {
|
||||
return notificationService.countUnreadNotificationsByRecipientId(user.getTenantId(), deliveryMethod, user.getId());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Mark notification as read (markNotificationAsRead)",
|
||||
notes = "Marks notification as read by its id." +
|
||||
AVAILABLE_FOR_ANY_AUTHORIZED_USER)
|
||||
|
||||
@ -785,6 +785,9 @@ public class NotificationApiTest extends AbstractNotificationApiTest {
|
||||
verify(firebaseService).sendMessage(eq(tenantId), eq("testCredentials"),
|
||||
eq("customerFcmToken"), eq("Title"), eq("Message"), anyMap(), eq(2));
|
||||
verifyNoMoreInteractions(firebaseService);
|
||||
|
||||
Integer unreadCount = doGet("/api/notifications/unread/count", Integer.class);
|
||||
assertThat(unreadCount).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user