Search in sources :

Example 1 with RolesDifference

use of io.lumeer.api.model.RolesDifference in project engine by Lumeer.

the class PusherFacade method checkProjectPermissionsChange.

private void checkProjectPermissionsChange(final Project originalProject, final Project updatedProject) {
    RolesDifference rolesDifference = permissionAdapter.getProjectReadersDifference(getOrganization(), originalProject, updatedProject);
    Set<String> removedUsers = new HashSet<>(rolesDifference.getRemovedUsers());
    removedUsers.remove(getCurrentUserId());
    if (!removedUsers.isEmpty()) {
        sendNotificationsByUsers(updatedProject, removedUsers, REMOVE_EVENT_SUFFIX);
    }
}
Also used : RolesDifference(io.lumeer.api.model.RolesDifference) HashSet(java.util.HashSet)

Example 2 with RolesDifference

use of io.lumeer.api.model.RolesDifference in project engine by Lumeer.

the class UserNotificationFacade method checkResourcesNotifications.

private void checkResourcesNotifications(final Resource originalResource, final Resource currentResource) {
    if (originalResource == null || currentResource == null) {
        return;
    }
    final RolesDifference resourceReadersDifference = permissionsChecker.getPermissionAdapter().getResourceReadersDifference(getOrganization(), getProject(), originalResource, currentResource);
    final Set<String> removedUsers = new HashSet<>(resourceReadersDifference.getRemovedUsers());
    removedUsers.remove(getCurrentUserId());
    mutedUsers.forEach(removedUsers::remove);
    if (removedUsers.size() > 0) {
        removeNotifications(currentResource, removedUsers);
    }
    final Set<String> addedUsers = new HashSet<>(resourceReadersDifference.getAddedUsers());
    addedUsers.remove(getCurrentUserId());
    mutedUsers.forEach(addedUsers::remove);
    if (addedUsers.size() > 0) {
        createResourceSharedNotifications(currentResource, addedUsers);
        sendResourceSharedEmails(currentResource, addedUsers);
    }
}
Also used : RolesDifference(io.lumeer.api.model.RolesDifference) HashSet(java.util.HashSet)

Example 3 with RolesDifference

use of io.lumeer.api.model.RolesDifference in project engine by Lumeer.

the class PusherFacade method checkOrganizationPermissionsChange.

private void checkOrganizationPermissionsChange(final Organization originalOrganization, final Organization updatedOrganization) {
    RolesDifference rolesDifference = permissionAdapter.getOrganizationReadersDifference(originalOrganization, updatedOrganization);
    Set<String> removedUsers = new HashSet<>(rolesDifference.getRemovedUsers());
    removedUsers.remove(getCurrentUserId());
    if (!removedUsers.isEmpty()) {
        sendNotificationsByUsers(updatedOrganization, removedUsers, REMOVE_EVENT_SUFFIX);
    }
}
Also used : RolesDifference(io.lumeer.api.model.RolesDifference) HashSet(java.util.HashSet)

Aggregations

RolesDifference (io.lumeer.api.model.RolesDifference)3 HashSet (java.util.HashSet)3