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 {
}
}
else {
Message changedSubject = roomHistory.getChangedSubject();
boolean addChangedSubject = (changedSubject != null) ? true : false;
if (getMaxChars() == 0) {
// The user requested to receive no history
if (addChangedSubject) {
joinRole.send(changedSubject);
}
return;
}
Message message;
......@@ -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);
}
// Check if we should add the latest subject change.
if (addChangedSubject) {
historyToSend.addFirst(changedSubject);
}
// Send the smallest amount of traffic to the user
for (Object aHistoryToSend : historyToSend) {
joinRole.send((Message) aHistoryToSend);
......
......@@ -305,6 +305,16 @@ public class HistoryStrategy {
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> {
public int compare(Message o1, Message o2) {
String stamp1 = o1.getChildElement("x", "jabber:x:delay").attributeValue("stamp");
......
......@@ -195,4 +195,14 @@ public final class MUCRoomHistory {
public boolean 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