send different notification for partial approval

Signed-off-by: MiniDigger <admin@minidigger.me>
This commit is contained in:
MiniDigger 2021-03-13 17:52:19 +01:00
parent 0e26eed9b5
commit 53a1b288d7
4 changed files with 12 additions and 4 deletions

View File

@ -359,6 +359,7 @@ const msgs: LocaleMessageObject = {
},
project: {
reviewed: '{0} {1} has been reviewed and is approved',
reviewedPartial: '{0} {1} has been reviewed and is partially approved',
},
},
visibility: {

View File

@ -5,5 +5,6 @@ public enum NotificationType {
PROJECT_INVITE,
ORGANIZATION_INVITE,
NEW_PROJECT_VERSION,
VERSION_REVIEWED
VERSION_REVIEWED,
VERSION_REVIEWED_PARTIAL,
}

View File

@ -58,12 +58,18 @@ public class NotificationService extends HangarService {
notificationsDAO.insert(notificationTables);
}
public void notifyUsersVersionReviewed(ProjectVersionTable projectVersionTable) {
public void notifyUsersVersionReviewed(ProjectVersionTable projectVersionTable, boolean partial) {
List<NotificationTable> notificationTables = new ArrayList<>();
ProjectTable projectTable = projectsDAO.getById(projectVersionTable.getProjectId());
permissionService.getProjectMemberPermissions(projectVersionTable.getProjectId()).forEach((user, perm) -> {
if (perm.has(Permission.EditVersion)) {
notificationTables.add(new NotificationTable(user.getId(), NotificationType.VERSION_REVIEWED, null, null, new String[]{"notifications.project.reviewed", projectTable.getSlug(), projectVersionTable.getVersionString()}));
if (partial) {
notificationTables.add(new NotificationTable(user.getId(), NotificationType.VERSION_REVIEWED_PARTIAL, null, null,
new String[]{"notifications.project.reviewedPartial", projectTable.getSlug(), projectVersionTable.getVersionString()}));
} else {
notificationTables.add(new NotificationTable(user.getId(), NotificationType.VERSION_REVIEWED, null, null,
new String[]{"notifications.project.reviewed", projectTable.getSlug(), projectVersionTable.getVersionString()}));
}
}
});
notificationsDAO.insert(notificationTables);

View File

@ -98,7 +98,7 @@ public class ReviewService extends HangarService {
projectVersionReviewsDAO.insertMessage(new ProjectVersionReviewMessageTable(latestUnfinishedReview.getId(), msg.getMessage(), new JSONB(msg.getArgs()), reviewAction));
projectVersionReviewsDAO.update(latestUnfinishedReview);
ProjectVersionTable projectVersionTable = projectVersionsDAO.getProjectVersionTable(versionId);
notificationService.notifyUsersVersionReviewed(projectVersionTable);
notificationService.notifyUsersVersionReviewed(projectVersionTable, reviewAction == ReviewAction.PARTIALLY_APPROVE);
}
public void undoApproval(long versionId, ReviewMessage msg) {