use of io.lumeer.engine.api.event.RemoveUser in project engine by Lumeer.
the class PusherFacade method createRemoveUserNotification.
public void createRemoveUserNotification(@Observes final RemoveUser removeUser) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(removeUser.getOrganizationId());
ResourceId resourceId = new ResourceId(getAppId(), removeUser.getUser().getId(), organization.getId());
String className = removeUser.getUser().getClass().getSimpleName();
Set<String> users = resourceAdapter.getOrganizationReaders(organization);
List<Event> events = users.stream().map(userId -> createEventForRemove(className, resourceId, userId)).collect(Collectors.toList());
sendNotificationsBatch(events);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
use of io.lumeer.engine.api.event.RemoveUser in project engine by Lumeer.
the class UserFacade method deleteUser.
public void deleteUser(String organizationId, String userId) {
checkOrganizationPermissions(organizationId, RoleType.UserConfig);
groupDao.setOrganization(getOrganization());
groupDao.deleteUserFromGroups(userId);
User storedUser = userDao.getUserById(userId);
var organizations = new HashSet<>(storedUser.getOrganizations());
organizations.remove(organizationId);
storedUser.setOrganizations(organizations);
storedUser = userDao.updateUser(userId, storedUser);
if (removeUserEvent != null) {
removeUserEvent.fire(new RemoveUser(organizationId, storedUser));
}
userCache.updateUser(storedUser.getEmail(), storedUser);
}
Aggregations