Bug - possible for admin to assign PM to moderator who does not have access to the PM

AI-generated summary

A bug was identified in the Discourse Assign plugin where admins can assign private messages (PMs) to moderators who lack access to those PMs, resulting in errors when moderators attempt to view them. tobiaseigen first reported the issue, noting that assignees receive notifications but cannot access the assigned content. jomaxro confirmed the reproducibility, including in restricted categories. codinghorror flagged it as an edge case, prompting sam to suggest displaying an error when assigning to users without access — especially important as the assign feature expands beyond moderators. tobiaseigen later noted recurring instances of misassigned messages causing missed follow-ups. codinghorror asked for a simple fix, leading sam to delegate to Roman. Roman submitted a PR enforcing two rules: the assignee must be permitted to assign, and must have access to the topic. An error message now appears if either condition fails, and Roman plans to further refine the user search API to exclude inaccessible users from the assign modal. The PR is pending review before merging. Roman also shared a screenshot illustrating the error state.

I have noticed what I think is a bug with the Discourse Assign - #117 plugin. It is possible for an admin to assign a PM to a moderator who does not have access to the PM. They are notified, but when they click through to see the PM they cannot see it and get an error.

The answer, it seems to me, should be to add the assignee to the message at the same time, or to display an error to the assigner to let them know the assignee is not in the message and cannot be assigned the message.

This obviously does not affect admins who can see all PMs.

5 likes

I can repro this. An assign notification is generated despite the user not having access to the PM assigned. Same issue occurs in categories with security that mods can’t access.

5 likes

Oh yeah interesting edge case what can we do here @sam?

4 likes

I think a minimum change here is to pop up an error saying moderator has no access to the PM when the admin / mod tries to assign.

This particular edge case will become much less of an edge case when we unlock “assign” to designated groups that are not mods.

4 likes

I just came across this again today - we are finding that I have assigned lots of messages to moderators who do not have access to them and hence have not been following up on them. Whoops.

2 likes

LOL can we protect against the above @sam in some simple way?

3 likes

This happened now maybe @Roman can follow it up.

5 likes

I opened a PR to enforce additional rules when trying to assign a topic:

  • The user we’re going to assign to must be able to assign.
  • The user we’re going to assign must have access to the topic.

Trying to assign to one of these users will raise an error:

I think we should also remove users without access from the assign modal results. To achieve this, I’ll have to extend the core’s user search API a little bit.

Here’s the PR:

https://github.com/discourse/discourse-assign/pull/46

I’ll find someone to review it before merging.

6 likes