Skip to content

Messages: offer each account only what Spring lets it do - #2082

Closed
svaka2000 wants to merge 6 commits into
Open-Coding-Society:mainfrom
svaka2000:feat/messages-mentors
Closed

svaka2000 wants to merge 6 commits into
Open-Coding-Society:mainfrom
svaka2000:feat/messages-mentors

Conversation

@svaka2000

@svaka2000 svaka2000 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Messages now only offers an account what Spring lets it do. For a mentor, that means no direct messages, no finding or making groups, and no adding or removing members.

A mentor's /dm: only their team group, and the Direct messages list says it's off
A student's New chat: searching "Mentor" offers no one
Members marks the mentor

  • A new Allowances class (allowances.js) follows Spring's rules: an account with ROLE_MENTOR and no teacher or admin role only talks in groups it's been added to.
  • For that account, /dm hides New chat and Find or make, and Members has no Remove or add search. Its groups and unread counts stay, so a mentor still gets the team group's alerts.
  • An empty Direct messages list says direct messages are off, and Leave says a member can add them back. Older direct messages still open (Spring still lets them read those), and a send there says a mentor is in the chat.
  • New chat leaves out people Spring won't let anyone message, so a student isn't offered a mentor.
  • If Spring refuses a send, a new chat or a member change because of a mentor rule, the page says why instead of "try again". The UI Builder's Message us does too.
  • Members marks who is a mentor, for everyone.

How it fits with Darshan's work:

  • It reads the same ROLE_MENTOR that Darshan's Mentor Dashboard 1: hand Flask's signed mentor statement to Spring at sign-in #2050 gives at sign-in to a mentor a teacher verified. His role-view.js switches the site sidebar, and nothing here changes that.
  • No Messages file but allowances.js checks the mentor role. The page gets the answers from Allowances and passes them in, and a test reads every file and fails if one does.

Other notes:

How to try it (with Open-Coding-Society/spring#303):

  1. Sign in as a mentor and open /dm. There are only groups, and no New chat or Find or make.
  2. Sign in as a student, open New chat and search the mentor's name. They aren't offered.

A class group's members come from the classes on each student's Profile, and
spring#309 lets only teachers and admins change them through POST and DELETE
/api/groups/{id}/members/{personId}. Members now shows Add and Remove on a class
group only to them (canChangeMembers). Everyone else sees the list, without the
Action column. With the search hidden, createDialog focuses the close button, so
focus stays in the dialog. isClassGroup now trims the name before comparing, as
Spring's ClassGroupMembershipService does.
Allowances.for(me) mirrors Spring's rules for the page. Spring's
MentorRules keep an account with ROLE_MENTOR and no teacher or admin
role to its team's groups, so that account gets no New chat, no Find or
make, and no Remove or add search in Members. Its empty Direct messages
list says direct messages are off, the empty thread pane says to pick a
group, and Leave says a member can add them back. Allowances also holds
those words and shows or hides the buttons. The page passes its answers
to the shared modules, which never check the mentor role; a test fails
if one does.

New chat leaves out people Spring won't let anyone message, since
Spring refuses any direct message that includes one of them.

A refusal now carries Spring's reason with its status, uploads too. A
send, a New chat start or a member change that Spring refuses for a
mentor rule says why instead of asking to try again. Members marks the
members Spring says are mentors, and a dialog whose fields are all
hidden focuses Close.
…keeps its status

The page passed createThread two texts objects, and the later one (the
commands placeholder) replaced Allowances' words, so a mentor's empty
thread pane still offered New chat and Find a group. They're one object
now, and a test fails if a second appears.

A failed response whose body can't be read now keeps its status, with
no reason, instead of rejecting with the read error.
Spring refuses "message the owner" with mentor_no_direct_messages when
the page's owner or the visitor is a mentor. The block showed its
generic "Couldn't start a message. Try again." for that, so the visitor
kept trying. It now says a mentor would be in the message.
… check reads every module

"Add at least 2 people who aren't mentors" was wrong for a group that
already had one. It now says a group needs at least 2 members who
aren't mentors before it can have a mentor.

The test that keeps the mentor role out of shared code read 5 of the
42 modules. It now reads every one but allowances.js.
…roup rule

Open-Coding-Society#2088 hides Members' Action column on a class group for anyone who isn't
a teacher or admin, so the dialog now toggles the column's header, and
the tests give it one. A student no longer gets Add in a class group, so
the class-group refusal test opens the dialog as a teacher.
@svaka2000

Copy link
Copy Markdown
Contributor Author

Combined into #2091 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