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 --> <!-- BareRTC constants injected by IndexPage route -->
<script type="text/javascript"> <script type="text/javascript">
const Branding = {{.Config.Branding}}; const Branding = {{.Config.Branding}};
const BareRTCStrings = {{.Config.Strings}};
const PublicChannels = {{.Config.GetChannels}}; const PublicChannels = {{.Config.GetChannels}};
const DMDisclaimer = {{.Config.DirectMessageHistory.DisclaimerMessage}}; const DMDisclaimer = {{.Config.DirectMessageHistory.DisclaimerMessage}};
const WebsiteURL = "{{.Config.WebsiteURL}}"; const WebsiteURL = "{{.Config.WebsiteURL}}";

View File

@ -13,7 +13,7 @@ import (
// Version of the config format - when new fields are added, it will attempt // Version of the config format - when new fields are added, it will attempt
// to write the settings.toml to disk so new defaults populate. // to write the settings.toml to disk so new defaults populate.
var currentVersion = 14 var currentVersion = 15
// Config for your BareRTC app. // Config for your BareRTC app.
type Config struct { type Config struct {
@ -55,6 +55,8 @@ type Config struct {
DirectMessageHistory DirectMessageHistory DirectMessageHistory DirectMessageHistory
Strings Strings
Logging Logging Logging Logging
} }
@ -113,6 +115,14 @@ type WebhookURL struct {
URL string 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. // Logging configs to monitor channels or usernames.
type Logging struct { type Logging struct {
Enabled bool Enabled bool
@ -213,6 +223,12 @@ func DefaultConfig() Config {
Username: "example", 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{ DirectMessageHistory: DirectMessageHistory{
Enabled: false, Enabled: false,
SQLiteDatabase: "database.sqlite", 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? // Are they barred from watching cameras on chat?
if rule.NoImage { if rule.NoImage {
sub.ChatServer( sub.ChatServer(config.Current.Strings.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.",
)
return return
} }
@ -409,10 +406,7 @@ func (s *Server) OnMe(sub *Subscriber, msg messages.Message) {
// Are they barred from sharing their camera on chat? // Are they barred from sharing their camera on chat?
if rule.NoBroadcast || rule.NoVideo { if rule.NoBroadcast || rule.NoVideo {
sub.SendCut() sub.SendCut()
sub.ChatServer( sub.ChatServer(config.Current.Strings.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.",
)
msg.VideoStatus = 0 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) { if rule.CameraAlwaysNSFW && !(msg.VideoStatus&messages.VideoFlagNSFW == messages.VideoFlagNSFW) {
msg.VideoStatus |= messages.VideoFlagNSFW msg.VideoStatus |= messages.VideoFlagNSFW
reflect = true // send them a 'me' echo afterward to inform the front-end page properly of this reflect = true // send them a 'me' echo afterward to inform the front-end page properly of this
sub.ChatServer( sub.ChatServer(config.Current.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.",
)
} }
} }
@ -471,10 +462,7 @@ func (s *Server) OnOpen(sub *Subscriber, msg messages.Message) {
// Are they barred from watching cameras on chat? // Are they barred from watching cameras on chat?
if rule.NoVideo { if rule.NoVideo {
sub.ChatServer( sub.ChatServer(config.Current.Strings.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.",
)
return return
} }

View File

@ -78,6 +78,7 @@ export default {
// Website configuration provided by chat.html template. // Website configuration provided by chat.html template.
config: { config: {
branding: Branding, branding: Branding,
strings: BareRTCStrings,
channels: PublicChannels, channels: PublicChannels,
dmDisclaimer: DMDisclaimer, dmDisclaimer: DMDisclaimer,
website: WebsiteURL, website: WebsiteURL,
@ -2117,7 +2118,7 @@ export default {
if (this.jwt.rules.IsNoBroadcastRule) { if (this.jwt.rules.IsNoBroadcastRule) {
return this.modalAlert({ return this.modalAlert({
title: "Broadcasting video is not allowed for you", 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) { if (this.jwt.rules.IsNoVideoRule) {
return this.modalAlert({ return this.modalAlert({
title: "Videos are not available to you", 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.", "Please contact a chat operator for more information.",
}); });
} }
@ -3272,7 +3273,7 @@ export default {
onFileUpload(file) { onFileUpload(file) {
// Validate they can upload it here. // Validate they can upload it here.
if (!this.canUploadFile) { if (!this.canUploadFile) {
this.ChatClient("Photo sharing in DMs is not available."); this.ChatClient("Photo sharing in this channel is not available.");
return; return;
} }