From 12d9893b7569a7d064c4769446d2e5e2446085c5 Mon Sep 17 00:00:00 2001 From: Levin Herr Date: Sun, 7 Nov 2021 10:15:23 +0100 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=9A=91=20Fix=20a=20500=20when=20loggi?= =?UTF-8?q?ng=20in=20with=20user/password=20(#615)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Backend/Auth/LoginController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Backend/Auth/LoginController.php b/app/Http/Controllers/Backend/Auth/LoginController.php index 8e2b93470..7023db997 100644 --- a/app/Http/Controllers/Backend/Auth/LoginController.php +++ b/app/Http/Controllers/Backend/Auth/LoginController.php @@ -7,7 +7,7 @@ class LoginController extends Controller { - public static function login(string $login, string $password, bool $remember = false): bool { + public static function login(string $login, string $password, ?bool $remember = false): bool { $loginType = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; if (Auth::attempt([$loginType => $login, 'password' => $password], $remember)) { From dcfc1bdb114e9ece2c7fff16fc90b8b037e32e5b Mon Sep 17 00:00:00 2001 From: Kris Date: Sun, 7 Nov 2021 10:56:38 +0100 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=A9=B9=20Hide=20email=20and=20tel=20i?= =?UTF-8?q?f=20missing=20(#609)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/legal/notice.blade.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/views/legal/notice.blade.php b/resources/views/legal/notice.blade.php index dbc2c913e..34fee8f15 100644 --- a/resources/views/legal/notice.blade.php +++ b/resources/views/legal/notice.blade.php @@ -15,8 +15,12 @@ {{config('app.legal.address2')}}

Kontakt

-

E-Mail: {{config('app.legal.email')}}

-

Tel.: {{config('app.legal.tel')}}

+ @if(config('app.legal.email')) +

E-Mail: {{config('app.legal.email')}}

+ @endif + @if(config('app.legal.tel')) +

Tel.: {{config('app.legal.tel')}}

+ @endif

Haftung für Inhalte

Als Diensteanbieter sind wir gemäß § 7 Abs.1 TMG für eigene Inhalte auf diesen From dc34eabd607de556f3ed4fb31796328f5c9e9b99 Mon Sep 17 00:00:00 2001 From: Kris Date: Sun, 7 Nov 2021 10:56:56 +0100 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20responsive=20table=20(?= =?UTF-8?q?#612)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/events/overview.blade.php | 72 ++++++++++++----------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/resources/views/events/overview.blade.php b/resources/views/events/overview.blade.php index 39f0205ce..7834d5ad0 100644 --- a/resources/views/events/overview.blade.php +++ b/resources/views/events/overview.blade.php @@ -21,41 +21,43 @@ {{__('events.request-question')}}

@else - - - @foreach($liveAndUpcomingEvents as $event) - - - - - - @endforeach - -
- {{$event->name}} - @if($event->getTrainstation() != null) -
- - {{__('events.closestStation')}}: - - {{$event->getTrainstation()->name}} - - - @endif -
- @if($event->begin->isSameDay($event->end)) - {{$event->begin->format('d.m.Y')}} - @else - {{$event->begin->format('d.m.Y')}} - - {{$event->end->format('d.m.Y')}} - @endif - - - {{__('menu.show-more')}} - - -
+
+ + + @foreach($liveAndUpcomingEvents as $event) + + + + + + @endforeach + +
+ {{$event->name}} + @if($event->getTrainstation() != null) +
+ + {{__('events.closestStation')}}: + + {{$event->getTrainstation()->name}} + + + @endif +
+ @if($event->begin->isSameDay($event->end)) + {{$event->begin->format('d.m.Y')}} + @else + {{$event->begin->format('d.m.Y')}} + - {{$event->end->format('d.m.Y')}} + @endif + + + {{__('menu.show-more')}} + + +
+
{{$liveAndUpcomingEvents->links()}} @endif From ccfa6a06d5362e8982d06fbe64dd23e186fa7770 Mon Sep 17 00:00:00 2001 From: Kris Date: Sun, 7 Nov 2021 10:57:29 +0100 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=9A=B8=20Hide=20private=20users=20on?= =?UTF-8?q?=20leaderboard=20(#613)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Backend/LeaderboardController.php | 65 +++++++++++-------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/Backend/LeaderboardController.php b/app/Http/Controllers/Backend/LeaderboardController.php index 62ec83822..6a2e0435d 100644 --- a/app/Http/Controllers/Backend/LeaderboardController.php +++ b/app/Http/Controllers/Backend/LeaderboardController.php @@ -3,9 +3,9 @@ namespace App\Http\Controllers\Backend; use App\Http\Controllers\Controller; -use App\Models\Status; use App\Models\User; use Carbon\Carbon; +use Illuminate\Database\Query\Builder; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use InvalidArgumentException; @@ -39,8 +39,16 @@ public static function getLeaderboard( $query = DB::table('statuses') ->join('train_checkins', 'train_checkins.status_id', '=', 'statuses.id') + ->join('users', 'statuses.user_id', '=', 'users.id') ->where('train_checkins.departure', '>=', $since->toIso8601String()) ->where('train_checkins.departure', '<=', $until->toIso8601String()) + ->where(function(Builder $query) { + $query->where('users.private_profile', 0); + if (auth()->check()) { + $query->orWhereIn('users.id', auth()->user()->follows->pluck('id')) + ->orWhere('users.id', auth()->user()->id); + } + }) ->groupBy('statuses.user_id') ->select([ 'statuses.user_id', @@ -64,8 +72,6 @@ public static function getLeaderboard( //Fetch user models in ONE query and map it to the collection $userCache = User::whereIn('id', $data->pluck('user_id'))->get(); - // ToDo: Levin, das Leaderboard gibt jetzt Schnelligkeit und Distance in meter aus. Bitte in vue anpassen. - // ToDo: Probably re-sort for new distance-calculation, etc. return $data->map(function($row) use ($userCache) { $row->user = $userCache->where('id', $row->user_id)->first(); return $row; @@ -73,33 +79,40 @@ public static function getLeaderboard( } public static function getMonthlyLeaderboard(Carbon $date): Collection { - $data = Status::with(['trainCheckin', 'user']) - ->join('train_checkins', 'train_checkins.status_id', '=', 'statuses.id') - ->where( - 'train_checkins.departure', - '>=', - $date->clone()->firstOfMonth()->toIso8601String() - ) - ->where( - 'train_checkins.departure', - '<=', - $date->clone()->lastOfMonth()->endOfDay()->toIso8601String() - ) - ->select([ - 'statuses.user_id', - DB::raw('SUM(train_checkins.points) AS points'), - DB::raw('SUM(train_checkins.distance) AS distance'), - DB::raw(self::getDurationSelector() . ' AS duration'), - DB::raw('SUM(train_checkins.distance) / (' . self::getDurationSelector() . ' / 60) AS speed'), - ]) - ->groupBy('user_id') - ->orderByDesc('points') - ->get(); + $data = DB::table('statuses') + ->join('train_checkins', 'train_checkins.status_id', '=', 'statuses.id') + ->join('users', 'statuses.user_id', '=', 'users.id') + ->where( + 'train_checkins.departure', + '>=', + $date->clone()->firstOfMonth()->toIso8601String() + ) + ->where( + 'train_checkins.departure', + '<=', + $date->clone()->lastOfMonth()->endOfDay()->toIso8601String() + ) + ->where(function(Builder $query) { + $query->where('users.private_profile', 0); + if (auth()->check()) { + $query->orWhereIn('users.id', auth()->user()->follows->pluck('id')) + ->orWhere('users.id', auth()->user()->id); + } + }) + ->select([ + 'statuses.user_id', + DB::raw('SUM(train_checkins.points) AS points'), + DB::raw('SUM(train_checkins.distance) AS distance'), + DB::raw(self::getDurationSelector() . ' AS duration'), + DB::raw('SUM(train_checkins.distance) / (' . self::getDurationSelector() . ' / 60) AS speed'), + ]) + ->groupBy('user_id') + ->orderByDesc('points') + ->get(); //Fetch user models in ONE query and map it to the collection $userCache = User::whereIn('id', $data->pluck('user_id'))->get(); - // ToDo: Levin, das Leaderboard gibt jetzt Schnelligkeit und Distance in meter aus. Bitte in vue anpassen. return $data->map(function($row) use ($userCache) { $row->user = $userCache->where('id', $row->user_id)->first(); return $row; From f52e9ce8876bceaa8554ab616fddc0fbf72902e4 Mon Sep 17 00:00:00 2001 From: Kris Date: Sun, 7 Nov 2021 10:58:06 +0100 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=9A=9A=20Prepare=20profile=20url=20to?= =?UTF-8?q?=20match=20beta=20(#614)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/FrontendUserController.php | 2 +- app/Http/Controllers/SitemapController.php | 2 +- app/Notifications/FollowRequestApproved.php | 2 +- app/Notifications/UserFollowed.php | 2 +- .../includes/messages/checkin-success.blade.php | 2 +- resources/views/includes/status.blade.php | 12 ++++++------ resources/views/layouts/app.blade.php | 3 ++- .../views/leaderboard/includes/main-table.blade.php | 2 +- resources/views/leaderboard/month.blade.php | 8 ++++---- resources/views/profile.blade.php | 2 +- resources/views/search.blade.php | 4 ++-- resources/views/settings/follower.blade.php | 12 ++++++------ routes/web.php | 7 ++++--- tests/Feature/MutedProfileVisibilityTest.php | 4 ++-- .../Feature/PrivateProfileFollowerRelationsTest.php | 12 ++++++------ tests/Feature/PrivateProfileVisibilityTest.php | 2 +- ...taticPagesThatMightHaveComputedPropertiesTest.php | 2 +- 17 files changed, 41 insertions(+), 39 deletions(-) diff --git a/app/Http/Controllers/FrontendUserController.php b/app/Http/Controllers/FrontendUserController.php index 9390b4f1c..d3254ca11 100644 --- a/app/Http/Controllers/FrontendUserController.php +++ b/app/Http/Controllers/FrontendUserController.php @@ -124,7 +124,7 @@ public function searchUser(Request $request): Renderable|RedirectResponse { $userSearchResponse = UserBackend::searchUser($request['searchQuery']); if ($userSearchResponse->count() === 1) { - return redirect()->route('account.show', ['username' => $userSearchResponse->first()->username]); + return redirect()->route('profile', ['username' => $userSearchResponse->first()->username]); } } catch (HttpException) { return redirect()->back(); diff --git a/app/Http/Controllers/SitemapController.php b/app/Http/Controllers/SitemapController.php index 00f890391..88c1b3fde 100644 --- a/app/Http/Controllers/SitemapController.php +++ b/app/Http/Controllers/SitemapController.php @@ -88,7 +88,7 @@ private function addProfiles(Sitemap $sitemap): void { ->get(); foreach ($profiles as $profile) { - $url = Url::create(route('account.show', ['username' => $profile->username])) + $url = Url::create(route('profile', ['username' => $profile->username])) ->setPriority(0.5) ->setLastModificationDate(Carbon::parse($profile->last_mod)) ->setChangeFrequency('weekly'); diff --git a/app/Notifications/FollowRequestApproved.php b/app/Notifications/FollowRequestApproved.php index d7eb7da26..dc1154a0a 100644 --- a/app/Notifications/FollowRequestApproved.php +++ b/app/Notifications/FollowRequestApproved.php @@ -44,7 +44,7 @@ public static function render(mixed $notification): ?string { 'icon' => 'fas fa-user-plus', 'lead' => __('notifications.userApprovedFollow.lead', ['followerRequestUsername' => $detail->sender->username]), - 'link' => route('account.show', ['username' => $detail->sender->username]), + 'link' => route('profile', ['username' => $detail->sender->username]), 'notice' => '', 'date_for_humans' => $notification->created_at->diffForHumans(), 'read' => $notification->read_at != null, diff --git a/app/Notifications/UserFollowed.php b/app/Notifications/UserFollowed.php index 98d0cf461..1e90a8805 100644 --- a/app/Notifications/UserFollowed.php +++ b/app/Notifications/UserFollowed.php @@ -43,7 +43,7 @@ public static function render($notification): ?string { 'lead' => __('notifications.userFollowed.lead', [ 'followerUsername' => $detail->sender->username ]), - "link" => route('account.show', ['username' => $detail->sender->username]), + "link" => route('profile', ['username' => $detail->sender->username]), 'notice' => "", 'date_for_humans' => $notification->created_at->diffForHumans(), 'read' => $notification->read_at != null, diff --git a/resources/views/includes/messages/checkin-success.blade.php b/resources/views/includes/messages/checkin-success.blade.php index cc54526f3..4d46b10be 100644 --- a/resources/views/includes/messages/checkin-success.blade.php +++ b/resources/views/includes/messages/checkin-success.blade.php @@ -19,7 +19,7 @@ - + {{ '@' . $otherStatus->user->username }} diff --git a/resources/views/includes/status.blade.php b/resources/views/includes/status.blade.php index 4513e94eb..33d8ea2bb 100644 --- a/resources/views/includes/status.blade.php +++ b/resources/views/includes/status.blade.php @@ -13,7 +13,7 @@
- + {{ $status->user->username }} @@ -122,7 +122,7 @@ class="progress-bar progress-time" {{["fa-globe-americas", "fa-lock-open", "fa-user-friends", "fa-lock"][$status->visibility]}} visibility-icon text-small" aria-hidden="true" title="{{__('status.visibility.'.$status->visibility)}}" data-mdb-toggle="tooltip" data-mdb-placement="top"> - + @if(auth()?->user()?->id == $status->user_id) {{__('user.you')}} @else @@ -139,7 +139,7 @@ class="progress-bar progress-time" @if(auth()->user()->id == $status->user_id && $status->likes->count() !== 0)d-none @endif list-inline-item d-lg-none" id="avatar-small-{{ $status->id }}" data-trwl-selflike="{{ auth()->user()->id == $status->user_id }}"> - + {{__('settings.picture')}} @@ -167,7 +167,7 @@ class="like {{ $status->likes->where('user_id', auth()->user()->id)->first() === @endif @else
  • - + {{__('settings.picture')}} @@ -179,12 +179,12 @@ class="profile-image" alt="{{__('settings.picture')}}"> @if(Route::current()->uri == "status/{id}") @foreach($status->likes as $like)