瀏覽代碼

Update ap helpers, store media attachment width and height if present

Daniel Supernault 1 年之前
父節點
當前提交
8c96919119
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      app/Util/ActivityPub/Helpers.php

+ 12 - 1
app/Util/ActivityPub/Helpers.php

@@ -108,7 +108,10 @@ class Helpers {
                 'string',
                 'string',
                 Rule::in($mimeTypes)
                 Rule::in($mimeTypes)
             ],
             ],
-            '*.name' => 'sometimes|nullable|string'
+            '*.name' => 'sometimes|nullable|string',
+            '*.blurhash' => 'sometimes|nullable|string|min:6|max:164',
+            '*.width' => 'sometimes|nullable|integer|min:1|max:5000',
+            '*.height' => 'sometimes|nullable|integer|min:1|max:5000',
         ])->passes();
         ])->passes();
 
 
         return $valid;
         return $valid;
@@ -684,6 +687,8 @@ class Helpers {
             $blurhash = isset($media['blurhash']) ? $media['blurhash'] : null;
             $blurhash = isset($media['blurhash']) ? $media['blurhash'] : null;
             $license = isset($media['license']) ? License::nameToId($media['license']) : null;
             $license = isset($media['license']) ? License::nameToId($media['license']) : null;
             $caption = isset($media['name']) ? Purify::clean($media['name']) : null;
             $caption = isset($media['name']) ? Purify::clean($media['name']) : null;
+            $width = isset($media['width']) ? $media['width'] : false;
+            $height = isset($media['height']) ? $media['height'] : false;
 
 
             $media = new Media();
             $media = new Media();
             $media->blurhash = $blurhash;
             $media->blurhash = $blurhash;
@@ -695,6 +700,12 @@ class Helpers {
             $media->remote_url = $url;
             $media->remote_url = $url;
             $media->caption = $caption;
             $media->caption = $caption;
             $media->order = $key + 1;
             $media->order = $key + 1;
+            if($width) {
+                $media->width = $width;
+            }
+            if($height) {
+                $media->height = $height;
+            }
             if($license) {
             if($license) {
                 $media->license = $license;
                 $media->license = $license;
             }
             }