Commit 7bda1c76 authored by Günther Niess's avatar Günther Niess Committed by niess

OF-55: Send room's subject regardless any user side history limits

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11366 b35dd754-fafc-0310-a699-88a17e54d16e
parent a0bda201
...@@ -148,8 +148,13 @@ public class HistoryRequest { ...@@ -148,8 +148,13 @@ public class HistoryRequest {
} }
} }
else { else {
Message changedSubject = roomHistory.getChangedSubject();
boolean addChangedSubject = (changedSubject != null) ? true : false;
if (getMaxChars() == 0) { if (getMaxChars() == 0) {
// The user requested to receive no history // The user requested to receive no history
if (addChangedSubject) {
joinRole.send(changedSubject);
}
return; return;
} }
Message message; Message message;
...@@ -206,8 +211,19 @@ public class HistoryRequest { ...@@ -206,8 +211,19 @@ public class HistoryRequest {
} }
// Don't add the latest subject change if it's already in the history.
if (addChangedSubject) {
if (changedSubject != null && changedSubject.equals(message)) {
addChangedSubject = false;
}
}
historyToSend.addFirst(message); historyToSend.addFirst(message);
} }
// Check if we should add the latest subject change.
if (addChangedSubject) {
historyToSend.addFirst(changedSubject);
}
// Send the smallest amount of traffic to the user // Send the smallest amount of traffic to the user
for (Object aHistoryToSend : historyToSend) { for (Object aHistoryToSend : historyToSend) {
joinRole.send((Message) aHistoryToSend); joinRole.send((Message) aHistoryToSend);
......
...@@ -305,6 +305,16 @@ public class HistoryStrategy { ...@@ -305,6 +305,16 @@ public class HistoryStrategy {
return roomSubject != null; return roomSubject != null;
} }
/**
* Returns the message within the history of the room that has changed the
* room's subject.
*
* @return the latest room subject change or null if none exists yet.
*/
public Message getChangedSubject() {
return roomSubject;
}
private static class MessageComparator implements Comparator<Message> { private static class MessageComparator implements Comparator<Message> {
public int compare(Message o1, Message o2) { public int compare(Message o1, Message o2) {
String stamp1 = o1.getChildElement("x", "jabber:x:delay").attributeValue("stamp"); String stamp1 = o1.getChildElement("x", "jabber:x:delay").attributeValue("stamp");
......
...@@ -195,4 +195,14 @@ public final class MUCRoomHistory { ...@@ -195,4 +195,14 @@ public final class MUCRoomHistory {
public boolean hasChangedSubject() { public boolean hasChangedSubject() {
return historyStrategy.hasChangedSubject(); return historyStrategy.hasChangedSubject();
} }
/**
* Returns the message within the history of the room that has changed the
* room's subject.
*
* @return the latest room subject change or null if none exists yet.
*/
public Message getChangedSubject() {
return historyStrategy.getChangedSubject();
}
} }
\ No newline at end of file
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