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

Merged
merged 26 commits into from
Dec 19, 2024

Conversation

hqv126
Copy link
Contributor

@hqv126 hqv126 commented Nov 29, 2024

No description provided.

Copy link
Member

@guusdk guusdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I've left a bunch of suggestions. Most of them are pretty minor, but I believe some others are more important.

“Huy and others added 26 commits December 19, 2024 15:20
Add the string properties for the new clear chat history feature.
Add a new chat history command to the left-hand side admin bar.
Add a confirmation page before clearing chat history for a room.
Update the edit form to redirect users there after clearing the room’s chat history.
Add a function to clear chat history from a room by sending retraction messages. Do not store these messages, as they will be cleared immediately.
Add a function to clear chat history from the database.
Only chat messages should be cleared, not messages that update a room’s topic.
Changes from PR review

1. Add the chatManagement.bulkMsgRetractionEnabled configuration to allow administrators to skip sending bulk retraction messages.
2. Make the MucRoom.clearChatHistory() method asynchronous, as it can be a long-running process.
3. Iterate over the history from the end, sending a revocation for the most recently received message first. This message is much more likely to be currently displayed in a connected client than the oldest message in a chatroom.
4. Add a translatable muc.room.clear_chat.retraction_fallback_msg string.
Fix the error in setting room.setSavedToDB(false) when clearing chat history.
Changes from PR review

1. Updated copyright text to exclude Jive Software.
2. Improved webManager logging to include the full address of the room.
3. Added logging to indicate the before and after states of the asynchronous clear chat history process.
An improvement to SequenceManager has been made to better support its usage in plugins like the Monitoring plugin.

To use SequenceManager to keep track of and generate new unique IDs, an explicit type number is required. One way to achieve this is to assign a JiveID to a class that uses SequenceManager, e.g. @JiveID(604). However, there is potential for undetected ID clashes if IDs are explicitly assigned in more than one plugin.
This commit proposes a solution that uses unique names to assign a unique SequenceManager type. To obtain a SequenceManager for the roomIDs in the Monitoring plugin, you simply need to call:
SequenceManager.getSequenceManagerByUniqueName("Monitoring Plugin - RoomID").

These changes support fixes for issues igniterealtime#369 and igniterealtime#370 in the Monitoring plugin.
Add the event dispatcher code for roomClearChatHistory events. This change supports fixes for issues igniterealtime/openfire-monitoring-plugin#369 and igniterealtime/openfire-monitoring-plugin#370 in the Monitoring plugin.
Add a method to dispatcher roomClearChatHistory events. This change supports fixes for issues igniterealtime/openfire-monitoring-plugin#369 and igniterealtime/openfire-monitoring-plugin#370 in the Monitoring plugin.
Support dispatching roomClearChatHistory events in the following scenarios:
1. When a clear chat room history command is issued. (Fixes issue igniterealtime#369 in the monitoring plugin.)
2. When a chat room is destroyed and its chat history is not preserved. (Fixes issue igniterealtime#370 in the monitoring plugin.)
Implement the roomClearChatHistory event handler. Nothing is needed to be done in the OccupantManager for this event.
These files should remain unchanged after PR review feedback.
Add roomJID to exception log. Existing exception messages don’t log roomJID or other useful information, the same change can be applied for them in a separate PR.
- Changed `BULK_MSG_RETRACTION_ENABLED` to a `SystemProperty` with key `xmpp.muc.bulkretraction`, and default value `false`.
- Updated the `clearChatHistory` method to use the new `SystemProperty` for checking if bulk message retraction is enabled.
- Modified event dispatching in `destroyRoom` method to use `getJID()` instead of `getSelfRepresentation().getOccupantJID()` as recommended in PR feedback.
Removed unnecessary security log event.
Modified event dispatching in `clearChatHistory` method to use `getJID()` instead of `getSelfRepresentation().getOccupantJID()` as recommended in PR feedback.
Adding system_property.xmpp.muc.bulkretraction.
Correct system_property.xmpp.muc.bulkretraction.enabled to system_property.xmpp.muc.bulkretraction
Add an Issue369and370 class handle the migration of data for the monitoring plugin to obtain roomIDs so chat history can be cleared.
- Improved class description for Issue369and370.
- Changed some logging to the more appropriate debug level.
- Avoid out-of-memory issues by optimising SQL queries and resultset usage.
Remove redundant and misplaced pstmt.setFetchSize(…) and pstmt.setFetchDirection(…) calls.
Removed the code for generating room IDs for monitoring plugin tables. This functionality will now be handled by the monitoring plugin itself.
This adds a few non-functional changes:
- Updated copyright notices
- Removed unused import statement
- Moved some JSP scriptlets to JSTL
@guusdk guusdk force-pushed the OF-2918_Clear-MUC-chat-history branch from 036452e to fcf142c Compare December 19, 2024 14:44
@guusdk
Copy link
Member

guusdk commented Dec 19, 2024

I've added a couple of minor tweaks and rebased this PR.

@guusdk guusdk merged commit 683873d into igniterealtime:main Dec 19, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants