소스 검색

Update ApiV1Controller, fix hashtag timeline

Daniel Supernault 2 년 전
부모
커밋
fc1a385cfd
1개의 변경된 파일13개의 추가작업 그리고 5개의 파일을 삭제
  1. 13 5
      app/Http/Controllers/Api/ApiV1Controller.php

+ 13 - 5
app/Http/Controllers/Api/ApiV1Controller.php

@@ -3270,6 +3270,16 @@ class ApiV1Controller extends Controller
 		$max = $request->input('max_id');
 		$limit = $request->input('limit', 20);
 
+		if($min || $max) {
+			$minMax = SnowflakeService::byDate(now()->subMonths(6));
+			if($min && intval($min) < $minMax) {
+				return [];
+			}
+			if($max && intval($max) < $minMax) {
+				return [];
+			}
+		}
+
 		if(!$min && !$max) {
 			$id = 1;
 			$dir = '>';
@@ -3279,15 +3289,13 @@ class ApiV1Controller extends Controller
 		}
 
 		$res = StatusHashtag::whereHashtagId($tag->id)
-			->whereStatusVisibility('public')
 			->where('status_id', $dir, $id)
-			->latest()
+			->whereStatusVisibility('public')
+			->orderBy('status_id', 'desc')
 			->limit($limit)
 			->pluck('status_id')
 			->map(function ($i) {
-				if($i) {
-					return StatusService::getMastodon($i);
-				}
+				return StatusService::getMastodon($i);
 			})
 			->filter(function($i) {
 				return $i && isset($i['account']);