From ca6e491c8358aeb7e99d6f0f41af64b2ecbccb2f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 15 Jul 2021 22:39:40 -0600 Subject: [PATCH 1/7] Update PublicApiController, use fUserFilterService in public timeline endpoint --- app/Http/Controllers/PublicApiController.php | 33 ++++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index a3ce37ee2..4557c0cb0 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -291,10 +291,7 @@ class PublicApiController extends Controller $limit = $request->input('limit') ?? 3; $user = $request->user(); - $filtered = UserFilter::whereUserId($user->profile_id) - ->whereFilterableType('App\Profile') - ->whereIn('filter_type', ['mute', 'block']) - ->pluck('filterable_id')->toArray(); + $filtered = $user ? UserFilterService::filters($user->profile_id) : []; if($min || $max) { $dir = $min ? '>' : '<'; @@ -305,7 +302,8 @@ class PublicApiController extends Controller 'type', 'scope', 'local' - )->where('id', $dir, $id) + ) + ->where('id', $dir, $id) ->whereIn('type', ['text', 'photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereNotIn('profile_id', $filtered) ->whereLocal(true) @@ -339,7 +337,8 @@ class PublicApiController extends Controller 'likes_count', 'reblogs_count', 'updated_at' - )->whereIn('type', ['text', 'photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) + ) + ->whereIn('type', ['text', 'photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereNotIn('profile_id', $filtered) ->with('profile', 'hashtags', 'mentions') ->whereLocal(true) @@ -378,14 +377,14 @@ class PublicApiController extends Controller $user = $request->user(); $key = 'user:last_active_at:id:'.$user->id; - $ttl = now()->addMinutes(5); + $ttl = now()->addMinutes(20); Cache::remember($key, $ttl, function() use($user) { $user->last_active_at = now(); $user->save(); return; }); - $pid = Auth::user()->profile_id; + $pid = $user->profile_id; $following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function() use($pid) { $following = Follower::whereProfileId($pid)->pluck('following_id'); @@ -401,7 +400,7 @@ class PublicApiController extends Controller }); } - $filtered = Auth::check() ? UserFilterService::filters(Auth::user()->profile_id) : []; + $filtered = $user ? UserFilterService::filters($user->profile_id) : []; if($min || $max) { $dir = $min ? '>' : '<'; @@ -425,7 +424,8 @@ class PublicApiController extends Controller 'reblogs_count', 'created_at', 'updated_at' - )->whereIn('type', ['text','photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) + ) + ->whereIn('type', ['text','photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->with('profile', 'hashtags', 'mentions') ->where('id', $dir, $id) ->whereIn('profile_id', $following) @@ -454,7 +454,8 @@ class PublicApiController extends Controller 'reblogs_count', 'created_at', 'updated_at' - )->whereIn('type', ['text','photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) + ) + ->whereIn('type', ['text','photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->with('profile', 'hashtags', 'mentions') ->whereIn('profile_id', $following) ->whereNotIn('profile_id', $filtered) @@ -495,6 +496,8 @@ class PublicApiController extends Controller return; }); + $filtered = $user ? UserFilterService::filters($user->profile_id) : []; + if($min || $max) { $dir = $min ? '>' : '<'; $id = $min ?? $max; @@ -504,7 +507,9 @@ class PublicApiController extends Controller 'type', 'scope', 'created_at', - )->where('id', $dir, $id) + ) + ->where('id', $dir, $id) + ->whereNotIn('profile_id', $filtered) ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereNotNull('uri') ->whereScope('public') @@ -525,7 +530,9 @@ class PublicApiController extends Controller 'type', 'scope', 'created_at', - )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) + ) + ->whereNotIn('profile_id', $filtered) + ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereNotNull('uri') ->whereScope('public') ->where('id', '>', $amin) From 8544bcbda6d2ba195dd66ebf9cd226d96f48eb43 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 15 Jul 2021 23:18:40 -0600 Subject: [PATCH 2/7] Update ContextMenu, add View Profile link --- .../js/components/partials/ContextMenu.vue | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/resources/assets/js/components/partials/ContextMenu.vue b/resources/assets/js/components/partials/ContextMenu.vue index f5d966b62..9cdfd0809 100644 --- a/resources/assets/js/components/partials/ContextMenu.vue +++ b/resources/assets/js/components/partials/ContextMenu.vue @@ -12,6 +12,7 @@
View Post
+
View Profile
Share
@@ -279,6 +280,13 @@ return; }, + ctxMenuGoToProfile() { + let status = this.ctxMenuStatus; + window.location.href = this.profileUrl(status); + this.closeCtxMenu(); + return; + }, + ctxMenuFollow() { let id = this.ctxMenuStatus.account.id; axios.post('/i/follow', { @@ -633,6 +641,14 @@ return '/i/web/post/_/' + status.account.id + '/' + status.id; }, + profileUrl(status) { + if(status.local == true) { + return status.account.url; + } + + return '/i/web/profile/_/' + status.account.id; + }, + deletePost(status) { if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) { return; From 86422c81b7177bd24e8678d413cb426a670e7f64 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 15 Jul 2021 23:35:34 -0600 Subject: [PATCH 3/7] Update presenters, improve content warnings --- .../assets/js/components/PostComponent.vue | 16 ++-- resources/assets/js/components/RemotePost.vue | 8 +- .../assets/js/components/RemoteProfile.vue | 90 +++--------------- .../presenter/PhotoAlbumPresenter.vue | 95 +++++++++++++------ .../components/presenter/PhotoPresenter.vue | 24 +++++ 5 files changed, 113 insertions(+), 120 deletions(-) diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 38b966ffb..7b4e50456 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -57,19 +57,19 @@
- +
- +
- +
- +
@@ -292,19 +292,19 @@
- +
- +
- +
- +
diff --git a/resources/assets/js/components/RemotePost.vue b/resources/assets/js/components/RemotePost.vue index ff6806bb0..d653c6f68 100644 --- a/resources/assets/js/components/RemotePost.vue +++ b/resources/assets/js/components/RemotePost.vue @@ -50,19 +50,19 @@
- +
- +
- +
- +
diff --git a/resources/assets/js/components/RemoteProfile.vue b/resources/assets/js/components/RemoteProfile.vue index 4483bc052..d9f2bd350 100644 --- a/resources/assets/js/components/RemoteProfile.vue +++ b/resources/assets/js/components/RemoteProfile.vue @@ -60,60 +60,10 @@
-
-
-
- -
- {{profile.username}} - -
-
- -
-
- -
-
-
- -

{{status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}

-

(click to show)

-
- - - -
-
-
- - - - -
- -
- -
-
-

- - {{profile.username}} - - -

-
-
-

- - - -

-
-
-
+
+
@@ -195,10 +145,17 @@