Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OF-2916 and OF-2917 Add the option to control MUC history preservation #2621

3 changes: 2 additions & 1 deletion distribution/src/database/openfire_db2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ CREATE TABLE ofMucRoom (
roomPassword VARCHAR(50),
canDiscoverJID INTEGER NOT NULL,
logEnabled INTEGER NOT NULL,
preserveHistOnDel INTEGER NOT NULL,
subject VARCHAR(100),
rolesToBroadcast INTEGER NOT NULL,
useReservedNick INTEGER NOT NULL,
Expand Down Expand Up @@ -392,7 +393,7 @@ INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 34);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 35);

-- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
3 changes: 2 additions & 1 deletion distribution/src/database/openfire_hsqldb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ CREATE TABLE ofMucRoom (
roomPassword VARCHAR(50) NULL,
canDiscoverJID INTEGER NOT NULL,
logEnabled INTEGER NOT NULL,
preserveHistOnDel INTEGER NOT NULL,
subject VARCHAR(100) NULL,
rolesToBroadcast INTEGER NOT NULL,
useReservedNick INTEGER NOT NULL,
Expand Down Expand Up @@ -378,7 +379,7 @@ INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 34);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 35);

// Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
3 changes: 2 additions & 1 deletion distribution/src/database/openfire_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ CREATE TABLE ofMucRoom (
roomPassword VARCHAR(50) NULL,
canDiscoverJID TINYINT NOT NULL,
logEnabled TINYINT NOT NULL,
preserveHistOnDel TINYINT NOT NULL,
subject VARCHAR(100) NULL,
rolesToBroadcast TINYINT NOT NULL,
useReservedNick TINYINT NOT NULL,
Expand Down Expand Up @@ -368,7 +369,7 @@ INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 34);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 35);

# Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
3 changes: 2 additions & 1 deletion distribution/src/database/openfire_oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ CREATE TABLE ofMucRoom(
roomPassword VARCHAR2(50) NULL,
canDiscoverJID INTEGER NOT NULL,
logEnabled INTEGER NOT NULL,
preserveHistOnDel INTEGER NOT NULL,
subject VARCHAR2(100) NULL,
rolesToBroadcast INTEGER NOT NULL,
useReservedNick INTEGER NOT NULL,
Expand Down Expand Up @@ -376,7 +377,7 @@ INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 34);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 35);

-- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
3 changes: 2 additions & 1 deletion distribution/src/database/openfire_postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ CREATE TABLE ofMucRoom (
roomPassword VARCHAR(50) NULL,
canDiscoverJID INTEGER NOT NULL,
logEnabled INTEGER NOT NULL,
preserveHistOnDel INTEGER NOT NULL,
subject VARCHAR(100) NULL,
rolesToBroadcast INTEGER NOT NULL,
useReservedNick INTEGER NOT NULL,
Expand Down Expand Up @@ -384,7 +385,7 @@ INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 34);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 35);

-- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
3 changes: 2 additions & 1 deletion distribution/src/database/openfire_sqlserver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ CREATE TABLE ofMucRoom (
roomPassword NVARCHAR(50) NULL,
canDiscoverJID INT NOT NULL,
logEnabled INT NOT NULL,
preserveHistOnDel INT NOT NULL,
subject NVARCHAR(100) NULL,
rolesToBroadcast INT NOT NULL,
useReservedNick INT NOT NULL,
Expand Down Expand Up @@ -381,7 +382,7 @@ INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 34);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 35);

/* Entry for admin user */
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
3 changes: 2 additions & 1 deletion distribution/src/database/openfire_sybase.sql
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ CREATE TABLE ofMucRoom (
roomPassword NVARCHAR(50) NULL,
canDiscoverJID INT NOT NULL,
logEnabled INT NOT NULL,
preserveHistOnDel INT NOT NULL,
subject NVARCHAR(100) NULL,
rolesToBroadcast INT NOT NULL,
useReservedNick INT NOT NULL,
Expand Down Expand Up @@ -381,7 +382,7 @@ INSERT INTO ofID (idType, id) VALUES (23, 1)
INSERT INTO ofID (idType, id) VALUES (26, 2)
INSERT INTO ofID (idType, id) VALUES (27, 1)

INSERT INTO ofVersion (name, version) VALUES ('openfire', 34)
INSERT INTO ofVersion (name, version) VALUES ('openfire', 35)

/* Entry for admin user */
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
3 changes: 3 additions & 0 deletions distribution/src/database/upgrade/35/openfire_db2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE ofMucRoom ADD COLUMN preserveHistOnDel INTEGER DEFAULT 1 NOT NULL;

UPDATE ofVersion SET version = 35 WHERE name = 'openfire';
3 changes: 3 additions & 0 deletions distribution/src/database/upgrade/35/openfire_hsqldb.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE ofMucRoom ADD COLUMN preserveHistOnDel INTEGER DEFAULT 1 NOT NULL;

UPDATE ofVersion SET version = 35 WHERE name = 'openfire';
3 changes: 3 additions & 0 deletions distribution/src/database/upgrade/35/openfire_mysql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE ofMucRoom ADD COLUMN preserveHistOnDel TINYINT NOT NULL DEFAULT 1;

UPDATE ofVersion SET version = 35 WHERE name = 'openfire';
3 changes: 3 additions & 0 deletions distribution/src/database/upgrade/35/openfire_oracle.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE ofMucRoom ADD preserveHistOnDel INTEGER DEFAULT 1 NOT NULL;

UPDATE ofVersion SET version = 35 WHERE name = 'openfire';
3 changes: 3 additions & 0 deletions distribution/src/database/upgrade/35/openfire_postgresql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE ofMucRoom ADD COLUMN preserveHistOnDel INTEGER DEFAULT 1 NOT NULL;

UPDATE ofVersion SET version = 35 WHERE name = 'openfire';
3 changes: 3 additions & 0 deletions distribution/src/database/upgrade/35/openfire_sqlserver.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE ofMucRoom ADD preserveHistOnDel INT DEFAULT 1 NOT NULL;

UPDATE ofVersion SET version = 35 WHERE name = 'openfire';
3 changes: 3 additions & 0 deletions distribution/src/database/upgrade/35/openfire_sybase.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE ofMucRoom ADD preserveHistOnDel INT DEFAULT 1 NOT NULL;

UPDATE ofVersion SET version = 35 WHERE name = 'openfire';
3 changes: 3 additions & 0 deletions i18n/src/main/resources/openfire_i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ muc.form.conf.owner_roomsecret=Password
muc.form.conf.owner_whois=Role that May Discover Real JIDs of Occupants
muc.form.conf.anyone=Anyone
muc.form.conf.owner_enablelogging=Log Room Conversations
muc.form.conf.owner_preservehistondel=Preserve Chat History on Room Deletion
muc.form.conf.owner_reservednick=Only login with registered nickname
muc.form.conf.owner_canchangenick=Allow Occupants to change nicknames
muc.form.conf.owner_registration=Allow Users to register with the room
Expand Down Expand Up @@ -772,6 +773,7 @@ muc.default.settings.reserved_nick=Only login with registered nickname
muc.default.settings.can_change_nick=Allow Occupants to change nicknames
muc.default.settings.registration=Allow Users to register with the room
muc.default.settings.enable_logging=Log Room Conversations
muc.default.settings.preserve_hist_on_room_deletion=Preserve Chat History on Room Deletion
muc.default.settings.max_users=Maximum Room Occupants
muc.default.settings.error=Error while saving default settings.
muc.default.settings.update=Settings updated successfully.
Expand Down Expand Up @@ -892,6 +894,7 @@ muc.room.edit.form.reservednick=Only login with registered nickname
muc.room.edit.form.canchangenick=Allow Occupants to change nicknames
muc.room.edit.form.registration=Allow Users to register with the room
muc.room.edit.form.log=Log Room Conversations
muc.room.edit.form.preserve_hist_on_room_deletion=Preserve Chat History on Room Deletion
muc.room.edit.form.required_field=Required Field

# Muc room federation (FMUC) page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class SchemaManager {
/**
* Current Openfire database schema version.
*/
private static final int DATABASE_VERSION = 34;
private static final int DATABASE_VERSION = 35;

/**
* Checks the Openfire database schema to ensure that it's installed and up to date.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ public class MUCRoom implements GroupEventListener, UserEventListener, Externali
*/
private boolean logEnabled;

/**
* Enables the preservation of chat history after a room is deleted. The chat history logged
* when logEnabled is true will be removed, on room deletion, if this is false.
*/
private boolean preserveHistOnRoomDeletion;

/**
* Enables the logging of the conversation. The conversation in the room will be saved to the
* database.
Expand Down Expand Up @@ -369,6 +375,7 @@ public MUCRoom(@Nonnull MultiUserChatService chatService, @Nonnull String roomNa
this.canOccupantsInvite = MUCPersistenceManager.getBooleanProperty(mucService.getServiceName(), "room.canOccupantsInvite", false);
this.canAnyoneDiscoverJID = MUCPersistenceManager.getBooleanProperty(mucService.getServiceName(), "room.canAnyoneDiscoverJID", true);
this.logEnabled = MUCPersistenceManager.getBooleanProperty(mucService.getServiceName(), "room.logEnabled", true);
this.preserveHistOnRoomDeletion = MUCPersistenceManager.getBooleanProperty(mucService.getServiceName(), "room.preserveHistOnRoomDeletion", true);
this.loginRestrictedToNickname = MUCPersistenceManager.getBooleanProperty(mucService.getServiceName(), "room.loginRestrictedToNickname", false);
this.canChangeNickname = MUCPersistenceManager.getBooleanProperty(mucService.getServiceName(), "room.canChangeNickname", true);
this.registrationEnabled = MUCPersistenceManager.getBooleanProperty(mucService.getServiceName(), "room.registrationEnabled", true);
Expand Down Expand Up @@ -3135,6 +3142,24 @@ public boolean isLogEnabled() {
return logEnabled;
}

/**
* Sets if the room's conversation will be preserved when the room is deleted.
*
* @param preserveHistOnRoomDeletion boolean that specified if the room's conversation will be preserved on deletion.
*/
public void setPreserveHistOnRoomDeletionEnabled(boolean preserveHistOnRoomDeletion) {
this.preserveHistOnRoomDeletion = preserveHistOnRoomDeletion;
}

/**
* Returns true if the room's conversation will be preserved when the room is deleted.
*
* @return true if the room's conversation is being logged.
*/
public boolean isPreserveHistOnRoomDeletionEnabled() {
return preserveHistOnRoomDeletion;
}

/**
* Sets if the room's conversation is being logged. If logging is activated the room
* conversation will be saved to the database every couple of minutes. The saving frequency is
Expand Down Expand Up @@ -3633,6 +3658,7 @@ public int getCachedSize() throws CannotCalculateSizeException {
size += CacheSizes.sizeOfBoolean(); // canAnyoneDiscoverJID
size += CacheSizes.sizeOfString(canSendPrivateMessage);
size += CacheSizes.sizeOfBoolean(); // logEnabled
size += CacheSizes.sizeOfBoolean(); // preserveHistOnRoomDeletion
size += CacheSizes.sizeOfBoolean(); // loginRestrictedToNickname
size += CacheSizes.sizeOfBoolean(); // canChangeNickname
size += CacheSizes.sizeOfBoolean(); // registrationEnabled
Expand Down Expand Up @@ -3679,6 +3705,7 @@ public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeBoolean(out, canAnyoneDiscoverJID);
ExternalizableUtil.getInstance().writeSafeUTF(out, canSendPrivateMessage);
ExternalizableUtil.getInstance().writeBoolean(out, logEnabled);
ExternalizableUtil.getInstance().writeBoolean(out, preserveHistOnRoomDeletion);
ExternalizableUtil.getInstance().writeBoolean(out, loginRestrictedToNickname);
ExternalizableUtil.getInstance().writeBoolean(out, canChangeNickname);
ExternalizableUtil.getInstance().writeBoolean(out, registrationEnabled);
Expand Down Expand Up @@ -3737,6 +3764,7 @@ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundExcept
canAnyoneDiscoverJID = ExternalizableUtil.getInstance().readBoolean(in);
canSendPrivateMessage = ExternalizableUtil.getInstance().readSafeUTF(in);
logEnabled = ExternalizableUtil.getInstance().readBoolean(in);
preserveHistOnRoomDeletion = ExternalizableUtil.getInstance().readBoolean(in);
loginRestrictedToNickname = ExternalizableUtil.getInstance().readBoolean(in);
canChangeNickname = ExternalizableUtil.getInstance().readBoolean(in);
registrationEnabled = ExternalizableUtil.getInstance().readBoolean(in);
Expand Down Expand Up @@ -3801,6 +3829,7 @@ public void updateConfiguration(MUCRoom otherRoom) {
password = otherRoom.password;
canAnyoneDiscoverJID = otherRoom.canAnyoneDiscoverJID;
logEnabled = otherRoom.logEnabled;
preserveHistOnRoomDeletion = otherRoom.preserveHistOnRoomDeletion;
loginRestrictedToNickname = otherRoom.loginRestrictedToNickname;
canChangeNickname = otherRoom.canChangeNickname;
registrationEnabled = otherRoom.registrationEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ private void processConfigurationForm(@Nonnull final DataForm completedForm, @No
room.setPublicRoom( parseFirstValueAsBoolean( field, true ) );
}

field = completedForm.getField("{http://igniterealtime.org}muc#roomconfig_preservehistondel");
if (field != null) {
final boolean newValue = parseFirstValueAsBoolean(field, true);
room.setPreserveHistOnRoomDeletionEnabled(newValue);
}

field = completedForm.getField("muc#roomconfig_persistentroom");
if (field != null) {
boolean isPersistent = parseFirstValueAsBoolean( field, true );
Expand Down Expand Up @@ -570,6 +576,10 @@ private Element generateProbeResult(Locale preferredLocale) {
LocaleUtils.getLocalizedString("muc.form.conf.owner_enablelogging", preferredLocale),
Type.boolean_type);

configurationForm.addField("{http://igniterealtime.org}muc#roomconfig_preservehistondel",
LocaleUtils.getLocalizedString("muc.form.conf.owner_preservehistondel", preferredLocale),
Type.boolean_type);

configurationForm.addField("x-muc#roomconfig_reservednick",
LocaleUtils.getLocalizedString("muc.form.conf.owner_reservednick", preferredLocale),
Type.boolean_type);
Expand Down Expand Up @@ -663,6 +673,10 @@ private Element generateProbeResult(Locale preferredLocale) {
field.clearValues();
field.addValue((room.isLogEnabled() ? "1" : "0"));

field = configurationForm.getField("{http://igniterealtime.org}muc#roomconfig_preservehistondel");
field.clearValues();
field.addValue((room.isPreserveHistOnRoomDeletionEnabled() ? "1" : "0"));

field = configurationForm.getField("x-muc#roomconfig_reservednick");
field.clearValues();
field.addValue((room.isLoginRestrictedToNickname() ? "1" : "0"));
Expand Down
Loading
Loading