1
0
Daniel Supernault 6 жил өмнө
parent
commit
580bfd0bbe

+ 5 - 2
app/Http/Controllers/StatusController.php

@@ -133,8 +133,11 @@ class StatusController extends Controller
         if ($status->profile_id === Auth::user()->profile->id || Auth::user()->is_admin == true) {
             StatusDelete::dispatch($status);
         }
-
-        return redirect(Auth::user()->url());
+        if($request->wantsJson()) {
+            return response()->json(['Status successfully deleted.']);
+        } else {
+            return redirect(Auth::user()->url());
+        }
     }
 
     public function storeShare(Request $request)

+ 1 - 4
app/Jobs/StatusPipeline/StatusDelete.php

@@ -38,15 +38,12 @@ class StatusDelete implements ShouldQueue
     public function handle()
     {
         $status = $this->status;
+
         $this->unlinkRemoveMedia($status);
     }
 
     public function unlinkRemoveMedia($status)
     {
-        if ($status->media()->count() == 0) {
-            return;
-        }
-
         foreach ($status->media as $media) {
             $thumbnail = storage_path("app/{$media->thumbnail_path}");
             $photo = storage_path("app/{$media->media_path}");

BIN
public/js/components.js


BIN
public/mix-manifest.json


+ 6 - 1
resources/assets/js/components.js

@@ -114,4 +114,9 @@ $(document).ready(function() {
   $(function () {
     $('[data-toggle="tooltip"]').tooltip()
   });
-});
+});
+
+const warningTitleCSS = 'color:red; font-size:60px; font-weight: bold; -webkit-text-stroke: 1px black;';
+const warningDescCSS = 'font-size: 18px;';
+console.log('%cStop!', warningTitleCSS);
+console.log("%cThis is a browser feature intended for developers. If someone told you to copy and paste something here to enable a Pixelfed feature or \"hack\" someone's account, it is a scam and will give them access to your Pixelfed account.", warningDescCSS);

+ 12 - 1
resources/assets/js/components/PostComments.vue

@@ -37,6 +37,7 @@
             <b-dropdown-item class="font-weight-bold" :href="comment.account.url">Profile</b-dropdown-item>
             <b-dropdown-divider></b-dropdown-divider>
             <b-dropdown-item class="font-weight-bold" :href="'/i/report?type=post&id='+comment.id">Report</b-dropdown-item>
+            <b-dropdown-item class="font-weight-bold" v-on:click="deleteComment(comment.id, index)" v-if="comment.account.id == user.id">Delete</b-dropdown-item>
           </b-dropdown>
         </span>
       </p>
@@ -47,7 +48,7 @@
 
 <script>
 export default {
-    props: ['post-id', 'post-username'],
+    props: ['post-id', 'post-username', 'user'],
     data() {
         return {
             results: {},
@@ -67,6 +68,16 @@ export default {
       embed(e) {
           pixelfed.embed.build(e);
       },
+      deleteComment(id, i) {
+        axios.post('/i/delete', {
+          type: 'comment',
+          item: id
+        }).then(res => {
+          this.results.splice(i, 1);
+        }).catch(err => {
+          swal('Something went wrong!', 'Please try again later', 'error');
+        });
+      },
       l(e) {
         let len = e.length;
         if(len < 10) { return e; } 

+ 2 - 4
resources/assets/js/components/PostComponent.vue

@@ -201,7 +201,7 @@
                   <span class="font-weight-bold pr-1">{{statusUsername}}</span>
                   <span class="comment-text"></span>
                 </p>
-                <post-comments :post-id="statusId" :post-username="statusUsername"></post-comments>
+                <post-comments :user="this.user" :post-id="statusId" :post-username="statusUsername"></post-comments>
               </div>
             </div>
             <div class="card-body flex-grow-0 py-1">
@@ -266,7 +266,7 @@
 pixelfed.postComponent = {};
 pixelfed.presenter = {
   show: {
-    image: function(container, media) { console.log(234);
+    image: function(container, media) {
       let wrapper = $('<div>');
       wrapper.addClass(media[0]['filter_class']);
       let el = $('<img>');
@@ -345,9 +345,7 @@ export default {
       },
       showMuteBlock() {
         let sid = this.status.account.id;
-        console.log('sid :' + sid);
         let uid = this.user.id;
-        console.log('uid :' + uid);
         if(sid != uid) {
           $('.post-actions').removeClass('d-none');
         }

+ 13 - 1
resources/views/status/reply.blade.php

@@ -26,7 +26,19 @@
             <div class="media-body">
               <h5 class="mt-0 font-weight-bold">{{$status->profile->username}}</h5>
               <p class="mb-1">{!! $status->rendered !!}</p>
-              <p class="mb-0"><a href="{{$status->url()}}" class="text-muted">{{$status->created_at->diffForHumans()}}</a></p>
+              <div class="mb-0">
+                <a href="{{$status->url()}}" class="text-muted">
+                  {{$status->created_at->diffForHumans()}}
+                </a>
+                @if(Auth::check() && $status->profile_id == Auth::user()->profile->id)
+                <form class="float-right" method="POST" action="/i/delete">
+                  @csrf
+                  <input type="hidden" name="item" value="{{$status->id}}">
+                  <input type="hidden" name="type" value="status">
+                  <button class="btn btn-outline-danger small font-weight-bold btn-sm py-1">Delete</button>
+                </form>
+                @endif
+              </div>
             </div>
           </div>
         </div>