From 0801b279a4fe91c8cb1d653676f43dfe6c26a6f2 Mon Sep 17 00:00:00 2001 From: Shinryuken Date: Tue, 7 Nov 2017 19:15:02 +0100 Subject: User defaults when no User is available - EventForwarder refactoring --- src/org/traccar/notification/NotificationFormatter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/notification/NotificationFormatter.java') diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java index 591f848d4..bd919cce0 100644 --- a/src/org/traccar/notification/NotificationFormatter.java +++ b/src/org/traccar/notification/NotificationFormatter.java @@ -39,16 +39,16 @@ public final class NotificationFormatter { private NotificationFormatter() { } - public static VelocityContext prepareContext(Long userIdreq, Event event, Position position) { - - long userId = userIdreq != null ? userIdreq : (Long) Context.getPermissionsManager() - .getDeviceUsers(event.getDeviceId()).toArray()[0]; + public static VelocityContext prepareContext(Long userId, Event event, Position position) { User user = Context.getPermissionsManager().getUser(userId); Device device = Context.getIdentityManager().getById(event.getDeviceId()); VelocityContext velocityContext = new VelocityContext(); - velocityContext.put("user", user); + + if (user != null) { + velocityContext.put("user", user); + } velocityContext.put("device", device); velocityContext.put("event", event); if (position != null) { -- cgit v1.2.3