Ver código fonte

Merge pull request #3302 from pixelfed/staging

Update ReblogService
daniel 3 anos atrás
pai
commit
4d99ffcff3
1 arquivos alterados com 12 adições e 4 exclusões
  1. 12 4
      app/Services/ReblogService.php

+ 12 - 4
app/Services/ReblogService.php

@@ -9,8 +9,8 @@ use App\Status;
 class ReblogService
 {
 	const CACHE_KEY = 'pf:services:reblogs:';
-	const REBLOGS_KEY = 'pf:services:reblogs:post:';
-	const COLDBOOT_KEY = 'pf:services:reblogs:post_:';
+	const REBLOGS_KEY = 'pf:services:reblogs:v1:post:';
+	const COLDBOOT_KEY = 'pf:services:reblogs:v1:post_:';
 
 	public static function get($profileId, $statusId)
 	{
@@ -50,11 +50,19 @@ class ReblogService
 
 	public static function addPostReblog($parentId, $reblogId)
 	{
-		return Redis::zadd(self::REBLOGS_KEY . $parentId, $reblogId);
+		$pid = intval($parentId);
+		$id = intval($reblogId);
+		if($pid && $id) {
+			return Redis::zadd(self::REBLOGS_KEY . $pid, $id);
+		}
 	}
 
 	public static function removePostReblog($parentId, $reblogId)
 	{
-		return Redis::zrem(self::REBLOGS_KEY . $parentId, $reblogId);
+		$pid = intval($parentId);
+		$id = intval($reblogId);
+		if($pid && $id) {
+			return Redis::zrem(self::REBLOGS_KEY . $pid, $id);
+		}
 	}
 }