HOWEVER, byobu listeners run after tag listeners, so Byobu does not check whether the discussion is private or not until the tag has actually run.
As I pointed out in the GH issue, Laravel used to support ordered listeners but dropped them as that encouraged anti-patterns. However, in this particular case, I don't think there's a reasonable alternative (a middleware wouldn't work, as the policy doesn't get the request object, and the discussion object isn't created when the middleware runs).
As a result, I propose a listenBefore method on the Event extender. We should strongly discourage using this unless absolutely necessary, but since we use events to extend API controllers, I think this might be a necessary evil.
Feature Request
Is your feature request related to a problem? Please describe. This is prompted by https://github.com/FriendsOfFlarum/byobu/issues/141#issuecomment-804299827. Essentially:
SaveTagsToDatabase
listener. At this point, we call an ability check (https://github.com/flarum/tags/blob/master/src/Listener/SaveTagsToDatabase.php#L114), that calls a policy. Here, Byobu SHOULD be able to allow the action if the discussion is privateAs I pointed out in the GH issue, Laravel used to support ordered listeners but dropped them as that encouraged anti-patterns. However, in this particular case, I don't think there's a reasonable alternative (a middleware wouldn't work, as the policy doesn't get the request object, and the discussion object isn't created when the middleware runs).
As a result, I propose a
listenBefore
method on theEvent
extender. We should strongly discourage using this unless absolutely necessary, but since we use events to extend API controllers, I think this might be a necessary evil.