Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Prune Threads #13683

Merged
merged 4 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/rocketchat-models/server/models/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export class Messages extends Base {
this.tryEnsureIndex({ snippeted: 1 }, { sparse: 1 });
this.tryEnsureIndex({ location: '2dsphere' });
this.tryEnsureIndex({ slackBotId: 1, slackTs: 1 }, { sparse: 1 });
this.tryEnsureIndex({ unread: 1 }, { sparse: true });
this.tryEnsureIndex({ unread: 1 }, { sparse: 1 });

// threads
this.tryEnsureIndex({ trid: 1 }, { sparse: true });
this.tryEnsureIndex({ trid: 1 }, { sparse: 1 });

this.loadSettings();
}
Expand Down Expand Up @@ -171,7 +171,7 @@ export class Messages extends Base {
query.pinned = { $ne: true };
}

if (!ignoreThreads) {
if (ignoreThreads) {
sampaiodiego marked this conversation as resolved.
Show resolved Hide resolved
query.trid = { $exists: 0 };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
{{> icon icon="check" block="rc-checkbox__icon"}}
<span class="rc-checkbox__text rc-text__small">{{_ "Exclude_pinned"}}</span>
</label>
<label class="rc-checkbox">
<input type="checkbox" name="ignoreThreads" class="rc-checkbox__input">
{{> icon icon="check" block="rc-checkbox__icon"}}
<span class="rc-checkbox__text rc-text__small">{{_ "RetentionPolicy_DoNotExcludeThreads"}}</span>
</label>
<label class="rc-checkbox">
<input type="checkbox" name="filesOnly" class="rc-checkbox__input">
{{> icon icon="check" block="rc-checkbox__icon"}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ const getRoomName = function() {
return t('conversation_with_s', roomTypes.getRoomName(room.t, room));
};

const purgeWorker = function(roomId, oldest, latest, inclusive, limit, excludePinned, filesOnly, fromUsers) {
const purgeWorker = function(roomId, oldest, latest, inclusive, limit, excludePinned, ignoreThreads, filesOnly, fromUsers) {
return call('cleanRoomHistory', {
roomId,
latest,
oldest,
inclusive,
limit,
excludePinned,
ignoreThreads,
filesOnly,
fromUsers,
});
Expand Down Expand Up @@ -139,6 +140,8 @@ Template.cleanHistory.onCreated(function() {
this.cleanHistoryExcludePinned = new ReactiveVar(false);
this.cleanHistoryFilesOnly = new ReactiveVar(false);

this.ignoreThreads = new ReactiveVar(false);


this.cleanHistoryBusy = new ReactiveVar(false);
this.cleanHistoryFinished = new ReactiveVar(false);
Expand Down Expand Up @@ -271,6 +274,9 @@ Template.cleanHistory.events({
'change [name=filesOnly]'(e, instance) {
instance.cleanHistoryFilesOnly.set(e.target.checked);
},
'change [name=ignoreThreads]'(e, instance) {
instance.ignoreThreads.set(e.target.checked);
},
'click .js-prune'(e, instance) {

modal.open({
Expand All @@ -293,6 +299,7 @@ Template.cleanHistory.events({
const metaCleanHistoryInclusive = instance.cleanHistoryInclusive.get();
const metaCleanHistoryExcludePinned = instance.cleanHistoryExcludePinned.get();
const metaCleanHistoryFilesOnly = instance.cleanHistoryFilesOnly.get();
const ignoreThreads = instance.ignoreThreads.get();

let fromDate = new Date('0001-01-01T00:00:00Z');
let toDate = new Date('9999-12-31T23:59:59Z');
Expand All @@ -311,7 +318,7 @@ Template.cleanHistory.events({
let count = 0;
let result;
do {
result = await purgeWorker(roomId, fromDate, toDate, metaCleanHistoryInclusive, limit, metaCleanHistoryExcludePinned, metaCleanHistoryFilesOnly, users);
result = await purgeWorker(roomId, fromDate, toDate, metaCleanHistoryInclusive, limit, metaCleanHistoryExcludePinned, ignoreThreads, metaCleanHistoryFilesOnly, users);
count += result;
} while (result === limit);

Expand Down