Skip to content

Commit 811b832

Browse files
committed
overwrite flag and few adjustments
1 parent 90e5e04 commit 811b832

File tree

9 files changed

+172
-161
lines changed

9 files changed

+172
-161
lines changed

packages/rocketchat-channel-settings/client/views/channelSettings.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,24 @@
226226
</div>
227227
{{/with}}
228228
</div>
229-
{{# if settings.retentionEnabled.value.get }}
229+
{{# if retentionEnabled settings.retentionEnabled.value.get }}
230+
{{#with settings.retentionOverrideGlobal}}
231+
<div class="rc-user-info__row">
232+
<div class="rc-switch rc-switch--blue">
233+
<label class="rc-switch__label">
234+
<span class="rc-switch__text">
235+
{{_ label}}{{equal default value '*'}}
236+
</span>
237+
<input type="checkbox" class="rc-switch__input js-input-check" name="retentionOverrideGlobal" checked="{{checked}}" disabled="{{./disabled}}">
238+
<span class="rc-switch__button">
239+
<span class="rc-switch__button-inside"></span>
240+
</span>
241+
</label>
242+
</div>
243+
</div>
244+
{{/with}}
245+
{{/if}}
246+
{{# if settings.retentionOverrideGlobal.value.get }}
230247
<div class="mail-messages__instructions mail-messages__instructions--warning" style="margin-bottom: 0;">
231248
<div class="mail-messages__instructions-wrapper">
232249
<div class="mail-messages__instructions-text">

packages/rocketchat-channel-settings/client/views/channelSettings.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,31 @@ Template.channelSettingsEditing.onCreated(function() {
522522
return RocketChat.authz.hasAllPermission('edit-room', room._id);
523523
},
524524
save(value) {
525-
return call('saveRoomSettings', room._id, 'retentionEnabled', value).then(
525+
return call('saveRoomSettings', room._id, 'retentionEnabled', value).then(() => toastr.success(t('Retention_setting_changed_successfully')));
526+
}
527+
},
528+
retentionOverrideGlobal: {
529+
type: 'boolean',
530+
label: 'RetentionPolicyRoom_OverrideGlobal',
531+
isToggle: true,
532+
processing: new ReactiveVar(false),
533+
getValue() {
534+
return Template.instance().room.retention && Template.instance().room.retention.overrideGlobal;
535+
},
536+
canView() {
537+
return true;
538+
},
539+
canEdit() {
540+
return RocketChat.authz.hasAllPermission('edit-privileged-setting', room._id);
541+
},
542+
disabled() {
543+
return !RocketChat.authz.hasAllPermission('edit-privileged-setting', room._id);
544+
},
545+
save(value) {
546+
return call('saveRoomSettings', room._id, 'retentionOverrideGlobal', value).then(
526547
() => {
527-
call('saveRoomSettings', room._id, 'retentionOverrideGlobal', value !== undefined).then(
528-
() => {
529-
toastr.success(
530-
t('Retention_setting_changed_successfully')
531-
);
532-
}
548+
toastr.success(
549+
t('Retention_setting_changed_successfully')
533550
);
534551
}
535552
);

packages/rocketchat-lib/server/models/Messages.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,7 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base {
756756
_id: 1
757757
},
758758
limit
759-
}).map((document) => {
760-
return document._id;
761-
});
759+
}).map(({ _id }) => _id);
762760

763761
return this.remove({
764762
_id: {
@@ -776,18 +774,14 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base {
776774
removeFilesByRoomId(roomId) {
777775
this.find({
778776
rid: roomId,
779-
file: {
777+
'file._id': {
780778
$exists: true
781779
}
782780
}, {
783781
fields: {
784-
file: 1
785-
}
786-
}).fetch().map(function(document) {
787-
if (document.file && document.file._id) {
788-
FileUpload.getStore('Uploads').deleteById(document.file._id);
782+
'file._id': 1
789783
}
790-
});
784+
}).fetch().foreach(document => FileUpload.getStore('Uploads').deleteById(document.file._id));
791785
}
792786

793787
getMessageByFileId(fileID) {

packages/rocketchat-lib/server/models/Rooms.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -658,23 +658,14 @@ class ModelRooms extends RocketChat.models._Base {
658658
}
659659

660660
saveRetentionOverrideGlobalById(_id, value) {
661-
const query = {_id};
661+
const query = { _id };
662662

663-
let update = {
663+
const update = {
664664
$set: {
665665
'retention.overrideGlobal': value === true
666666
}
667667
};
668668

669-
if (value === true && this.findOne({_id}, {'retention.maxAge': 1}).retention.maxAge === undefined) {
670-
update = {
671-
$set: {
672-
'retention.overrideGlobal': value === true,
673-
'retention.maxAge': 30
674-
}
675-
};
676-
}
677-
678669
return this.update(query, update);
679670
}
680671

packages/rocketchat-retention-policy/server/cronPruneMessages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function job() {
4141
'retention.maxAge': { $gte: 0 },
4242
_updatedAt: { $gte: lastPrune }
4343
}).forEach(room => {
44-
const { maxAge = 0, filesOnly, excludePinned } = room.retention;
44+
const { maxAge = 30, filesOnly, excludePinned } = room.retention;
4545
const latest = new Date(now.getTime() - maxAge * toDays);
4646
RocketChat.cleanRoomHistory({ rid: room._id, latest, oldest, filesOnly, excludePinned });
4747
});

packages/rocketchat-ui-clean-history/client/views/cleanHistory.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<div class="mail-messages__instructions-wrapper">
7979
{{> icon block="mail-messages__instructions-icon" icon="warning"}}
8080
<div class="mail-messages__instructions-text">
81-
{{warningBox}}
81+
{{warningBox}}
8282
</div>
8383
</div>
8484
</div>

0 commit comments

Comments
 (0)