}
$condtion = ['id' => $parameters['id'], 'uid' => $uid];
- $post = DBA::selectFirst('delayed-post', ['id'], $condtion);
+ $post = DBA::selectFirst('delayed-post', ['id', 'wid'], $condtion);
if (empty($post['id'])) {
DI::mstdnError()->RecordNotFound();
}
DI::mstdnError()->RecordNotFound();
}
+ if (!DBA::delete('workerqueue', ['id' => $post['wid']])) {
+ DI::mstdnError()->RecordNotFound();
+ }
+
System::jsonExit([]);
}
class Schedule extends BaseProfile
{
- public static function content(array $parameters = [])
+ public static function post(array $parameters = [])
{
if (!local_user()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- if (!empty($parameters['id'])) {
- self::deleteSchedule($parameters['id']);
+ if (empty($_REQUEST['delete'])) {
+ throw new HTTPException\BadRequestException();
+ }
+ self::deleteSchedule($_REQUEST['delete']);
+ }
+
+ public static function content(array $parameters = [])
+ {
+ if (!local_user()) {
+ throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$a = DI::app();
private static function deleteSchedule($id)
{
+ $condtion = ['id' => $id, 'uid' => local_user()];
+ $post = DBA::selectFirst('delayed-post', ['id', 'wid'], $condtion);
+ if (empty($post['id'])) {
+ return;
+ }
+
DBA::delete('delayed-post', ['id' => $id, 'uid' => local_user()]);
+ DBA::delete('workerqueue', ['id' => $post['wid']]);
}
}
$profileRoutes = [
'' => [Module\Profile\Index::class, [R::GET]],
'/profile' => [Module\Profile\Profile::class, [R::GET]],
- '/schedule' => [Module\Profile\Schedule::class, [R::GET]],
- '/schedule/delete/{id:\d+}' => [Module\Profile\Schedule::class, [R::GET]],
+ '/schedule' => [Module\Profile\Schedule::class, [R::GET, R::POST]],
'/contacts/common' => [Module\Profile\Common::class, [R::GET]],
'/contacts[/{type}]' => [Module\Profile\Contacts::class, [R::GET]],
'/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class, [R::GET]],
<div class="generic-page-wrapper">
<h1>{{$title}}</h1>
- <form action="profile/{{$nickname}}/schedule" method="post" autocomplete="off">
- <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
- <table id='application-block' class='table table-condensed table-striped'>
- <thead>
- <tr>
- <th>{{$scheduled_at}}</th>
- <th>{{$content}}</th>
- </tr>
- </thead>
- <tbody>
- {{foreach $schedule as $entry}}
- <tr>
- <td>{{$entry.scheduled_at}}</td>
- <td>{{$entry.content}}</td>
- <td><a href="{{$baseurl}}/profile/{{$nickname}}/schedule/delete/{{$entry.id}}?t={{$form_security_token}}" class="icon s22 delete" title="{{$delete}}"> </a></td>
- </tr>
- {{/foreach}}
- </tbody>
- </table>
- </form>
+ <table id='application-block' class='table table-condensed table-striped'>
+ <thead>
+ <tr>
+ <th>{{$scheduled_at}}</th>
+ <th>{{$content}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{foreach $schedule as $entry}}
+ <tr>
+ <td>{{$entry.scheduled_at}}</td>
+ <td>{{$entry.content}}</td>
+ <td>
+ <form action="{{$baseurl}}/profile/{{$nickname}}/schedule" method="post">
+ <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
+ <button type="submit" name="delete" value="{{$row.id}}" title="{{$delete}}">
+ <i class="fa fa-trash" aria-hidden="true">
+ </button>
+ </form>
+ </td>
+ </tr>
+ {{/foreach}}
+ </tbody>
+ </table>
</div>
<div class="generic-page-wrapper">
{{* include the title template for the settings title *}}
{{include file="section_title.tpl" title=$title}}
- <form action="profile/{{$nickname}}/schedule" method="post" autocomplete="off">
- <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
- <table id='application-block' class='table table-condensed table-striped'>
- <thead>
- <tr>
- <th>{{$scheduled_at}}</th>
- <th>{{$content}}</th>
- </tr>
- </thead>
- <tbody>
- {{foreach $schedule as $row}}
- <tr>
- <td>{{$row.scheduled_at}}</td>
- <td>{{$row.content}}</td>
- <td>
- <form action="{{$baseurl}}/profile/{{$nickname}}/schedule" method="post">
- <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
- <button type="submit" name="delete" value="{{$row.id}}" title="{{$delete}}">
- <i class="fa fa-trash" aria-hidden="true">
- </button>
- </form>
- </td>
- </tr>
- {{/foreach}}
- </tbody>
- </table>
- </form>
+ <table id='application-block' class='table table-condensed table-striped'>
+ <thead>
+ <tr>
+ <th>{{$scheduled_at}}</th>
+ <th>{{$content}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{foreach $schedule as $row}}
+ <tr>
+ <td>{{$row.scheduled_at}}</td>
+ <td>{{$row.content}}</td>
+ <td>
+ <form action="{{$baseurl}}/profile/{{$nickname}}/schedule" method="post">
+ <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
+ <button type="submit" name="delete" value="{{$row.id}}" title="{{$delete}}">
+ <i class="fa fa-trash" aria-hidden="true">
+ </button>
+ </form>
+ </td>
+ </tr>
+ {{/foreach}}
+ </tbody>
+ </table>
</div>