Skip to content

Commit

Permalink
fix deleted discussion closes #13689
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Apr 6, 2019
1 parent 49b7978 commit 44ac327
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/discussion/server/hooks/propagateDiscussionMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ callbacks.add('afterDeleteMessage', function(message, { _id, prid } = {}) {
callbacks.add('afterDeleteRoom', function(rid) {
Rooms.find({ prid: rid }, { fields: { _id: 1 } }).forEach(({ _id }) => deleteRoom(_id));
}, 'DeleteDiscussionChain');


callbacks.add('afterDeleteRoom', function(drid) {
Messages.update({ drid }, {
$unset: {
dcount: 1,
dlm: 1,
drid: 1,
},
});
}, 'CleanDiscussionMessage');
1 change: 1 addition & 0 deletions server/startup/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,5 @@ import './v136';
import './v137';
import './v138';
import './v139';
import './v140';
import './xrun';
17 changes: 17 additions & 0 deletions server/startup/migrations/v140.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Migrations } from '../../../app/migrations/server';

import { Messages, Rooms } from '../../../app/models/server';

Migrations.add({
version: 140,
up() {
Messages.find({ drid: { $exists: 1 } }, { fields: { drid: 1 } }).forEach(({ _id, drid }) => Rooms.findOne({ _id: drid }) || Messages.update({ _id }, {
$unset: {
drid: 1,
dcount: 1,
dlm: 1,
t: 1,
},
}));
},
});

0 comments on commit 44ac327

Please sign in to comment.