Restrict uploads

Thanks it works

Now can we get this component to restrict to subscriber groups :stuck_out_tongue:

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.

2 Likes

Restrict Uploads is now blocking the ability to upload at all on new post or replies.

1 Like

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.

1 Like

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.

1 Like

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:

4 Likes