How can I access composePrivateMessage from a post menu button?


I wrote a plugin for mailing list type behaviour, where emails can be replied to (only the sender) and reply-all (to the whole topic). I want to recreate this in the web UI as well by having a “reply” and “reply all” button on each post in the topic. The “reply” would mimic clicking on a post author’s card and then “message”. This is the default behaviour it gives:

Despite writing the plugin above, I am not very familiar with rails and struggle significantly with it. I think I found the correct ‘action’ here. It is composePrivateMessage, which is found in /discourse/app/assets/javascripts/discourse/app/routes/application.js. As indicated by the path, it’s a route, which is throwing me off, and I am struggling to turn that into a clickable button.

Here is what I have right now:

  api.addPostMenuButton("reply-privately", (attrs, state) => {
    return {
      action: composePrivateMessage(user, post),
      title: "reply-privately",
      icon: "reply",
      position: "last",
      className: "reply-privately",

Any thoughts on how to make the ‘action’ fit into the ‘route’?

1 Like