Conversation
Dokploy Preview Deployment
|
There was a problem hiding this comment.
Pull Request Overview
This PR implements a custom hate speech and profanity filter system to replace the bad-words library, adding client-side and server-side validation for ACARS messages and chat. It also includes improvements to chat user presence tracking and message handling.
- Replaced
bad-wordslibrary with custom hate speech/profanity filtering using regex patterns - Added validation to ACARS contact messages with UI feedback when content violates guidelines
- Enhanced chat sidebar with better presence tracking, automod reason display, and improved mention suggestions UI
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/hateSpeechFilter.ts | New custom filter with regex patterns for hate speech and profanity detection |
| server/utils/hateSpeechFilter.ts | Server-side implementation of the same filtering logic |
| src/components/tools/ContactAcarsSidebar.tsx | Adds content validation to ACARS messages with UI feedback |
| src/components/tools/ChatSidebar.tsx | Improves chat presence tracking and automod notifications |
| src/pages/Flights.tsx | Updates to pass station/position parameters for ACARS contact |
| src/pages/ACARS.tsx | Updates to receive and display station/position from contact requests |
| server/websockets/flightsWebsocket.ts | Adds station/position parameter handling to contact messages |
| server/websockets/chatWebsocket.ts | Improves chat presence tracking with chatOpened/chatClosed events |
| server/db/chats.ts | Replaces bad-words with custom hate speech filter and adds reason tracking |
| src/main.tsx | Adds console branding/version display |
| src/components/modals/AtisReminderModal.tsx | Adds ASCII art comment |
| eslint.config.js | Excludes hate speech filter from linting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const getDefaultMessage = () => { | ||
| const freq = frequencies.find((f) => f.type === selectedPosition); | ||
| if (freq) { | ||
| return `CONTACT ME ON ${airportIcao}_${selectedPosition} ${freq.freq}`; | ||
| } | ||
| return 'CONTACT ME ON FREQUENCY'; | ||
| }; | ||
|
|
||
| // Use useMemo to ensure consistent message evaluation | ||
| const currentMessage = useMemo(() => { | ||
| return customMessage.trim() || getDefaultMessage(); |
There was a problem hiding this comment.
The useMemo hook calls getDefaultMessage() which is a function that depends on frequencies, selectedPosition, and airportIcao, but getDefaultMessage itself is not stable (it's redefined on every render). This defeats the purpose of useMemo. Either include getDefaultMessage in the dependency array or inline the logic, or move getDefaultMessage outside the component or wrap it in useCallback.
| const getDefaultMessage = () => { | |
| const freq = frequencies.find((f) => f.type === selectedPosition); | |
| if (freq) { | |
| return `CONTACT ME ON ${airportIcao}_${selectedPosition} ${freq.freq}`; | |
| } | |
| return 'CONTACT ME ON FREQUENCY'; | |
| }; | |
| // Use useMemo to ensure consistent message evaluation | |
| const currentMessage = useMemo(() => { | |
| return customMessage.trim() || getDefaultMessage(); | |
| // Use useMemo to ensure consistent message evaluation | |
| const currentMessage = useMemo(() => { | |
| if (customMessage.trim()) { | |
| return customMessage.trim(); | |
| } | |
| const freq = frequencies.find((f) => f.type === selectedPosition); | |
| if (freq) { | |
| return `CONTACT ME ON ${airportIcao}_${selectedPosition} ${freq.freq}`; | |
| } | |
| return 'CONTACT ME ON FREQUENCY'; |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces significant improvements to the chat system, focusing on enhanced hate speech detection and automoderation, improved mention handling, and better user experience in the chat UI. The main changes include replacing the basic profanity filter with a custom hate speech filter, updating how mentions are processed and stored, providing clearer automod feedback to users, and improving chat message loading and UI responsiveness.
Chat moderation and hate speech detection:
bad-wordsprofanity filter with a custom hate speech filter (hateSpeechFilter.ts) that uses regular expressions to detect racial slurs and extremist content, and provides a specific reason for automoderation. The automod reason is now returned and displayed to the user. [1] [2] [3] [4] [5] [6]Chat mention and active user handling:
chatOpenedandchatClosedevents to more accurately track active users in a session, improving the active user indicator. [1] [2] [3] [4]Chat UI and user experience improvements:
Flights websocket (controller contact):
contactMeevent in the flights websocket now supports optionalstationandpositionfields, which are sanitized and included in both the request and emitted events, providing more context for controller/flight interactions. [1] [2] [3]Other:
These changes collectively enhance moderation accuracy, chat reliability, and the clarity of feedback provided to users.
References: