Package org.sakaiproject.profile2.logic
Interface ProfileMessagingLogic
-
public interface ProfileMessagingLogicAn interface for dealing with messaging in Profile2- Author:
- Steve Swinsburg (steve.swinsburg@gmail.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetAllUnreadMessagesCount(String userId)Get the number of all unread messages for this user, across all all message threads.MessagegetMessage(String id)Gets a Message from the databaseMessageParticipantgetMessageParticipant(String messageId, String userUuid)Get a MessageParticipant recordList<Message>getMessagesInThread(String threadId)Gets a list of the messages contained in this thread, sorted by date posted.intgetMessagesInThreadCount(String threadId)Gets the count of the messages in a threadMessageThreadgetMessageThread(String threadId)Gets a MessageThread, first gets the item, then injects the latest Message into it before returning TODO This needs to be optimised to get the latest message property in the same query.List<MessageThread>getMessageThreads(String userId)Gets a list of MessageThreads with messages to a given user, each containing the most recent messages in each thread TODO This needs to be optimised to get the latest message property in the same query.intgetMessageThreadsCount(String userId)Gets the count of the message threads for a userintgetSentMessagesCount(String userId)Get the number of all messages sent from this userList<String>getThreadParticipants(String threadId)Get a list of all participants in a threadStringgetThreadSubject(String threadId)Get the subject of a threadintgetThreadsWithUnreadMessagesCount(String userId)Get the number of threads with unread messages.booleanisThreadParticipant(String threadId, String userId)Is the user a participant in this thread?MessagereplyToThread(String threadId, String reply, String userId)Sends a reply to a thread, returns the Message just sentbooleansendNewMessage(String uuidTo, String uuidFrom, String threadId, String subject, String messageStr)Send a messagebooleantoggleMessageRead(MessageParticipant participant, boolean status)Toggle a single message as read/unread
-
-
-
Method Detail
-
getAllUnreadMessagesCount
int getAllUnreadMessagesCount(String userId)
Get the number of all unread messages for this user, across all all message threads.- Parameters:
userId- uuid of the user to retrieve the count for
-
getThreadsWithUnreadMessagesCount
int getThreadsWithUnreadMessagesCount(String userId)
Get the number of threads with unread messages.For instance, if a user has two message threads, each with one unread message in each thread, this will return 2, as expected.
However, if a user has two message threads, each with 5 unread messages in each thread, this will return 2, not 10.
This is because we are interested in the number of threads with unread messages not the total unread messages. SeeProfileLogic#getAllUnreadMessagesCount(String)if you want that instead.- Parameters:
userId- uuid of the user to retrieve the count for- Returns:
-
getSentMessagesCount
int getSentMessagesCount(String userId)
Get the number of all messages sent from this user- Parameters:
userId- uuid of the user to retrieve the count for- Returns:
-
getMessageThread
MessageThread getMessageThread(String threadId)
Gets a MessageThread, first gets the item, then injects the latest Message into it before returning TODO This needs to be optimised to get the latest message property in the same query.- Parameters:
id- id of the thread- Returns:
-
getMessageThreads
List<MessageThread> getMessageThreads(String userId)
Gets a list of MessageThreads with messages to a given user, each containing the most recent messages in each thread TODO This needs to be optimised to get the latest message property in the same query.- Parameters:
userId- user to get the list of messages for- Returns:
-
getMessageThreadsCount
int getMessageThreadsCount(String userId)
Gets the count of the message threads for a user- Parameters:
userId- user to get the count of message threads for- Returns:
-
getMessagesInThread
List<Message> getMessagesInThread(String threadId)
Gets a list of the messages contained in this thread, sorted by date posted.- Parameters:
threadId- id of the thread to get the messages for- Returns:
-
getMessagesInThreadCount
int getMessagesInThreadCount(String threadId)
Gets the count of the messages in a thread- Parameters:
threadId- thread to get the count for- Returns:
-
getMessage
Message getMessage(String id)
Gets a Message from the database- Parameters:
id- id of the message- Returns:
-
sendNewMessage
boolean sendNewMessage(String uuidTo, String uuidFrom, String threadId, String subject, String messageStr)
Send a messageTODO this should be optimised for foreign key constraints
- Parameters:
uuidTo- uuid of recipientuuidFrom- uuid of senderthreadId- threadId, a uuid that should be generated via {@link ProfileUtils.generateUuid()}subject- message subjectmessageStr- message body- Returns:
-
replyToThread
Message replyToThread(String threadId, String reply, String userId)
Sends a reply to a thread, returns the Message just sent- Parameters:
threadId- id of the threadreply- the messageuserId- uuid of user who is sending the message- Returns:
-
toggleMessageRead
boolean toggleMessageRead(MessageParticipant participant, boolean status)
Toggle a single message as read/unread- Parameters:
participant- the MessageParticipant record as this is the item that stores read/unread statusstatus- boolean if to be toggled as read/unread- Returns:
-
getMessageParticipant
MessageParticipant getMessageParticipant(String messageId, String userUuid)
Get a MessageParticipant record- Parameters:
messageId- message id to get the record foruserUuid- uuid to get the record for- Returns:
-
getThreadParticipants
List<String> getThreadParticipants(String threadId)
Get a list of all participants in a thread- Parameters:
threadId- id of the thread- Returns:
-
isThreadParticipant
boolean isThreadParticipant(String threadId, String userId)
Is the user a participant in this thread?- Parameters:
threadId- id of the threaduserId- id of the user- Returns:
-
-