Browse Source

Merge branch 'pixelfed:dev' into patch-1

Artur Mancha 3 years ago
parent
commit
7a448da89b

+ 2 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 
 
 ### Added
 ### Added
 - Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387))
 - Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387))
+- Added StatusMentionService, fixes #3026. ([e5387d67](https://github.com/pixelfed/pixelfed/commit/e5387d67))
 
 
 ### Updated
 ### Updated
 - Updated NotificationService, fix 500 bug. ([4a609dc3](https://github.com/pixelfed/pixelfed/commit/4a609dc3))
 - Updated NotificationService, fix 500 bug. ([4a609dc3](https://github.com/pixelfed/pixelfed/commit/4a609dc3))
@@ -31,6 +32,7 @@
 - Updated PublicApiController, fix private account statuses api. Closes #2995. ([aa2dd26c](https://github.com/pixelfed/pixelfed/commit/aa2dd26c))
 - Updated PublicApiController, fix private account statuses api. Closes #2995. ([aa2dd26c](https://github.com/pixelfed/pixelfed/commit/aa2dd26c))
 - Updated Status model, use AccountService to generate urls instead of loading profile relation. ([2ae527c0](https://github.com/pixelfed/pixelfed/commit/2ae527c0))
 - Updated Status model, use AccountService to generate urls instead of loading profile relation. ([2ae527c0](https://github.com/pixelfed/pixelfed/commit/2ae527c0))
 - Updated Autospam service, add mark all as read and mark all as not spam options and filter active, spam and not spam reports. ([ae8c7517](https://github.com/pixelfed/pixelfed/commit/ae8c7517))
 - Updated Autospam service, add mark all as read and mark all as not spam options and filter active, spam and not spam reports. ([ae8c7517](https://github.com/pixelfed/pixelfed/commit/ae8c7517))
+- Updated UserInviteController, fixes #3017. ([b8e9056e](https://github.com/pixelfed/pixelfed/commit/b8e9056e))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 
 ## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)
 ## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)

+ 3 - 5
app/Http/Controllers/UserInviteController.php

@@ -9,19 +9,16 @@ use Illuminate\Support\Str;
 
 
 class UserInviteController extends Controller
 class UserInviteController extends Controller
 {
 {
-	public function __construct()
-	{
-		abort_if(!config('pixelfed.user_invites.enabled'), 404);
-	}
-
 	public function create(Request $request)
 	public function create(Request $request)
 	{
 	{
+		abort_if(!config('pixelfed.user_invites.enabled'), 404);
 		abort_unless(Auth::check(), 403);
 		abort_unless(Auth::check(), 403);
 		return view('settings.invites.create');
 		return view('settings.invites.create');
 	}
 	}
 
 
 	public function show(Request $request)
 	public function show(Request $request)
 	{
 	{
+		abort_if(!config('pixelfed.user_invites.enabled'), 404);
 		abort_unless(Auth::check(), 403);
 		abort_unless(Auth::check(), 403);
 		$invites = UserInvite::whereUserId(Auth::id())->paginate(10);
 		$invites = UserInvite::whereUserId(Auth::id())->paginate(10);
 		$limit = config('pixelfed.user_invites.limit.total');
 		$limit = config('pixelfed.user_invites.limit.total');
@@ -31,6 +28,7 @@ class UserInviteController extends Controller
 
 
 	public function store(Request $request)
 	public function store(Request $request)
 	{
 	{
+		abort_if(!config('pixelfed.user_invites.enabled'), 404);
 		abort_unless(Auth::check(), 403);
 		abort_unless(Auth::check(), 403);
 		$this->validate($request, [
 		$this->validate($request, [
 			'email' => 'required|email|unique:users|unique:user_invites',
 			'email' => 'required|email|unique:users|unique:user_invites',

+ 23 - 0
app/Services/StatusMentionService.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Services;
+
+use Illuminate\Support\Facades\Cache;
+use App\Mention;
+use Illuminate\Support\Str;
+
+class StatusMentionService
+{
+	public static function get($id)
+	{
+		return Mention::whereStatusId($id)
+			->get()
+			->map(function($mention) {
+				return AccountService::get($mention->profile_id);
+			})->filter(function($mention) {
+				return $mention;
+			})
+			->values()
+			->toArray();
+	}
+}

+ 3 - 2
app/Transformer/Api/StatusStatelessTransformer.php

@@ -11,6 +11,7 @@ use App\Services\MediaService;
 use App\Services\MediaTagService;
 use App\Services\MediaTagService;
 use App\Services\StatusHashtagService;
 use App\Services\StatusHashtagService;
 use App\Services\StatusLabelService;
 use App\Services\StatusLabelService;
+use App\Services\StatusMentionService;
 use App\Services\ProfileService;
 use App\Services\ProfileService;
 use App\Services\PollService;
 use App\Services\PollService;
 
 
@@ -35,7 +36,7 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
 			'created_at'                => $status->created_at->format('c'),
 			'created_at'                => $status->created_at->format('c'),
 			'emojis'                    => [],
 			'emojis'                    => [],
 			'reblogs_count'             => 0,
 			'reblogs_count'             => 0,
-			'favourites_count'          => 0,
+			'favourites_count'          => $status->likes_count ?? 0,
 			'reblogged'                 => null,
 			'reblogged'                 => null,
 			'favourited'                => null,
 			'favourited'                => null,
 			'muted'                     => null,
 			'muted'                     => null,
@@ -48,7 +49,7 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
 			 ],
 			 ],
 			'language'                  => null,
 			'language'                  => null,
 			'pinned'                    => null,
 			'pinned'                    => null,
-			'mentions'                  => [],
+			'mentions'                  => StatusMentionService::get($status->id),
 			'tags'                      => [],
 			'tags'                      => [],
 			'pf_type'                   => $status->type ?? $status->setType(),
 			'pf_type'                   => $status->type ?? $status->setType(),
 			'reply_count'               => (int) $status->reply_count,
 			'reply_count'               => (int) $status->reply_count,

+ 3 - 2
app/Transformer/Api/StatusTransformer.php

@@ -12,6 +12,7 @@ use App\Services\MediaService;
 use App\Services\MediaTagService;
 use App\Services\MediaTagService;
 use App\Services\StatusHashtagService;
 use App\Services\StatusHashtagService;
 use App\Services\StatusLabelService;
 use App\Services\StatusLabelService;
+use App\Services\StatusMentionService;
 use App\Services\ProfileService;
 use App\Services\ProfileService;
 use Illuminate\Support\Str;
 use Illuminate\Support\Str;
 use App\Services\PollService;
 use App\Services\PollService;
@@ -37,7 +38,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
 			'created_at'                => $status->created_at->format('c'),
 			'created_at'                => $status->created_at->format('c'),
 			'emojis'                    => [],
 			'emojis'                    => [],
 			'reblogs_count'             => 0,
 			'reblogs_count'             => 0,
-			'favourites_count'          => 0,
+			'favourites_count'          => $status->likes_count ?? 0,
 			'reblogged'                 => $status->shared(),
 			'reblogged'                 => $status->shared(),
 			'favourited'                => $status->liked(),
 			'favourited'                => $status->liked(),
 			'muted'                     => null,
 			'muted'                     => null,
@@ -50,7 +51,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
 			 ],
 			 ],
 			'language'                  => null,
 			'language'                  => null,
 			'pinned'                    => null,
 			'pinned'                    => null,
-			'mentions'                  => [],
+			'mentions'                  => StatusMentionService::get($status->id),
 			'tags'                      => [],
 			'tags'                      => [],
 			'pf_type'                   => $status->type ?? $status->setType(),
 			'pf_type'                   => $status->type ?? $status->setType(),
 			'reply_count'               => (int) $status->reply_count,
 			'reply_count'               => (int) $status->reply_count,

+ 1 - 1
resources/assets/js/components/Profile.vue

@@ -145,7 +145,7 @@
 										<span v-if="profile.pronouns" class="text-muted small">{{profile.pronouns.join('/')}}</span>
 										<span v-if="profile.pronouns" class="text-muted small">{{profile.pronouns.join('/')}}</span>
 									</p>
 									</p>
 									<p v-if="profile.note" class="mb-0" v-html="profile.note"></p>
 									<p v-if="profile.note" class="mb-0" v-html="profile.note"></p>
-									<p v-if="profile.website"><a :href="profile.website" class="profile-website small" rel="me external nofollow noopener" target="_blank" @click.prevent="remoteRedirect(profile.website)">{{formatWebsite(profile.website)}}</a></p>
+									<p v-if="profile.website"><a :href="profile.website" class="profile-website small" rel="me external nofollow noopener" target="_blank">{{formatWebsite(profile.website)}}</a></p>
 									<p class="d-flex small text-muted align-items-center">
 									<p class="d-flex small text-muted align-items-center">
 										<span v-if="profile.is_admin" class="btn btn-outline-danger btn-sm py-0 mr-3" title="Admin Account" data-toggle="tooltip">
 										<span v-if="profile.is_admin" class="btn btn-outline-danger btn-sm py-0 mr-3" title="Admin Account" data-toggle="tooltip">
 											Admin
 											Admin