FEATURE: the ability to permanently destroy the private message (#11115)
PostDestroyer should accept the option to permanently destroy post from the database. In addition, when the first post is destroyed it destroys the whole topic. Currently, that feature is limited to private messages and creator of the post. It will be used by discourse-encrypt to explode encrypted private messages.
This commit is contained in:
committed by
GitHub
parent
27e94f2f98
commit
586c8efbd8
@@ -1424,6 +1424,12 @@ export default Controller.extend(bufferedProperty("model"), {
|
||||
.then(() => refresh({ id: data.id }));
|
||||
break;
|
||||
}
|
||||
case "destroyed": {
|
||||
postStream
|
||||
.triggerDestroyedPost(data.id)
|
||||
.then(() => refresh({ id: data.id }));
|
||||
break;
|
||||
}
|
||||
case "recovered": {
|
||||
postStream
|
||||
.triggerRecoveredPost(data.id)
|
||||
|
||||
@@ -737,6 +737,12 @@ export default RestModel.extend({
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
triggerDestroyedPost(postId) {
|
||||
const existing = this._identityMap[postId];
|
||||
this.removePosts([existing]);
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
triggerChangedPost(postId, updatedAt, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import PreloadStore from "discourse/lib/preload-store";
|
||||
import Category from "discourse/models/category";
|
||||
import User from "discourse/models/user";
|
||||
import { deepEqual } from "discourse-common/lib/object";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
|
||||
function isNew(topic) {
|
||||
return (
|
||||
@@ -148,6 +149,17 @@ const TopicTrackingState = EmberObject.extend({
|
||||
}
|
||||
tracker.incrementMessageCount();
|
||||
});
|
||||
|
||||
this.messageBus.subscribe("/destroy", (msg) => {
|
||||
tracker.incrementMessageCount();
|
||||
const currentRoute = DiscourseURL.router.currentRoute.parent;
|
||||
if (
|
||||
currentRoute.name === "topic" &&
|
||||
parseInt(currentRoute.params.id, 10) === msg.topic_id
|
||||
) {
|
||||
DiscourseURL.redirectTo("/");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
mutedTopics() {
|
||||
|
||||
Reference in New Issue
Block a user