]> git.mxchange.org Git - friendica.git/commitdiff
Using "post" when deleting, fixing deleting
authorMichael <heluecht@pirati.ca>
Mon, 2 Aug 2021 19:18:44 +0000 (19:18 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 2 Aug 2021 19:18:44 +0000 (19:18 +0000)
src/Module/Api/Mastodon/ScheduledStatuses.php
src/Module/Profile/Schedule.php
static/routes.config.php
view/templates/profile/schedule.tpl
view/theme/frio/templates/profile/schedule.tpl

index d18e51d9d51fa1e4969465055c06d74cd997497c..7f34900524674126a5a0b6cbf2c701d2ff2aa54c 100644 (file)
@@ -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([]);
        }
 
index bb2c91ef062b9f701ec8918147d15a4ba3263cbb..675e132db91a98e835ef8bcb59c453fda46de45b 100644 (file)
@@ -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']]);
        }
 }
index 18edde75070a1efc18bb34a87e24960f7986a137..d42d5cfbbfa460370a22b59920ba89b57ecdb87b 100644 (file)
@@ -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]],
index ae7e0859729b70d6d82b585b4007badc3b3629ca..57a8f94521b0c8cfe85abc20c707b3fdcbbbbba6 100644 (file)
@@ -1,23 +1,27 @@
 <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}}">&nbsp;</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>
index c241285592f0b444cfb7689bda2361d5dbe99b4b..8cd0a565cf5cd1be9ef483c5e861713fd6d19467 100644 (file)
@@ -1,31 +1,28 @@
 <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>