planiverse

A minimalist, no-JS front-end for Mastodon.
git clone https://git.stjo.hn/planiverse
Log | Files | Refs | README | LICENSE

commit 157b9eed4824c0bf388df65dc214b2d643f9c358
parent 2bdea8f08849cd8897fd79db4c208e372c2c4f68
Author: St John Karp <stjohn@fuzzjunket.com>
Date:   Wed, 10 Oct 2018 15:09:51 -0700

Exclude the logged-in user from reply mentions

When posting a reply, exclude the current user from the automatically
populated list of mentions.

Diffstat:
Mapp/Http/Controllers/StatusController.php | 23++++++++++++++++++++++-
Mresources/views/show_status.blade.php | 2+-
2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php @@ -39,10 +39,31 @@ class StatusController extends Controller } } + // Compile a list of accounts to include in the reply. + $reply_mentions = []; + if (session()->has('user')) + { + // Include the original poster, if not the current user. + if ($status['account']['acct'] !== session('user')->user['acct']) + { + array_push($reply_mentions, '@' . $status['account']['acct']); + } + + // Include all mentions, excluding the current user. + foreach ($status['mentions'] as $mention) + { + if ($mention['acct'] !== session('user')->user['acct']) + { + array_push($reply_mentions, '@' . $mention['acct']); + } + } + } + $vars = [ 'status' => $status, 'mastodon_domain' => explode('//', env('MASTODON_DOMAIN'))[1], - 'logged_in' => session()->has('user') + 'logged_in' => session()->has('user'), + 'reply_mentions' => implode(' ', $reply_mentions) ]; return view('show_status', $vars); diff --git a/resources/views/show_status.blade.php b/resources/views/show_status.blade.php @@ -28,7 +28,7 @@ placeholder="Spoiler/Warning" value="{{ $status['spoiler_text'] }}" /> - <textarea rows="4" name="status" placeholder="Reply" required autofocus>{{ '@' . $status['account']['acct'] }} @foreach ($status['mentions'] as $mention){{ '@' . $mention['acct'] }} @endforeach</textarea> + <textarea rows="4" name="status" placeholder="Reply" required autofocus>{{ $reply_mentions }} </textarea> <select name="visibility"> <option value="public" @if ($status['visibility'] === 'public') selected @endif>Public</option> <option value="unlisted" @if ($status['visibility'] === 'unlisted') selected @endif>Unlisted</option>