From 8cac1fd26d3a4ec867af5ff00a776080d57ad4f1 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Fri, 2 Jun 2023 22:17:28 +0100
Subject: [PATCH] Fix some debugging; accept all content except video

Video is skipped due to the (current) lack of ffmpeg in wp-mat-server.
---
 wp-mat.php | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/wp-mat.php b/wp-mat.php
index ef3585d..1c6ebb8 100644
--- a/wp-mat.php
+++ b/wp-mat.php
@@ -3,7 +3,7 @@
  * Plugin Name: wp-mat
  * Plugin URI: https://git.autistici.org/noblogs/wp-mat
  * Description: Process uploaded files through MAT
- * Version: 0.0.11
+ * Version: 0.1.0
  * Author: Autistici/Inventati
  * Author URI: https://www.autistici.org/
  * License: MIT
@@ -15,11 +15,13 @@ if (!defined("WP_MAT_ENDPOINT")) {
 }
 
 // Check if the mime type is one of those we want to clean up.
+// Use a blacklist, currently empty. Send everything by default
+// except video.
 function wp_mat_is_supported_mime_type($mimetype) {
-    if (substr($mimetype, 0, 6) === "image/") {
-        return true;
+    if (substr($mimetype, 0, 6) === "video/") {
+        return false;
     }
-    return false;
+    return true;
 }
 
 // Make a POST request to the MAT service with the uploaded file and
@@ -51,10 +53,7 @@ function wp_mat_issue_request($path, $mimetype, $output_path) {
 }
 
 function wp_mat_handle_upload_prefilter($file) {
-    error_log("wp-mat: called with file=".json_encode($file));
-
     if (isset($file['error']) && $file['error']) {
-        error_log("wp-mat: upload has error set to ".$file['error']);
         return $file;
     }
 
@@ -97,7 +96,10 @@ function wp_mat_handle_upload_prefilter($file) {
 
 add_filter('wp_handle_upload_prefilter', 'wp_mat_handle_upload_prefilter');
 
-function wp_handle_upload_error(&$file, $message) {
-    error_log("wp_handle_upload_error: ".$message);
-    return array( "error" => $message );
+// This is generally useful for debugging.
+if (!function_exists('wp_handle_upload_error')) {
+    function wp_handle_upload_error(&$file, $message) {
+        error_log("wp_handle_upload_error: ".$message);
+        return array( "error" => $message );
+    }
 }
-- 
GitLab