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-2918 Clear MUC Chat History #2627

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e8ac57a
OF-2918: Add option to clear history for a given MUC
Nov 29, 2024
2df54ce
OF-2918: Add option to clear history for a given MUC
Nov 29, 2024
4afca51
OF-2918: Add option to clear history for a given MUC
Nov 29, 2024
7bd86d3
OF-2918: Add option to clear history for a given MUC
Nov 29, 2024
196e6ee
OF-2918: Add option to clear history for a given MUC
Nov 29, 2024
f8343f6
OF-2918: Add option to clear history for a given MUC
Nov 29, 2024
5f3573a
OF-2918: Add option to clear history for a given MUC
Dec 3, 2024
156f9ce
OF-2918: Add option to clear history for a given MUC
Dec 3, 2024
01af2dd
OF-2918: Add option to clear history for a given MUC
Dec 3, 2024
d5a9754
OF-2918: Add option to clear history for a given MUC
Dec 6, 2024
7be30bd
OF-2918: Add option to clear history for a given MUC
Dec 6, 2024
94f083d
OF-2918: Add option to clear history for a given MUC
Dec 6, 2024
4e83456
OF-2918: Add option to clear history for a given MUC
Dec 6, 2024
4ed359c
OF-2918: Add option to clear history for a given MUC
Dec 6, 2024
5d673d2
#369 and #370 Clear Chat Room History
Dec 11, 2024
4ae3b94
#369 and #370 Clear Chat Room History
Dec 11, 2024
82fc000
#369 and #370 Clear Chat Room History
Dec 11, 2024
b7f21ae
#369 and #370 Clear Chat Room History
Dec 11, 2024
c03e7e0
#369 and #370 Clear Chat Room History
Dec 11, 2024
db1bc7d
OF-2918: Add option to clear history for a given MUC
Dec 12, 2024
2e8dabf
OF-2918: Add option to clear history for a given MUC
Dec 16, 2024
9de6408
OF-2918: Add option to clear history for a given MUC
Dec 16, 2024
79f01f0
OF-2918: Add option to clear history for a given MUC
Dec 16, 2024
2c0f292
OF-2918: Add option to clear history for a given MUC
Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public class MUCPersistenceManager {
"INSERT INTO ofMucConversationLog (roomID,messageID,sender,nickname,logTime,subject,body,stanza) VALUES (?,?,?,?,?,?,?,?)";
private static final String DELETE_ROOM_HISTORY =
"DELETE FROM ofMucConversationLog WHERE roomID=?";
// Clear the chat history for a room but don't clear the messages that set the room's subject
guusdk marked this conversation as resolved.
Show resolved Hide resolved
private static final String CLEAR_ROOM_CHAT_HISTORY =
"DELETE FROM ofMucConversationLog WHERE roomID=? AND subject IS NULL";

/* Map of subdomains to their associated properties */
private static ConcurrentHashMap<String,MUCServiceProperties> propertyMaps = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -559,6 +562,39 @@ public static void deleteFromDB(MUCRoom room) {
}
}

/**
* Clears the chat history for a room
*
* @param room the room to cleaer chat history from
*/
public static void clearRoomChatFromDB(MUCRoom room) {
Log.debug("Attempting to clear the chat history of room '{}' from the database.", room.getName());

if (!room.isPersistent() || !room.wasSavedToDB()) {
return;
}
Connection con = null;
PreparedStatement pstmt = null;
boolean abortTransaction = false;
try {
con = DbConnectionManager.getTransactionConnection();
pstmt = con.prepareStatement(CLEAR_ROOM_CHAT_HISTORY);
pstmt.setLong(1, room.getID());
pstmt.executeUpdate();

// Update the room (in memory) to indicate the it's no longer in the database.
room.setSavedToDB(false);
guusdk marked this conversation as resolved.
Show resolved Hide resolved
}
catch (SQLException sqle) {
Log.error("A database error occurred while trying to delete room: {}", room.getName(), sqle);
abortTransaction = true;
}
finally {
DbConnectionManager.closeStatement(pstmt);
DbConnectionManager.closeTransactionConnection(con, abortTransaction);
}
}

/**
* Loads the name of all the rooms that are in the database.
*
Expand Down
Loading