From 580bfd0bbe762c706dbf42b11e0210e40d8e43bc Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 22 Nov 2018 13:21:36 -0700 Subject: [PATCH] Fixes #577 --- app/Http/Controllers/StatusController.php | 7 +++++-- app/Jobs/StatusPipeline/StatusDelete.php | 5 +---- public/js/components.js | 2 +- public/mix-manifest.json | 2 +- resources/assets/js/components.js | 7 ++++++- resources/assets/js/components/PostComments.vue | 13 ++++++++++++- resources/assets/js/components/PostComponent.vue | 6 ++---- resources/views/status/reply.blade.php | 14 +++++++++++++- 8 files changed, 41 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index fb5545c48..db0b0f453 100644 --- a/app/Http/Controllers/StatusController.php +++ b/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) diff --git a/app/Jobs/StatusPipeline/StatusDelete.php b/app/Jobs/StatusPipeline/StatusDelete.php index 6a585fcbe..9cf6fe030 100644 --- a/app/Jobs/StatusPipeline/StatusDelete.php +++ b/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}"); diff --git a/public/js/components.js b/public/js/components.js index 390df0c17..e41f02e8f 100644 --- a/public/js/components.js +++ b/public/js/components.js @@ -1 +1 @@ -!function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=2)}({"/7en":function(t,e,n){var i,r;"undefined"!=typeof window&&window,void 0===(r="function"==typeof(i=function(){"use strict";function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var n=this._events=this._events||{},i=n[t]=n[t]||[];return-1==i.indexOf(e)&&i.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var n=this._onceEvents=this._onceEvents||{};return(n[t]=n[t]||{})[e]=!0,this}},e.off=function(t,e){var n=this._events&&this._events[t];if(n&&n.length){var i=n.indexOf(e);return-1!=i&&n.splice(i,1),this}},e.emitEvent=function(t,e){var n=this._events&&this._events[t];if(n&&n.length){n=n.slice(0),e=e||[];for(var i=this._onceEvents&&this._onceEvents[t],r=0;r1&&($(".section-people .lds-ring").hide(),$(".section-people .row.d-none").removeClass("d-none")),t.posts.length>1&&($(".section-explore .lds-ring").hide(),$(".section-explore .row.d-none").removeClass("d-none"))})}}}},"1/oy":function(t,e,n){var i=n("eAYY");"string"==typeof i&&(i=[[t.i,i,""]]);var r={transform:void 0};n("MTIv")(i,r);i.locals&&(t.exports=i.locals)},"162o":function(t,e,n){(function(t){var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(r.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new o(r.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n("mypn"),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(e,n("DuR2"))},"1MO9":function(t,e,n){(t.exports=n("FZ+f")(!1)).push([t.i,"input.form-control[type=color],input.form-control[type=range]{height:2.25rem}input.form-control.form-control-sm[type=color],input.form-control.form-control-sm[type=range]{height:1.9375rem}input.form-control.form-control-lg[type=color],input.form-control.form-control-lg[type=range]{height:3rem}input.form-control[type=color]{padding:.25rem}input.form-control.form-control-sm[type=color]{padding:.125rem}",""])},2:function(t,e,n){t.exports=n("Tkmu")},"20cu":function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={data:function(){return{tokens:[]}},ready:function(){this.prepareComponent()},mounted:function(){this.prepareComponent()},methods:{prepareComponent:function(){this.getTokens()},getTokens:function(){var t=this;axios.get("/oauth/tokens").then(function(e){t.tokens=e.data})},revoke:function(t){var e=this;axios.delete("/oauth/tokens/"+t.id).then(function(t){e.getTokens()})}}}},"3G5u":function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("div",[n("div",{staticClass:"card card-default mb-4"},[n("div",{staticClass:"card-header font-weight-bold bg-white"},[n("div",{staticStyle:{display:"flex","justify-content":"space-between","align-items":"center"}},[n("span",[t._v("\n Personal Access Tokens\n ")]),t._v(" "),n("a",{staticClass:"action-link",attrs:{tabindex:"-1"},on:{click:t.showCreateTokenForm}},[t._v("\n Create New Token\n ")])])]),t._v(" "),n("div",{staticClass:"card-body"},[0===t.tokens.length?n("p",{staticClass:"mb-0"},[t._v("\n You have not created any personal access tokens.\n ")]):t._e(),t._v(" "),t.tokens.length>0?n("table",{staticClass:"table table-borderless mb-0"},[t._m(0),t._v(" "),n("tbody",t._l(t.tokens,function(e){return n("tr",[n("td",{staticStyle:{"vertical-align":"middle"}},[t._v("\n "+t._s(e.name)+"\n ")]),t._v(" "),n("td",{staticStyle:{"vertical-align":"middle"}},[n("a",{staticClass:"action-link text-danger",on:{click:function(n){t.revoke(e)}}},[t._v("\n Delete\n ")])])])}))]):t._e()])])]),t._v(" "),n("div",{staticClass:"modal fade",attrs:{id:"modal-create-token",tabindex:"-1",role:"dialog"}},[n("div",{staticClass:"modal-dialog"},[n("div",{staticClass:"modal-content"},[t._m(1),t._v(" "),n("div",{staticClass:"modal-body"},[t.form.errors.length>0?n("div",{staticClass:"alert alert-danger"},[t._m(2),t._v(" "),n("br"),t._v(" "),n("ul",t._l(t.form.errors,function(e){return n("li",[t._v("\n "+t._s(e)+"\n ")])}))]):t._e(),t._v(" "),n("form",{attrs:{role:"form"},on:{submit:function(e){return e.preventDefault(),t.store(e)}}},[n("div",{staticClass:"form-group row"},[n("label",{staticClass:"col-md-4 col-form-label"},[t._v("Name")]),t._v(" "),n("div",{staticClass:"col-md-6"},[n("input",{directives:[{name:"model",rawName:"v-model",value:t.form.name,expression:"form.name"}],staticClass:"form-control",attrs:{id:"create-token-name",type:"text",name:"name",autocomplete:"off"},domProps:{value:t.form.name},on:{input:function(e){e.target.composing||t.$set(t.form,"name",e.target.value)}}})])]),t._v(" "),t.scopes.length>0?n("div",{staticClass:"form-group row"},[n("label",{staticClass:"col-md-4 col-form-label"},[t._v("Scopes")]),t._v(" "),n("div",{staticClass:"col-md-6"},t._l(t.scopes,function(e){return n("div",[n("div",{staticClass:"checkbox"},[n("label",[n("input",{attrs:{type:"checkbox"},domProps:{checked:t.scopeIsAssigned(e.id)},on:{click:function(n){t.toggleScope(e.id)}}}),t._v("\n\n "+t._s(e.id)+"\n ")])])])}))]):t._e()])]),t._v(" "),n("div",{staticClass:"modal-footer"},[n("button",{staticClass:"btn btn-secondary font-weight-bold",attrs:{type:"button","data-dismiss":"modal"}},[t._v("Close")]),t._v(" "),n("button",{staticClass:"btn btn-primary font-weight-bold",attrs:{type:"button"},on:{click:t.store}},[t._v("\n Create\n ")])])])])]),t._v(" "),n("div",{staticClass:"modal fade",attrs:{id:"modal-access-token",tabindex:"-1",role:"dialog"}},[n("div",{staticClass:"modal-dialog"},[n("div",{staticClass:"modal-content"},[t._m(3),t._v(" "),n("div",{staticClass:"modal-body"},[n("p",[t._v("\n Here is your new personal access token. This is the only time it will be shown so don't lose it!\n You may now use this token to make API requests.\n ")]),t._v(" "),n("textarea",{staticClass:"form-control",attrs:{rows:"10"}},[t._v(t._s(t.accessToken))])]),t._v(" "),t._m(4)])])])])},staticRenderFns:[function(){var t=this.$createElement,e=this._self._c||t;return e("thead",[e("tr",[e("th",[this._v("Name")]),this._v(" "),e("th")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"modal-header"},[e("h4",{staticClass:"modal-title"},[this._v("\n Create Token\n ")]),this._v(" "),e("button",{staticClass:"close",attrs:{type:"button","data-dismiss":"modal","aria-hidden":"true"}},[this._v("×")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("p",{staticClass:"mb-0"},[e("strong",[this._v("Whoops!")]),this._v(" Something went wrong!")])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"modal-header"},[e("h4",{staticClass:"modal-title"},[this._v("\n Personal Access Token\n ")]),this._v(" "),e("button",{staticClass:"close",attrs:{type:"button","data-dismiss":"modal","aria-hidden":"true"}},[this._v("×")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"modal-footer"},[e("button",{staticClass:"btn btn-secondary",attrs:{type:"button","data-dismiss":"modal"}},[this._v("Close")])])}]}},"3H+/":function(t,e,n){var i,r;!function(o,a){i=[n("/7en"),n("h803")],void 0===(r=function(t,e){return a(o,t,e)}.apply(e,i))||(t.exports=r)}(window,function(t,e,n){var i=t.jQuery,r={};function o(t,e){var a=n.getQueryElement(t);if(a){if((t=a).infiniteScrollGUID){var s=r[t.infiniteScrollGUID];return s.option(e),s}this.element=t,this.options=n.extend({},o.defaults),this.option(e),i&&(this.$element=i(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(a||t))}o.defaults={},o.create={},o.destroy={};var a=o.prototype;n.extend(a,e.prototype);var s=0;a.create=function(){var t=this.guid=++s;if(this.element.infiniteScrollGUID=t,r[t]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath())for(var e in this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit(),o.create)o.create[e].call(this);else console.error("Disabling InfiniteScroll")},a.option=function(t){n.extend(this.options,t)},a.callOnInit=function(){var t=this.options.onInit;t&&t.call(this,this)},a.dispatchEvent=function(t,e,n){this.log(t,n);var r=e?[e].concat(n):n;if(this.emitEvent(t,r),i&&this.$element){var o=t+=".infiniteScroll";if(e){var a=i.Event(e);a.type=t,o=a}this.$element.trigger(o,n)}};var l={initialized:function(t){return"on "+t},request:function(t){return"URL: "+t},load:function(t,e){return(t.title||"")+". URL: "+e},error:function(t,e){return t+". URL: "+e},append:function(t,e,n){return n.length+" items. URL: "+e},last:function(t,e){return"URL: "+e},history:function(t,e){return"URL: "+e},pageIndex:function(t,e){return"current page determined to be: "+t+" from "+e}};a.log=function(t,e){if(this.options.debug){var n="[InfiniteScroll] "+t,i=l[t];i&&(n+=". "+i.apply(this,e)),console.log(n)}},a.updateMeasurements=function(){this.windowHeight=t.innerHeight;var e=this.element.getBoundingClientRect();this.top=e.top+t.pageYOffset},a.updateScroller=function(){var e=this.options.elementScroll;if(e){if(this.scroller=!0===e?this.element:n.getQueryElement(e),!this.scroller)throw"Unable to find elementScroll: "+e}else this.scroller=t},a.updateGetPath=function(){var t=this.options.path;if(t){var e=typeof t;if("function"!=e)"string"==e&&t.match("{{#}}")?this.updateGetPathTemplate(t):this.updateGetPathSelector(t);else this.getPath=t}else console.error("InfiniteScroll path option required. Set as: "+t)},a.updateGetPathTemplate=function(t){this.getPath=function(){var e=this.pageIndex+1;return t.replace("{{#}}",e)}.bind(this);var e=t.replace("{{#}}","(\\d\\d?\\d?)"),n=new RegExp(e),i=location.href.match(n);i&&(this.pageIndex=parseInt(i[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};var c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/];return a.updateGetPathSelector=function(t){var e=document.querySelector(t);if(e){for(var n,i,r=e.getAttribute("href"),o=0;r&&o=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},n.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},n.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},e})},"99Qu":function(t,e,n){var i,r;!function(o,a){i=[n("3H+/"),n("h803")],void 0===(r=function(t,e){return a(o,t,e)}.apply(e,i))||(t.exports=r)}(window,function(t,e,n){var i=e.prototype;return e.defaults.scrollThreshold=400,e.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);var t=this.options.scrollThreshold;(t||0===t)&&this.enableScrollWatch()},e.destroy.scrollWatch=function(){this.disableScrollWatch()},i.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},i.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},i.bindScrollWatchEvents=function(e){var n=e?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.pageScrollHandler),t[n]("resize",this.resizeHandler)},i.onPageScroll=e.throttle(function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")}),i.getBottomDistance=function(){return this.options.elementScroll?this.getElementBottomDistance():this.getWindowBottomDistance()},i.getWindowBottomDistance=function(){return this.top+this.element.clientHeight-(t.pageYOffset+this.windowHeight)},i.getElementBottomDistance=function(){return this.scroller.scrollHeight-(this.scroller.scrollTop+this.scroller.clientHeight)},i.onResize=function(){this.updateMeasurements()},n.debounceMethod(e,"onResize",150),e})},"A/e+":function(t,e,n){var i=n("VU/8")(n("5m3O"),n("ITff"),!1,function(t){n("SZtu")},"data-v-6c5fc404",null);t.exports=i.exports},BXHd:function(t,e){$(document).ready(function(){$(document).on("submit",".bookmark-form",function(t){t.preventDefault();var e=$(this).data("id");axios.post("/i/bookmark",{item:e})})})},"Bx+d":function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),pixelfed.postComponent={},pixelfed.presenter={show:{image:function(t,e){console.log(234);var n=$("
");n.addClass(e[0].filter_class);var i=$("");i.attr("src",e[0].url),i.attr("title",e[0].description),n.append(i),t.append(n)},video:function(t,e){var n=$("
");n.addClass("embed-responsive embed-responsive-4by3");var i=$("