Bladeren bron

Merge pull request #2535 from pixelfed/staging

Staging
daniel 4 jaren geleden
bovenliggende
commit
9b141d95e4

+ 3 - 0
CHANGELOG.md

@@ -148,6 +148,9 @@
 - Update migrations, fix broken oauth change. ([4a885c88](https://github.com/pixelfed/pixelfed/commit/4a885c88))
 - Update LikeController, store status_profile_id and is_comment attributes. ([799a4cba](https://github.com/pixelfed/pixelfed/commit/799a4cba))
 - Updated Profile, fix status count. ([6dcd472b](https://github.com/pixelfed/pixelfed/commit/6dcd472b))
+- Updated StatusService, cast response to array. ([0fbde91e](https://github.com/pixelfed/pixelfed/commit/0fbde91e))
+- Updated status model, use scope over deprecated visibility attribute. ([f70826e1](https://github.com/pixelfed/pixelfed/commit/f70826e1))
+- Updated Follower model, increase hourly limit from 30 to 150. ([b9b84e6f](https://github.com/pixelfed/pixelfed/commit/b9b84e6f))
 
 ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)
 ### Added

+ 1 - 1
app/Follower.php

@@ -10,7 +10,7 @@ class Follower extends Model
     protected $fillable = ['profile_id', 'following_id', 'local_profile'];
 
     const MAX_FOLLOWING = 7500;
-    const FOLLOW_PER_HOUR = 30;
+    const FOLLOW_PER_HOUR = 150;
 
     public function actor()
     {

+ 2 - 2
app/Http/Controllers/Api/ApiV1Controller.php

@@ -1446,7 +1446,7 @@ class ApiV1Controller extends Controller
                       ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
                       ->with('profile', 'hashtags', 'mentions')
                       ->where('id', $dir, $id)
-                      ->whereVisibility('public')
+                      ->whereScope('public')
                       ->latest()
                       ->limit($limit)
                       ->get();
@@ -1473,7 +1473,7 @@ class ApiV1Controller extends Controller
                       )->whereNull('uri')
                       ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
                       ->with('profile', 'hashtags', 'mentions')
-                      ->whereVisibility('public')
+                      ->whereScope('public')
                       ->latest()
                       ->simplePaginate($limit);
         }

+ 2 - 1
app/Http/Controllers/Api/BaseApiController.php

@@ -133,6 +133,7 @@ class BaseApiController extends Controller
         $statuses = $account->statuses()->getQuery(); 
         if($only_media == true) {
             $statuses = $statuses
+                ->whereIn('scope', ['public','unlisted'])
                 ->whereHas('media')
                 ->whereNull('in_reply_to_id')
                 ->whereNull('reblog_of_id');
@@ -153,7 +154,7 @@ class BaseApiController extends Controller
                 ->orderBy('id', 'DESC')
                 ->paginate($limit);
         } else {
-            $statuses = $statuses->whereVisibility('public')->orderBy('id', 'desc')->paginate($limit);
+            $statuses = $statuses->whereScope('public')->orderBy('id', 'desc')->paginate($limit);
         }
         $resource = new Fractal\Resource\Collection($statuses, new StatusTransformer());
         $res = $this->fractal->createData($resource)->toArray();

+ 2 - 2
app/Http/Controllers/DiscoverController.php

@@ -181,14 +181,14 @@ class DiscoverController extends Controller
       $ttl = now()->addHours(2);
       $res = Cache::remember($key, $ttl, function() use($range) {
         if($range == '-1') {
-          $res = Status::whereVisibility('public')
+          $res = Status::whereScope('public')
           ->whereType('photo')
           ->whereIsNsfw(false)
           ->orderBy('likes_count','desc')
           ->take(12)
           ->get();
         } else {
-          $res = Status::whereVisibility('public')
+          $res = Status::whereScope('public')
           ->whereType('photo')
           ->whereIsNsfw(false)
           ->orderBy('likes_count','desc')

+ 2 - 2
app/Http/Controllers/PublicApiController.php

@@ -304,7 +304,7 @@ class PublicApiController extends Controller
                       ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
                       ->whereNotIn('profile_id', $filtered)
                       ->whereLocal(true)
-                      ->whereVisibility('public')
+                      ->whereScope('public')
                       ->orderBy('created_at', 'desc')
                       ->limit($limit)
                       ->get();
@@ -332,7 +332,7 @@ class PublicApiController extends Controller
                       ->whereNotIn('profile_id', $filtered)
                       ->with('profile', 'hashtags', 'mentions')
                       ->whereLocal(true)
-                      ->whereVisibility('public')
+                      ->whereScope('public')
                       ->orderBy('created_at', 'desc')
                       ->simplePaginate($limit);
         }

+ 1 - 1
app/Http/Controllers/StatusController.php

@@ -33,7 +33,7 @@ class StatusController extends Controller
 
         $status = Status::whereProfileId($user->id)
                 ->whereNull('reblog_of_id')
-                ->whereNotIn('visibility',['draft','direct'])
+                ->whereIn('scope', ['public','unlisted'])
                 ->findOrFail($id);
 
         if($status->uri || $status->url) {

+ 2 - 2
app/Services/StatusService.php

@@ -17,12 +17,12 @@ class StatusService {
 
 	public static function get($id)
 	{
-		return json_decode(Redis::get(self::CACHE_KEY . $id) ?? self::coldGet($id));
+		return json_decode(Redis::get(self::CACHE_KEY . $id) ?? self::coldGet($id), true);
 	}
 
 	public static function coldGet($id)
 	{
-		$status = Status::findOrFail($id);
+		$status = Status::whereScope('public')->findOrFail($id);
 		$fractal = new Fractal\Manager();
 		$fractal->setSerializer(new ArraySerializer());
 		$resource = new Fractal\Resource\Item($status, new StatusStatelessTransformer());

+ 1 - 1
app/Transformer/ActivityPub/ProfileOutbox.php

@@ -27,7 +27,7 @@ class ProfileOutbox extends Fractal\TransformerAbstract
         $statuses = $profile
           ->statuses()
           ->with('media')
-          ->whereVisibility('public')
+          ->whereScope('public')
           ->orderBy('created_at', 'desc')
           ->paginate(10);
 

+ 1 - 1
app/Util/ActivityPub/Outbox.php

@@ -26,7 +26,7 @@ class Outbox {
 
         $timeline = $profile
                     ->statuses()
-                    ->whereVisibility('public')
+                    ->whereScope('public')
                     ->orderBy('created_at', 'desc')
                     ->take(10)
                     ->get();