Implement reblogging

Implemented ability to reblog a status.
This commit is contained in:
St John Karp 2018-08-19 10:50:28 -07:00
parent d95406c407
commit d2c1874f0b
4 changed files with 31 additions and 3 deletions

View File

@ -13,7 +13,7 @@ class StatusController extends Controller
{
// The user has a session and may be here to favourite/unfavourite
// a status.
if (session()->has('user'))
if (session()->has('user') && $request->has('action'))
{
$user = session('user');
if ($request->action === 'favourite')
@ -28,6 +28,18 @@ class StatusController extends Controller
->token($user->token)
->post('/statuses/' . $status_id . '/unfavourite');
}
elseif ($request->action === 'reblog')
{
$status = Mastodon::domain(env('MASTODON_DOMAIN'))
->token($user->token)
->post('/statuses/' . $status_id . '/reblog');
}
elseif ($request->action === 'unreblog')
{
$status = Mastodon::domain(env('MASTODON_DOMAIN'))
->token($user->token)
->post('/statuses/' . $status_id . '/unreblog');
}
}
// If the status hasn't been returned from performing an action on it,

View File

@ -67,6 +67,10 @@ div.actions span.favourited a {
color: goldenrod;
}
div.actions span.reblogged a {
color: green;
}
time {
font-size: smaller;
margin-left: 1em;

View File

@ -12,6 +12,9 @@
<body>
<h1>{{ $mastodon_domain }} | Status</h1>
@component('navigation')
@endcomponent
@component('status', ['status' => $status])
@endcomponent

View File

@ -38,13 +38,22 @@
<!-- Reblog -->
<span>
&#8644; {{ $status['reblogs_count'] }}
@if ($status['reblogged'])
<span class="reblogged">
<a href="/status/{{ $status['id'] }}?action=unreblog">&#8644;</a>
</span>
@else
<a href="/status/{{ $status['id'] }}?action=reblog">&#8644;</a>
@endif
{{ $status['reblogs_count'] }}
</span>
<!-- Favourite -->
<span>
@if ($status['favourited'])
<span class="favourited"><a href="/status/{{ $status['id'] }}?action=unfavourite">&#9733;</a></span>
<span class="favourited">
<a href="/status/{{ $status['id'] }}?action=unfavourite">&#9733;</a>
</span>
@else
<a href="/status/{{ $status['id'] }}?action=favourite">&#9734;</a>
@endif