Terms&Conditions (#18):
* new settings for instance's terms * new channel option for channel's terms
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import type { ChannelConfigurationOptions } from '../../../../shared/lib/types'
|
||||
import { channelTermsMaxLength } from '../../../../shared/lib/constants'
|
||||
|
||||
/**
|
||||
* Sanitize data so that they can safely be used/stored for channel configuration configuration.
|
||||
@ -43,6 +44,16 @@ async function sanitizeChannelConfigurationOptions (
|
||||
throw new Error('Invalid data.mute data type')
|
||||
}
|
||||
|
||||
// terms not present in livechat <= 10.2.0
|
||||
let terms = data.terms
|
||||
if (terms !== undefined && (typeof terms !== 'string')) {
|
||||
throw new Error('Invalid data.terms data type')
|
||||
}
|
||||
if (terms && terms.length > channelTermsMaxLength) {
|
||||
throw new Error('data.terms value too long')
|
||||
}
|
||||
if (terms === '') { terms = undefined }
|
||||
|
||||
const result: ChannelConfigurationOptions = {
|
||||
bot: {
|
||||
enabled: _readBoolean(botData, 'enabled'),
|
||||
@ -59,6 +70,9 @@ async function sanitizeChannelConfigurationOptions (
|
||||
anonymous: _readBoolean(mute, 'anonymous')
|
||||
}
|
||||
}
|
||||
if (terms !== undefined) {
|
||||
result.terms = terms
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -52,7 +52,8 @@ function getDefaultChannelConfigurationOptions (_options: RegisterServerOptions)
|
||||
},
|
||||
mute: {
|
||||
anonymous: false
|
||||
}
|
||||
},
|
||||
terms: undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,14 @@ function initChatSettings ({ registerSetting }: RegisterServerOptions): void {
|
||||
private: true,
|
||||
descriptionHTML: loc('chat_title')
|
||||
})
|
||||
registerSetting({
|
||||
name: 'chat-terms',
|
||||
private: true,
|
||||
label: loc('chat_terms_label'),
|
||||
type: 'input-textarea',
|
||||
default: '',
|
||||
descriptionHTML: loc('chat_terms_description')
|
||||
})
|
||||
registerSetting({
|
||||
name: 'prosody-list-rooms',
|
||||
label: loc('list_rooms_label'),
|
||||
|
Reference in New Issue
Block a user