Commit 34e487e8 authored by Daryl Herzmann's avatar Daryl Herzmann Committed by akrherz

OF-18: Be sure to log private chats via MUC


git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11230 b35dd754-fafc-0310-a699-88a17e54d16e
parent ce3e1b75
...@@ -232,6 +232,9 @@ public class ClearspaceMUCTranscriptManager implements MUCEventListener { ...@@ -232,6 +232,9 @@ public class ClearspaceMUCTranscriptManager implements MUCEventListener {
} }
} }
public void privateMessageRecieved(JID fromJID, JID toJID, Message message) {
}
public void roomSubjectChanged(JID roomJID, JID user, String newSubject) { public void roomSubjectChanged(JID roomJID, JID user, String newSubject) {
if (isClearspaceRoom(roomJID) && !isRoomOwner(roomJID, user)) { if (isClearspaceRoom(roomJID) && !isRoomOwner(roomJID, user)) {
addGroupChatEvent(ClearspaceMUCTranscriptEvent.roomSubjectChanged(roomJID, user, newSubject, addGroupChatEvent(ClearspaceMUCTranscriptEvent.roomSubjectChanged(roomJID, user, newSubject,
......
...@@ -68,6 +68,12 @@ public class MUCEventDispatcher { ...@@ -68,6 +68,12 @@ public class MUCEventDispatcher {
} }
} }
public static void privateMessageRecieved(JID toJID, JID fromJID, Message message) {
for (MUCEventListener listener : listeners) {
listener.privateMessageRecieved(toJID, fromJID, message);
}
}
public static void roomCreated(JID roomJID) { public static void roomCreated(JID roomJID) {
for (MUCEventListener listener : listeners) { for (MUCEventListener listener : listeners) {
listener.roomCreated(roomJID); listener.roomCreated(roomJID);
......
...@@ -74,6 +74,15 @@ public interface MUCEventListener { ...@@ -74,6 +74,15 @@ public interface MUCEventListener {
*/ */
void messageReceived(JID roomJID, JID user, String nickname, Message message); void messageReceived(JID roomJID, JID user, String nickname, Message message);
/**
* Event triggered when a room occupant sent a private message to another room user
*
* @param toJID the JID of who the message is to.
* @param fromJID the JID of who the message came from.
* @param message the message sent to user.
*/
void privateMessageRecieved(JID toJID, JID fromJID, Message message);
/** /**
* Event triggered when the subject of a room is changed. * Event triggered when the subject of a room is changed.
* *
......
...@@ -928,6 +928,11 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -928,6 +928,11 @@ public class LocalMUCRoom implements MUCRoom {
if (occupant != null) { if (occupant != null) {
packet.setFrom(senderRole.getRoleAddress()); packet.setFrom(senderRole.getRoleAddress());
occupant.send(packet); occupant.send(packet);
if(packet instanceof Message) {
Message message = (Message) packet;
MUCEventDispatcher.privateMessageRecieved(occupant.getUserAddress(), senderRole.getUserAddress(),
message);
}
} }
else { else {
throw new NotFoundException(); throw new NotFoundException();
......
...@@ -117,6 +117,21 @@ public class GroupConversationInterceptor implements MUCEventListener, Startable ...@@ -117,6 +117,21 @@ public class GroupConversationInterceptor implements MUCEventListener, Startable
} }
} }
public void privateMessageRecieved(JID toJID, JID fromJID, Message message) {
if(message.getBody() != null) {
if (ClusterManager.isSeniorClusterMember()) {
conversationManager.processMessage(fromJID, toJID, message.getBody(), new Date());
}
else {
ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
eventsQueue.addChatEvent(conversationManager.getConversationKey(fromJID, toJID),
ConversationEvent.chatMessageReceived(toJID, fromJID,
conversationManager.isMessageArchivingEnabled() ? message.getBody() : null,
new Date()));
}
}
}
public void roomSubjectChanged(JID roomJID, JID user, String newSubject) { public void roomSubjectChanged(JID roomJID, JID user, String newSubject) {
// Do nothing // Do nothing
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment