FEATURE: Returning falsy value from upload handler stops upload. (#6969)

FEATURE: Returning falsy value from upload handler stops upload. (#6969)

diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6
index 059bddb..db6cde6 100644
--- a/app/assets/javascripts/discourse/components/composer-editor.js.es6
+++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6
@@ -681,8 +681,9 @@ export default Ember.Component.extend({
 
       const matchingHandler = uploadHandlers.find(matcher);
       if (data.files.length === 1 && matchingHandler) {
-        matchingHandler.method(data.files[0]);
-        return false;
+        if (!matchingHandler.method(data.files[0])) {
+          return false;
+        }
       }
 
       // If no plugin, continue as normal
diff --git a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 b/app/assets/javascripts/discourse/lib/plugin-api.js.es6
index a44548c..ecce020 100644
--- a/app/assets/javascripts/discourse/lib/plugin-api.js.es6
+++ b/app/assets/javascripts/discourse/lib/plugin-api.js.es6
@@ -786,7 +786,8 @@ class PluginApi {
   /**
    *
    * Registers a function to handle uploads for specified file types
-   * The normal uploading functionality will be bypassed
+   * The normal uploading functionality will be bypassed if function returns
+   * a falsy value.
    * This only for uploads of individual files
    *
    * Example:

GitHub sha: 2c222e16

1 Like