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 { ...@@ -143,13 +143,8 @@ 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;
} }
int accumulatedChars = 0; int accumulatedChars = 0;
...@@ -201,19 +196,8 @@ public class HistoryRequest { ...@@ -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); 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);
......
...@@ -185,14 +185,11 @@ public class HistoryStrategy { ...@@ -185,14 +185,11 @@ public class HistoryStrategy {
boolean subjectChange = isSubjectChangeRequest(packet); boolean subjectChange = isSubjectChangeRequest(packet);
if (subjectChange) { if (subjectChange) {
roomSubject = packet; roomSubject = packet;
return;
} }
// store message according to active strategy // store message according to active strategy
if (strategyType == Type.none && subjectChange) { if (strategyType == Type.all) {
history.clear();
history.add(packet);
}
else if (strategyType == Type.all || subjectChange) {
history.add(packet); history.add(packet);
} }
else if (strategyType == Type.number) { else if (strategyType == Type.number) {
......
...@@ -721,6 +721,10 @@ public class LocalMUCRoom implements MUCRoom, GroupEventListener { ...@@ -721,6 +721,10 @@ public class LocalMUCRoom implements MUCRoom, GroupEventListener {
else { else {
historyRequest.sendHistory(joinRole, roomHistory); historyRequest.sendHistory(joinRole, roomHistory);
} }
Message roomSubject = roomHistory.getChangedSubject();
if (roomSubject != null) {
joinRole.send(roomSubject);
}
if (!clientOnlyJoin) { if (!clientOnlyJoin) {
// Update the date when the last occupant left the room // Update the date when the last occupant left the room
setEmptyDate(null); 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