aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/resource
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/api/resource')
-rw-r--r--src/main/java/org/traccar/api/resource/NotificationResource.java12
-rw-r--r--src/main/java/org/traccar/api/resource/PasswordResource.java2
-rw-r--r--src/main/java/org/traccar/api/resource/ReportResource.java4
3 files changed, 12 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/api/resource/NotificationResource.java b/src/main/java/org/traccar/api/resource/NotificationResource.java
index cf4b66fa1..2fc103e20 100644
--- a/src/main/java/org/traccar/api/resource/NotificationResource.java
+++ b/src/main/java/org/traccar/api/resource/NotificationResource.java
@@ -31,7 +31,9 @@ import org.traccar.api.ExtendedObjectResource;
import org.traccar.model.Event;
import org.traccar.model.Notification;
import org.traccar.model.Typed;
+import org.traccar.model.User;
import org.traccar.notification.MessageException;
+import org.traccar.storage.StorageException;
@Path("notifications")
@Produces(MediaType.APPLICATION_JSON)
@@ -56,10 +58,11 @@ public class NotificationResource extends ExtendedObjectResource<Notification> {
@POST
@Path("test")
- public Response testMessage() throws MessageException, InterruptedException {
+ public Response testMessage() throws MessageException, InterruptedException, StorageException {
+ User user = permissionsService.getUser(getUserId());
for (Typed method : Context.getNotificatorManager().getAllNotificatorTypes()) {
Context.getNotificatorManager()
- .getNotificator(method.getType()).sendSync(getUserId(), new Event("test", 0), null);
+ .getNotificator(method.getType()).sendSync(user, new Event("test", 0), null);
}
return Response.noContent().build();
}
@@ -67,8 +70,9 @@ public class NotificationResource extends ExtendedObjectResource<Notification> {
@POST
@Path("test/{notificator}")
public Response testMessage(@PathParam("notificator") String notificator)
- throws MessageException, InterruptedException {
- Context.getNotificatorManager().getNotificator(notificator).sendSync(getUserId(), new Event("test", 0), null);
+ throws MessageException, InterruptedException, StorageException {
+ User user = permissionsService.getUser(getUserId());
+ Context.getNotificatorManager().getNotificator(notificator).sendSync(user, new Event("test", 0), null);
return Response.noContent().build();
}
diff --git a/src/main/java/org/traccar/api/resource/PasswordResource.java b/src/main/java/org/traccar/api/resource/PasswordResource.java
index 0642ff3cc..ed7131718 100644
--- a/src/main/java/org/traccar/api/resource/PasswordResource.java
+++ b/src/main/java/org/traccar/api/resource/PasswordResource.java
@@ -55,7 +55,7 @@ public class PasswordResource extends BaseResource {
velocityContext.put("token", token);
NotificationMessage fullMessage =
TextTemplateFormatter.formatMessage(velocityContext, "passwordReset", "full");
- Context.getMailManager().sendMessage(userId, fullMessage.getSubject(), fullMessage.getBody());
+ Context.getMailManager().sendMessage(user, fullMessage.getSubject(), fullMessage.getBody());
break;
}
}
diff --git a/src/main/java/org/traccar/api/resource/ReportResource.java b/src/main/java/org/traccar/api/resource/ReportResource.java
index 96b32a4f0..3c1b8f715 100644
--- a/src/main/java/org/traccar/api/resource/ReportResource.java
+++ b/src/main/java/org/traccar/api/resource/ReportResource.java
@@ -43,6 +43,7 @@ import org.traccar.api.BaseResource;
import org.traccar.helper.LogAction;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import org.traccar.model.User;
import org.traccar.model.UserRestrictions;
import org.traccar.reports.EventsReportProvider;
import org.traccar.reports.SummaryReportProvider;
@@ -97,8 +98,9 @@ public class ReportResource extends BaseResource {
attachment.setDataHandler(new DataHandler(new ByteArrayDataSource(
stream.toByteArray(), "application/octet-stream")));
+ User user = permissionsService.getUser(userId);
Context.getMailManager().sendMessage(
- userId, "Report", "The report is in the attachment.", attachment);
+ user, "Report", "The report is in the attachment.", attachment);
} catch (StorageException | IOException | MessagingException e) {
LOGGER.warn("Report failed", e);
}