Discourse Retort

Yup, I could do that. It would be a bit of a hack though :wink:

I’m not sure I could assume that workaround would remain viable over time. It’s also a bit risky. For example, if I just run that code the user’s post_undo_action_window_mins site setting would remained changed. You could change it back at the end of the migration, but doing setting changes like this on the fly to get around a guardian is not ideal.

Ideally what I’m after here is a slight change to the ReactionManager interface to make it possible to reliably migrate retorts to reactions. Currently it’s only set up to handle requests from the client.

One way to do that would be to

  • abstract the guardian in toggle! to an ensure_can_toggle method
  • make the ensure_can_toggle method subject to a force option

This is the approach typically taken to handle migrations or backend imports in other parts of Discourse (if you do a search in app/ or lib/ for force you’ll see a few examples).

Does that make sense?

2 Likes