use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorRESTService method markInboxAsUnRead.
@POST
@Path("/items/{COMMUNICATORMESSAGEID}/markasunread")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response markInboxAsUnRead(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId, @QueryParam("messageIds") List<Long> messageIds) {
UserEntity user = sessionController.getLoggedUserEntity();
CommunicatorMessageId messageId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
List<CommunicatorMessageRecipient> list = communicatorController.listCommunicatorMessageRecipientsByUserAndMessage(user, messageId, false);
for (CommunicatorMessageRecipient r : list) {
if ((messageIds != null) && (r.getCommunicatorMessage() != null)) {
if (!messageIds.isEmpty() && !messageIds.contains(r.getCommunicatorMessage().getId()))
continue;
}
communicatorController.updateRead(r, false);
}
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorRESTService method listUserUnreadCommunicatorMessagesByMessageId.
@GET
@Path("/unread/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserUnreadCommunicatorMessagesByMessageId(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) {
UserEntity user = sessionController.getLoggedUserEntity();
CommunicatorMessageId threadId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
List<CommunicatorMessage> receivedItems = communicatorController.listMessagesByMessageId(user, threadId, false);
List<CommunicatorMessageIdLabel> labels = communicatorController.listMessageIdLabelsByUserEntity(user, threadId);
List<CommunicatorMessageIdLabelRESTModel> restLabels = restModels.restLabel(labels);
CommunicatorMessageId olderThread = communicatorController.findOlderThreadId(user, threadId, CommunicatorFolderType.UNREAD, null);
CommunicatorMessageId newerThread = communicatorController.findNewerThreadId(user, threadId, CommunicatorFolderType.UNREAD, null);
return Response.ok(restModels.restThreadViewModel(receivedItems, olderThread, newerThread, restLabels)).build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorRESTService method listUserSentCommunicatorMessagesByMessageId.
@GET
@Path("/sentitems/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserSentCommunicatorMessagesByMessageId(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) {
UserEntity user = sessionController.getLoggedUserEntity();
CommunicatorMessageId threadId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
List<CommunicatorMessage> receivedItems = communicatorController.listMessagesByMessageId(user, threadId, false);
CommunicatorMessageId olderThread = communicatorController.findOlderThreadId(user, threadId, CommunicatorFolderType.SENT, null);
CommunicatorMessageId newerThread = communicatorController.findNewerThreadId(user, threadId, CommunicatorFolderType.SENT, null);
List<CommunicatorMessageIdLabel> labels = communicatorController.listMessageIdLabelsByUserEntity(user, threadId);
List<CommunicatorMessageIdLabelRESTModel> restLabels = restModels.restLabel(labels);
return Response.ok(restModels.restThreadViewModel(receivedItems, olderThread, newerThread, restLabels)).build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorRESTService method deleteReceivedMessages.
@DELETE
@Path("/items/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response deleteReceivedMessages(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) throws AuthorizationException {
UserEntity user = sessionController.getLoggedUserEntity();
CommunicatorMessageId messageId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
communicatorController.trashAllThreadMessages(user, messageId);
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorRESTService method listUserCommunicatorMessagesByMessageId.
@GET
@Path("/messages/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserCommunicatorMessagesByMessageId(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) {
UserEntity user = sessionController.getLoggedUserEntity();
CommunicatorMessageId threadId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
List<CommunicatorMessage> receivedItems = communicatorController.listMessagesByMessageId(user, threadId, false);
List<CommunicatorMessageIdLabel> labels = communicatorController.listMessageIdLabelsByUserEntity(user, threadId);
List<CommunicatorMessageIdLabelRESTModel> restLabels = restModels.restLabel(labels);
CommunicatorMessageId olderThread = communicatorController.findOlderThreadId(user, threadId, CommunicatorFolderType.INBOX, null);
CommunicatorMessageId newerThread = communicatorController.findNewerThreadId(user, threadId, CommunicatorFolderType.INBOX, null);
return Response.ok(restModels.restThreadViewModel(receivedItems, olderThread, newerThread, restLabels)).build();
}
Aggregations