Customizable error strings for moderation rules

This commit is contained in:
Noah 2024-09-20 20:33:42 -07:00
parent 16b148fc92
commit 971a6d800d
4 changed files with 26 additions and 20 deletions

View File

@ -28,6 +28,7 @@
<!-- BareRTC constants injected by IndexPage route -->
<script type="text/javascript">
const Branding = {{.Config.Branding}};
const BareRTCStrings = {{.Config.Strings}};
const PublicChannels = {{.Config.GetChannels}};
const DMDisclaimer = {{.Config.DirectMessageHistory.DisclaimerMessage}};
const WebsiteURL = "{{.Config.WebsiteURL}}";

View File

@ -13,7 +13,7 @@ import (
// Version of the config format - when new fields are added, it will attempt
// to write the settings.toml to disk so new defaults populate.
var currentVersion = 14
var currentVersion = 15
// Config for your BareRTC app.
type Config struct {
@ -55,6 +55,8 @@ type Config struct {
DirectMessageHistory DirectMessageHistory
Strings Strings
Logging Logging
}
@ -113,6 +115,14 @@ type WebhookURL struct {
URL string
}
// Strings config for customizing certain user-facing messaging around the app.
type Strings struct {
ModRuleErrorCameraAlwaysNSFW string
ModRuleErrorNoBroadcast string
ModRuleErrorNoVideo string
ModRuleErrorNoImage string
}
// Logging configs to monitor channels or usernames.
type Logging struct {
Enabled bool
@ -213,6 +223,12 @@ func DefaultConfig() Config {
Username: "example",
},
},
Strings: Strings{
ModRuleErrorCameraAlwaysNSFW: "A chat server moderation rule is currently in place which forces your camera to stay marked as Explicit. Please contact a chat moderator if you have any questions about this.",
ModRuleErrorNoBroadcast: "A chat server moderation rule is currently in place which restricts your ability to share your webcam. Please contact a chat operator for more information.",
ModRuleErrorNoVideo: "A chat server moderation rule is currently in place which restricts your ability to watch webcams. Please contact a chat operator for more information.",
ModRuleErrorNoImage: "A chat server moderation rule is currently in place which restricts your ability to share images. Please contact a chat operator for more information.",
},
DirectMessageHistory: DirectMessageHistory{
Enabled: false,
SQLiteDatabase: "database.sqlite",

View File

@ -309,10 +309,7 @@ func (s *Server) OnFile(sub *Subscriber, msg messages.Message) {
// Are they barred from watching cameras on chat?
if rule.NoImage {
sub.ChatServer(
"A chat server moderation rule is currently in place which restricts your ability to share images. Please " +
"contact a chat operator for more information.",
)
sub.ChatServer(config.Current.Strings.ModRuleErrorNoImage)
return
}
@ -409,10 +406,7 @@ func (s *Server) OnMe(sub *Subscriber, msg messages.Message) {
// Are they barred from sharing their camera on chat?
if rule.NoBroadcast || rule.NoVideo {
sub.SendCut()
sub.ChatServer(
"A chat server moderation rule is currently in place which restricts your ability to share your webcam. Please " +
"contact a chat operator for more information.",
)
sub.ChatServer(config.Current.Strings.ModRuleErrorNoBroadcast)
msg.VideoStatus = 0
}
@ -420,10 +414,7 @@ func (s *Server) OnMe(sub *Subscriber, msg messages.Message) {
if rule.CameraAlwaysNSFW && !(msg.VideoStatus&messages.VideoFlagNSFW == messages.VideoFlagNSFW) {
msg.VideoStatus |= messages.VideoFlagNSFW
reflect = true // send them a 'me' echo afterward to inform the front-end page properly of this
sub.ChatServer(
"A chat server moderation rule is currently in place which forces your camera to stay marked as Explicit. Please " +
"contact a chat moderator if you have any questions about this.",
)
sub.ChatServer(config.Current.Strings.ModRuleErrorCameraAlwaysNSFW)
}
}
@ -471,10 +462,7 @@ func (s *Server) OnOpen(sub *Subscriber, msg messages.Message) {
// Are they barred from watching cameras on chat?
if rule.NoVideo {
sub.ChatServer(
"A chat server moderation rule is currently in place which restricts your ability to watch webcams. Please " +
"contact a chat operator for more information.",
)
sub.ChatServer(config.Current.Strings.ModRuleErrorNoVideo)
return
}

View File

@ -78,6 +78,7 @@ export default {
// Website configuration provided by chat.html template.
config: {
branding: Branding,
strings: BareRTCStrings,
channels: PublicChannels,
dmDisclaimer: DMDisclaimer,
website: WebsiteURL,
@ -2117,7 +2118,7 @@ export default {
if (this.jwt.rules.IsNoBroadcastRule) {
return this.modalAlert({
title: "Broadcasting video is not allowed for you",
message: "A chat room moderation rule is currently in place which restricts your ability to broadcast your webcam.\n\nPlease contact a chat operator for more information.",
message: this.config.strings.ModRuleErrorNoBroadcast || "A chat room moderation rule is currently in place which restricts your ability to broadcast your webcam.\n\nPlease contact a chat operator for more information.",
});
}
@ -2351,7 +2352,7 @@ export default {
if (this.jwt.rules.IsNoVideoRule) {
return this.modalAlert({
title: "Videos are not available to you",
message: "A chat room moderation rule is currently in place which restricts your ability to watch webcams.\n\n" +
message: this.config.strings.ModRuleErrorNoVideo || "A chat room moderation rule is currently in place which restricts your ability to watch webcams.\n\n" +
"Please contact a chat operator for more information.",
});
}
@ -3272,7 +3273,7 @@ export default {
onFileUpload(file) {
// Validate they can upload it here.
if (!this.canUploadFile) {
this.ChatClient("Photo sharing in DMs is not available.");
this.ChatClient("Photo sharing in this channel is not available.");
return;
}