Thanks it works
Now can we get this component to restrict to subscriber groups ![]()
Only way I can do it myself is making Trust Level 3 impossible to get to by increasing the number of days, etc. And then manually adding people when they subscribe. Which is most likely the route I will take unless I can modify this by group.
Restrict Uploads is now blocking the ability to upload at all on new post or replies.
That’s right, sorry.
It looks like this._super() doesn’t actually report whether the user is allowed to upload images in core. I had reused it from the old component, and I already noticed yesterday that it caused issues with the placeholder logic as well.
I don’t have time to dig deeper into this right now.
One thing I noticed while testing today: using "*" in api.addComposerUploadHandler(["*"] breaks the regex used for matching upload handlers.
I think this seems like it should be a part of core. Just my humble opinion but a way of controlling uploads by trust level, group or even individual users would be very useful.
I believe you need to use the subclass method to overwrite this computed descriptor correctly.
import discourseComputed from "discourse-common/utils/decorators";
api.modifyClass("service:composer",
(SuperClass) => class extends SuperClass {
@discourseComputed
allowUpload() {
return super.allowUpload && canUpload;
}
}
);
EDIT:
Made a PR:
https://github.com/tshenry/discourse-restrict-uploads/pull/4
I created a pull request which switches the component from trust level-based to group-based restrictions:
https://github.com/tshenry/discourse-restrict-uploads/pull/6
@tshenry are you interested in changing the component to work group based?
The changes would probably need to be adjusted now to reflect the changes in core regarding group settings in themes. But if you don’t want the change anyway, I don’t need to spend time on an update.
