mirror of https://git.stjo.hn/planiverse
Fix #5 - Implement deleting statuses
Added a link (and a confirmation page) that allows a user to delete their own Statuses.
This commit is contained in:
parent
9a0fb86099
commit
7fc59f1c58
|
@ -20,7 +20,9 @@ Currently implemented features are:
|
||||||
|
|
||||||
* pagination
|
* pagination
|
||||||
|
|
||||||
* posting, favouriting, reblogging, and replying to statuses
|
* posting and deleting statuses
|
||||||
|
|
||||||
|
* favouriting, reblogging, and replying to statuses
|
||||||
|
|
||||||
* spoiler/content warnings
|
* spoiler/content warnings
|
||||||
|
|
||||||
|
@ -40,8 +42,6 @@ Currently implemented features are:
|
||||||
|
|
||||||
Features still to be implemented include:
|
Features still to be implemented include:
|
||||||
|
|
||||||
* deleting statuses
|
|
||||||
|
|
||||||
* muting/blocking accounts
|
* muting/blocking accounts
|
||||||
|
|
||||||
* uploading attachments
|
* uploading attachments
|
||||||
|
|
|
@ -203,6 +203,47 @@ class StatusController extends Controller
|
||||||
return redirect()->route('home');
|
return redirect()->route('home');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Delete a Status.
|
||||||
|
*
|
||||||
|
* @param string $status_id The ID of the Status to be deleted.
|
||||||
|
*
|
||||||
|
* @return Illuminate\Routing\Redirector Redirect to the home timeline page.
|
||||||
|
*/
|
||||||
|
public function delete_status(string $status_id)
|
||||||
|
{
|
||||||
|
$user = session('user');
|
||||||
|
|
||||||
|
if (session()->has('delete_status') && session('delete_status') === $status_id)
|
||||||
|
{
|
||||||
|
# The user has confirmed the deletion, so go ahead and delete the Status.
|
||||||
|
|
||||||
|
Mastodon::domain(env('MASTODON_DOMAIN'))
|
||||||
|
->token($user->token)
|
||||||
|
->call('DELETE', '/statuses/' . $status_id);
|
||||||
|
|
||||||
|
return redirect()->route('home');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# Render the confirmation page.
|
||||||
|
|
||||||
|
session()->flash('delete_status', $status_id);
|
||||||
|
|
||||||
|
$status = Mastodon::domain(env('MASTODON_DOMAIN'))
|
||||||
|
->token(session('user')->token)
|
||||||
|
->get('/statuses/' . $status_id);
|
||||||
|
|
||||||
|
$vars = [
|
||||||
|
'status' => $status,
|
||||||
|
'mastodon_domain' => explode('//', env('MASTODON_DOMAIN'))[1]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('delete_status', $vars);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the context of a Status.
|
* Show the context of a Status.
|
||||||
*
|
*
|
||||||
|
|
|
@ -71,6 +71,10 @@ div.actions span.reblogged a {
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span#delete {
|
||||||
|
font-size: smaller;
|
||||||
|
}
|
||||||
|
|
||||||
time, span.event-indicators {
|
time, span.event-indicators {
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
|
@ -96,3 +100,7 @@ nav ul li {
|
||||||
display: inline;
|
display: inline;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.warning {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="{{ app()->getLocale() }}">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<title>{{ $mastodon_domain }} | Delete Status</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="{{ url('css/styles.css') }}" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{{ $mastodon_domain }} | Delete Status</h1>
|
||||||
|
|
||||||
|
@component('navigation')
|
||||||
|
@endcomponent
|
||||||
|
|
||||||
|
<p class="warning">Are you sure you want to delete this status? Click the delete link again to confirm.</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
@component('status', ['status' => $status])
|
||||||
|
@endcomponent
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -55,5 +55,12 @@
|
||||||
@endif
|
@endif
|
||||||
{{ $status['favourites_count'] }}
|
{{ $status['favourites_count'] }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
<!-- Delete -->
|
||||||
|
@if (Session::has('user') && Session::get('user')->id === $status['account']['id'])
|
||||||
|
<span title="Delete" id="delete">
|
||||||
|
<a href="{{ route('delete', ['status_id' => $status['id']]) }}">🗙</a>
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</article></li>
|
</article></li>
|
||||||
|
|
|
@ -48,6 +48,10 @@ Route::get('/status/{status_id}/unfavourite', 'StatusController@unfavourite_stat
|
||||||
->name('unfavourite')
|
->name('unfavourite')
|
||||||
->middleware('authorize');
|
->middleware('authorize');
|
||||||
|
|
||||||
|
Route::get('/status/{status_id}/delete', 'StatusController@delete_status')
|
||||||
|
->name('delete')
|
||||||
|
->middleware('authorize');
|
||||||
|
|
||||||
Route::get('/status/{status_id}/thread', 'StatusController@context')
|
Route::get('/status/{status_id}/thread', 'StatusController@context')
|
||||||
->name('thread');
|
->name('thread');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue