瀏覽代碼

Invalidate status cache after importing custom emoji

Daniel Supernault 3 年之前
父節點
當前提交
dbb1638fd6
共有 2 個文件被更改,包括 6 次插入6 次删除
  1. 1 5
      app/Jobs/StatusPipeline/StatusTagsPipeline.php
  2. 5 1
      app/Services/CustomEmojiService.php

+ 1 - 5
app/Jobs/StatusPipeline/StatusTagsPipeline.php

@@ -45,11 +45,7 @@ class StatusTagsPipeline implements ShouldQueue
 			return $tag && $tag['type'] == 'Emoji';
 			return $tag && $tag['type'] == 'Emoji';
 		})
 		})
 		->map(function($tag) {
 		->map(function($tag) {
-			CustomEmojiService::import($tag['id']);
+			CustomEmojiService::import($tag['id'], $this->status->id);
 		});
 		});
-
-		// sleep(15);
-
-		StatusService::del($this->status->id);
 	}
 	}
 }
 }

+ 5 - 1
app/Services/CustomEmojiService.php

@@ -18,7 +18,7 @@ class CustomEmojiService
 		return CustomEmoji::whereShortcode($shortcode)->first();
 		return CustomEmoji::whereShortcode($shortcode)->first();
 	}
 	}
 
 
-	public static function import($url)
+	public static function import($url, $id = false)
 	{
 	{
 		if(config('federation.custom_emoji.enabled') == false) {
 		if(config('federation.custom_emoji.enabled') == false) {
 			return;
 			return;
@@ -72,6 +72,10 @@ class CustomEmojiService
 
 
 			$name = str_replace(':', '', $json['name']);
 			$name = str_replace(':', '', $json['name']);
 			Cache::forget('pf:custom_emoji:' . $name);
 			Cache::forget('pf:custom_emoji:' . $name);
+
+			if($id) {
+				StatusService::del($id);
+			}
 			return;
 			return;
 		} else {
 		} else {
 			return;
 			return;