diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index d18e51d9d5..7f34900524 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -50,7 +50,7 @@ class ScheduledStatuses extends BaseApi } $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(); } @@ -59,6 +59,10 @@ class ScheduledStatuses extends BaseApi DI::mstdnError()->RecordNotFound(); } + if (!DBA::delete('workerqueue', ['id' => $post['wid']])) { + DI::mstdnError()->RecordNotFound(); + } + System::jsonExit([]); } diff --git a/src/Module/Profile/Schedule.php b/src/Module/Profile/Schedule.php index bb2c91ef06..675e132db9 100644 --- a/src/Module/Profile/Schedule.php +++ b/src/Module/Profile/Schedule.php @@ -32,14 +32,22 @@ use Friendica\Network\HTTPException; 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(); @@ -78,6 +86,13 @@ class Schedule extends BaseProfile 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']]); } } diff --git a/static/routes.config.php b/static/routes.config.php index 18edde7507..d42d5cfbbf 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -33,8 +33,7 @@ use Friendica\Module; $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]], diff --git a/view/templates/profile/schedule.tpl b/view/templates/profile/schedule.tpl index ae7e085972..57a8f94521 100644 --- a/view/templates/profile/schedule.tpl +++ b/view/templates/profile/schedule.tpl @@ -1,23 +1,27 @@

{{$title}}

-
- - - - - - - - - - {{foreach $schedule as $entry}} - - - - - - {{/foreach}} - -
{{$scheduled_at}}{{$content}}
{{$entry.scheduled_at}}{{$entry.content}} 
-
+ + + + + + + + + {{foreach $schedule as $entry}} + + + + + + {{/foreach}} + +
{{$scheduled_at}}{{$content}}
{{$entry.scheduled_at}}{{$entry.content}} +
+ +
diff --git a/view/theme/frio/templates/profile/schedule.tpl b/view/theme/frio/templates/profile/schedule.tpl index c241285592..8cd0a565cf 100644 --- a/view/theme/frio/templates/profile/schedule.tpl +++ b/view/theme/frio/templates/profile/schedule.tpl @@ -1,31 +1,28 @@
{{* include the title template for the settings title *}} {{include file="section_title.tpl" title=$title}} -
- - - - - - - - - - {{foreach $schedule as $row}} - - - - - - {{/foreach}} - -
{{$scheduled_at}}{{$content}}
{{$row.scheduled_at}}{{$row.content}} - - -
- + + + + + + + + + {{foreach $schedule as $row}} + + + + + + {{/foreach}} + +
{{$scheduled_at}}{{$content}}
{{$row.scheduled_at}}{{$row.content}} +
+ +