Commit 6c67e99e authored by Dave Cridland's avatar Dave Cridland Committed by daryl herzmann

OF-1061 Always send room subject after history (#702)

This change means that room subject changes are no longer held within the
history transcript, but instead are always sent in a distinct action afterward.

Although this means that repeated changes will not be replayed in history, this
seems to be normal behaviour on other servers, and simplified the history replay
code considerably.
parent de1344ff
......@@ -143,13 +143,8 @@ 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;
}
int accumulatedChars = 0;
......@@ -201,19 +196,8 @@ 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);
......
......@@ -185,14 +185,11 @@ public class HistoryStrategy {
boolean subjectChange = isSubjectChangeRequest(packet);
if (subjectChange) {
roomSubject = packet;
return;
}
// store message according to active strategy
if (strategyType == Type.none && subjectChange) {
history.clear();
history.add(packet);
}
else if (strategyType == Type.all || subjectChange) {
if (strategyType == Type.all) {
history.add(packet);
}
else if (strategyType == Type.number) {
......
......@@ -721,6 +721,10 @@ public class LocalMUCRoom implements MUCRoom, GroupEventListener {
else {
historyRequest.sendHistory(joinRole, roomHistory);
}
Message roomSubject = roomHistory.getChangedSubject();
if (roomSubject != null) {
joinRole.send(roomSubject);
}
if (!clientOnlyJoin) {
// Update the date when the last occupant left the room
setEmptyDate(null);
......
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