Enviar notificaciones todos los usuarios
Last updated
Last updated
@Inject
AutoincrementableServices autoincrementableServices;
//Notification
@Inject
UsuarioServices usuarioServices;
@Inject
JmoordbNotificationsRepository jmoordbNotificationsRepository;
@Inject
@Push(channel = "notification")
private PushContext push;public Boolean afterSave(Boolean saved) {
try {
for (Usuario u : usuarioServices.getUsuarioList()) {
//Guardarlo en la base de datos
JmoordbNotifications jmoordbNotifications = new JmoordbNotifications();
// Usuario jmoordb_user = (Usuario) JmoordbContext.get("jmoordb_user");
jmoordbNotifications.setIdjmoordbnotifications(autoincrementableServices.getContador("jmoordbnNotifications"));
jmoordbNotifications.setUsername(u.getUsername());
jmoordbNotifications.setMessage("se creo un nuevo rol");
jmoordbNotifications.setViewed("no");
jmoordbNotifications.setDate(DateUtil.fechaActual());
jmoordbNotifications.setType("rolnuevo");
jmoordbNotificationsRepository.save(jmoordbNotifications);
}
push.send("Se creo un nuevo rol");
} catch (Exception e) {
}
return false;
}