use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorTrashRESTService method markTrashAsRead.
@POST
@Path("/trash/{COMMUNICATORMESSAGEID}/markasread")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response markTrashAsRead(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) {
UserEntity user = sessionController.getLoggedUserEntity();
CommunicatorMessageId messageId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
List<CommunicatorMessageRecipient> list = communicatorController.listCommunicatorMessageRecipientsByUserAndMessage(user, messageId, true);
for (CommunicatorMessageRecipient r : list) {
communicatorController.updateRead(r, true);
}
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorTrashRESTService method deleteReceivedMessages.
@PUT
@Path("/trash/{COMMUNICATORMESSAGEID}/restore")
@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.unTrashAllThreadMessages(user, messageId);
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorTrashRESTService method deleteTrashMessages.
@DELETE
@Path("/trash/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response deleteTrashMessages(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) throws AuthorizationException {
UserEntity user = sessionController.getLoggedUserEntity();
CommunicatorMessageId threadId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
communicatorController.archiveTrashedMessages(user, threadId);
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.
the class CommunicatorTrashRESTService method markTrashAsUnRead.
@POST
@Path("/trash/{COMMUNICATORMESSAGEID}/markasunread")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response markTrashAsUnRead(@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 CommunicatorController method postMessage.
public CommunicatorMessage postMessage(UserEntity sender, String category, String subject, String content, List<UserEntity> recipients) {
CommunicatorMessageId communicatorMessageId = createMessageId();
// TODO Category not existing at this point would technically indicate an invalid state
CommunicatorMessageCategory categoryEntity = persistCategory(category);
return createMessage(communicatorMessageId, sender, recipients, null, null, null, categoryEntity, subject, content, null);
}
Aggregations