mirror of
https://github.com/wassname/talk.git
synced 2026-08-18 12:30:39 +08:00
autoclose an article toggle
This commit is contained in:
@@ -37,6 +37,11 @@ const updateInfoBoxContent = (updateSettings) => (event) => {
|
||||
updateSettings({infoBoxContent});
|
||||
};
|
||||
|
||||
const updateAutoClose = (updateSettings, autoCloseStream) => () => {
|
||||
console.log('autoCloseStream', autoCloseStream);
|
||||
updateSettings({autoCloseStream});
|
||||
};
|
||||
|
||||
const updateClosedMessage = (updateSettings) => (event) => {
|
||||
const closedMessage = event.target.value;
|
||||
updateSettings({closedMessage});
|
||||
@@ -131,6 +136,11 @@ const StreamSettings = ({updateSettings, settingsError, settings, errors}) => {
|
||||
</div>
|
||||
</Card>
|
||||
<Card className={`${styles.configSetting} ${styles.configSettingInfoBox}`}>
|
||||
<div className={styles.action}>
|
||||
<Checkbox
|
||||
onChange={updateAutoClose(updateSettings, !settings.autoCloseStream)}
|
||||
checked={settings.autoCloseStream} />
|
||||
</div>
|
||||
<div className={styles.content}>
|
||||
{lang.t('configure.close-after')}
|
||||
<br />
|
||||
|
||||
@@ -47,6 +47,10 @@ const SettingSchema = new Schema({
|
||||
organizationName: {
|
||||
type: String
|
||||
},
|
||||
autoCloseStream: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
closedTimeout: {
|
||||
type: Number,
|
||||
|
||||
|
||||
+13
-1
@@ -57,12 +57,24 @@ module.exports = class AssetsService {
|
||||
static findOrCreateByUrl(url) {
|
||||
|
||||
// Check the URL to confirm that is in the domain whitelist
|
||||
return domainlist.urlCheck(url).then((whitelisted) => {
|
||||
return Promise.all([
|
||||
domainlist.urlCheck(url),
|
||||
SettingsService.retrieve()
|
||||
]).then(([whitelisted, settings]) => {
|
||||
|
||||
const setOnInsert = {url};
|
||||
|
||||
if (settings.autoCloseStream) {
|
||||
setOnInsert.closedAt = new Date(Date.now() + settings.closedTimeout * 1000);
|
||||
}
|
||||
|
||||
if (!whitelisted) {
|
||||
return Promise.reject(errors.ErrInvalidAssetURL);
|
||||
} else {
|
||||
return AssetModel.findOneAndUpdate({url}, {url}, {
|
||||
|
||||
$setOnInsert: setOnInsert,
|
||||
|
||||
// Ensure that if it's new, we return the new object created.
|
||||
new: true,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user