Skip to content

Chat socket: drop client SENDs to every /topic destination - #295

Closed
svaka2000 wants to merge 1 commit into
Open-Coding-Society:masterfrom
svaka2000:fix/group-topic-sends
Closed

svaka2000 wants to merge 1 commit into
Open-Coding-Society:masterfrom
svaka2000:fix/group-topic-sends

Conversation

@svaka2000

Copy link
Copy Markdown
Contributor

This follows #286 and uses the same guard. A client's SEND to any /topic/... destination on the chat socket (/ws-chat) is now dropped, so group chat topics get the same rule #286 gave DM topics.

  • DirectMessageTopicGuard already dropped a client's STOMP SEND frame to /topic/dm/.... It now drops a SEND to any /topic/... destination, since the simple broker relays everything under /topic to its subscribers. That includes /topic/group/{id}.
  • I moved the /topic prefix into WebSocketBrokerConfig.BROKER_PREFIX, so the broker config and the guard use the same value.
  • Only the server publishes to /topic/.... The pages chats post group messages over REST, and the pages calendar card and Spring's group page send to /app/groups.chat (an /app destination, which is still allowed), so no client I found sends to a topic directly. The server's own group broadcasts are unchanged.

Other notes:

  • I updated the testing note in docs/group-chat-architecture.md and added a line about it under the chat socket notes in AGENTS.md.
  • I added tests that SENDs to DM, group and other /topic destinations are dropped, and that the server's own group broadcast still reaches subscribers. The full suite passes except ImportPersonPasswordTest, which needs a local .env, and PersonCapstoneApprovalRouteTest, which fails the same way on master right now.
  • I ran Spring locally, and a group chat subscriber still got a message posted over REST.

How to try it:

  1. Run ./mvnw test -Dtest='DirectMessageTopic*Test'.
  2. Run Spring and pages locally, open a course page with a chat, post as a second user, and check that it shows up live for the first.

DirectMessageTopicGuard already dropped a client's SEND to a DM topic.
It now drops a client's SEND to any destination the simple broker
handles (WebSocketBrokerConfig.BROKER_PREFIX, "/topic"), so group chat
topics get the same rule. Only the server publishes to topics: pages
send group messages over REST, and Spring's group page sends to
/app/groups.chat.

The tests cover SENDs to DM, group and other topic destinations being
dropped, and the server's own group broadcast still reaching its
subscribers.
@svaka2000

Copy link
Copy Markdown
Contributor Author

Combined into #314 with the same commits.

@svaka2000 svaka2000 closed this Nov 26, 2026
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.

1 participant