瀏覽代碼

Merge pull request #4730 from pixelfed/staging

Staging
daniel 1 年之前
父節點
當前提交
e45ede5a12

+ 3 - 0
CHANGELOG.md

@@ -40,6 +40,9 @@
 - Update ApiV1Dot1Controller, allow iar rate limits to be configurable ([28a80803](https://github.com/pixelfed/pixelfed/commit/28a80803))
 - Update ApiV1Dot1Controller, add domain to iar redirect ([1f82d47c](https://github.com/pixelfed/pixelfed/commit/1f82d47c))
 - Update ApiV1Dot1Controller, add configurable app confirm rate limit ttl ([4c6a0719](https://github.com/pixelfed/pixelfed/commit/4c6a0719))
+- Update LikePipeline, dispatch to feed queue. Fixes ([#4723](https://github.com/pixelfed/pixelfed/issues/4723)) ([da510089](https://github.com/pixelfed/pixelfed/commit/da510089))
+- Update AccountImport ([5a2d7e3e](https://github.com/pixelfed/pixelfed/commit/5a2d7e3e))
+- Update ImportPostController, fix IG bug with missing spaces between hashtags ([9c24157a](https://github.com/pixelfed/pixelfed/commit/9c24157a))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)

+ 13 - 2
app/Http/Controllers/ImportPostController.php

@@ -83,6 +83,17 @@ class ImportPostController extends Controller
         );
     }
 
+    public function formatHashtags($val = false)
+    {
+        if(!$val || !strlen($val)) {
+            return null;
+        }
+
+        $groupedHashtagRegex = '/#\w+(?=#)/';
+
+        return preg_replace($groupedHashtagRegex, '$0 ', $val);
+    }
+
     public function store(Request $request)
     {
         abort_unless(config('import.instagram.enabled'), 404);
@@ -128,11 +139,11 @@ class ImportPostController extends Controller
             $ip->media = $c->map(function($m) {
                 return [
                     'uri' => $m['uri'],
-                    'title' => $m['title'],
+                    'title' => $this->formatHashtags($m['title']),
                     'creation_timestamp' => $m['creation_timestamp']
                 ];
             })->toArray();
-            $ip->caption = $c->count() > 1 ? $file['title'] : $ip->media[0]['title'];
+            $ip->caption = $c->count() > 1 ? $this->formatHashtags($file['title']) : $this->formatHashtags($ip->media[0]['title']);
             $ip->filename = last(explode('/', $ip->media[0]['uri']));
             $ip->metadata = $c->map(function($m) {
                 return [

二進制
public/js/account-import.js


二進制
public/js/collections.js


二進制
public/js/compose.chunk.10e7f993dcc726f9.js


二進制
public/js/compose.chunk.965eab35620423e5.js


二進制
public/js/compose.js


二進制
public/js/manifest.js


二進制
public/js/post.chunk.23fc9e82d4fadc83.js


+ 0 - 0
public/js/post.chunk.74f8b1d1954f5d01.js.LICENSE.txt → public/js/post.chunk.23fc9e82d4fadc83.js.LICENSE.txt


二進制
public/js/post.chunk.74f8b1d1954f5d01.js


二進制
public/mix-manifest.json


+ 16 - 4
resources/assets/components/AccountImport.vue

@@ -348,8 +348,18 @@
                 }, 500);
             },
 
-            filterPostMeta(media) {
-                let json = JSON.parse(media);
+            async fixFacebookEncoding(string) {
+                // Facebook and Instagram are encoding UTF8 characters in a weird way in their json
+                // here is a good explanation what's going wrong https://sorashi.github.io/fix-facebook-json-archive-encoding
+                // See https://github.com/pixelfed/pixelfed/pull/4726 for more info
+                const replaced = string.replace(/\\u00([a-f0-9]{2})/g, (x) => String.fromCharCode(parseInt(x.slice(2), 16)));
+                const buffer = Array.from(replaced, (c) => c.charCodeAt(0));
+                return new TextDecoder().decode(new Uint8Array(buffer));
+            },
+
+            async filterPostMeta(media) {
+            	let fbfix = await this.fixFacebookEncoding(media);
+                let json = JSON.parse(fbfix);
                 let res = json.filter(j => {
                     let ids = j.media.map(m => m.uri).filter(m => {
                         if(this.config.allow_video_posts == true) {
@@ -396,12 +406,14 @@
                     this.filterPostMeta(media);
 
                     let imgs = await Promise.all(entries.filter(entry => {
-                        return entry.filename.startsWith('media/posts/') && (entry.filename.endsWith('.png') || entry.filename.endsWith('.jpg') || entry.filename.endsWith('.mp4'));
+                        return (entry.filename.startsWith('media/posts/') || entry.filename.startsWith('media/other/')) && (entry.filename.endsWith('.png') || entry.filename.endsWith('.jpg') || entry.filename.endsWith('.mp4'));
                     })
                     .map(async entry => {
                         if(
-                            entry.filename.startsWith('media/posts/') &&
                             (
+                                entry.filename.startsWith('media/posts/') ||
+                                entry.filename.startsWith('media/other/')
+                            ) && (
                                 entry.filename.endsWith('.png') ||
                                 entry.filename.endsWith('.jpg') ||
                                 entry.filename.endsWith('.mp4')