Back-end allows moderators to use merge/move posts to private message, but front-end does not

This functionality shows up when you are administrator, but not for moderators:

image

The front-end code for this is here:
https://github.com/discourse/discourse/blob/52672b9eabccb1184d85dc7f08062d5a7c18cb73/app/assets/javascripts/discourse/app/controllers/move-to-topic.js#L109-L112

Note the “this.currentUser.admin”.

However, the back-end allows for moderators (all staff) to perform this action just fine:
https://github.com/discourse/discourse/blob/5cf411c3aec01f48c26e71de5440ff4c0512c266/app/controllers/topics_controller.rb#L709-L715
https://github.com/discourse/discourse/blob/5cf411c3aec01f48c26e71de5440ff4c0512c266/app/controllers/topics_controller.rb#L737-L740
https://github.com/discourse/discourse/blob/9f73e8779d3ae7a1646473d4138a85c3660a58db/lib/guardian/topic_guardian.rb#L205-L220


I think the front-end code should be adjusted:

@discourseComputed("canSplitTopic")
canSplitToPM(canSplitTopic) {
-  return canSplitTopic && this.currentUser && this.currentUser.admin;
+  return canSplitTopic && this.currentUser && this.currentUser.staff;
},

If you agree with this being a bug I’d be happy to make a PR to fix it. Our moderation team would have need of this fix.

4 Likes

I’m not sure but it seems plausible. What do you think @techAPJ?

3 Likes

The decision to not show “move to new PM” option for moderators was made explicitly in:

https://github.com/discourse/discourse/commit/dc2776bcddc07e69e5a4ab92526f6238f3a5ccd7

This is because the moderators do not have permission to see PMs and the relevant code will fail at:

https://github.com/discourse/discourse/blob/310952fd6a2fb74127175486bb0d6723640a274d/app/models/post_mover.rb#L66

7 Likes

Would it be feasible if a code change is made so that the acting moderator/administrator is added as a recipient on the newly created topic (private message) so that they can see the new topic once it is created? (and would this be a change you folks are interested in receiving?)

3 Likes

I’ll look into the possibility of adding acting moderator as PM recipient and subsequently enabling the feature “move posts to a new PM” for moderators.

4 Likes

Great! In case this ends up in backlog / deprioritized and is PR welcome, please let me know and I could help with implementation.

1 Like

It might take a bit for me to get to this. PR is 100% welcome here! :+1:

2 Likes