Moderator rule: nodvd (exempt from dark video detector)

Some users had reported the dark video detector errors out on their
camera, reading a solid black image and average color of 0 despite their
camera actually being bright and colorful.

This case seems rare, but the nodvd moderation rule can lift the feature
for specific affected users while keeping it in place for everyone else.
This commit is contained in:
Noah 2025-01-03 23:13:37 -08:00
parent 1a4961e2f3
commit 7021c56045
5 changed files with 18 additions and 2 deletions

View File

@ -138,6 +138,7 @@ type ModerationRule struct {
NoBroadcast bool NoBroadcast bool
NoVideo bool NoVideo bool
NoImage bool NoImage bool
NoDarkVideo bool
} }
// Current loaded configuration. // Current loaded configuration.

View File

@ -14,6 +14,7 @@ const (
NoBroadcastRule = Rule("nobroadcast") // They can not share their webcam NoBroadcastRule = Rule("nobroadcast") // They can not share their webcam
NoImageRule = Rule("noimage") // Can not upload or see images NoImageRule = Rule("noimage") // Can not upload or see images
RedCamRule = Rule("redcam") // Their camera is force marked NSFW RedCamRule = Rule("redcam") // Their camera is force marked NSFW
NoDarkVideoRule = Rule("nodvd") // Exempt user from the dark video detector
) )
func (r Rule) IsNoVideoRule() bool { func (r Rule) IsNoVideoRule() bool {
@ -32,6 +33,10 @@ func (r Rule) IsRedCamRule() bool {
return r == RedCamRule return r == RedCamRule
} }
func (r Rule) IsNoDarkVideoRule() bool {
return r == NoDarkVideoRule
}
// Rules are the plural set of rules as shown on a JWT token (string array), // Rules are the plural set of rules as shown on a JWT token (string array),
// with some extra functionality attached such as an easy serializer to JSON. // with some extra functionality attached such as an easy serializer to JSON.
type Rules []Rule type Rules []Rule
@ -44,6 +49,7 @@ func (r Rules) ToDict() map[string]bool {
"IsNoImageRule": false, "IsNoImageRule": false,
"IsNoBroadcastRule": false, "IsNoBroadcastRule": false,
"IsRedCamRule": false, "IsRedCamRule": false,
"IsNoDarkVideoRule": false,
} }
for _, rule := range r { for _, rule := range r {
@ -59,6 +65,9 @@ func (r Rules) ToDict() map[string]bool {
if v := rule.IsRedCamRule(); v { if v := rule.IsRedCamRule(); v {
result["IsRedCamRule"] = true result["IsRedCamRule"] = true
} }
if v := rule.IsNoDarkVideoRule(); v {
result["IsNoDarkVideoRule"] = true
}
} }
return result return result

View File

@ -30,6 +30,9 @@ func (sub *Subscriber) GetModerationRule() *config.ModerationRule {
if rule.IsNoBroadcastRule() { if rule.IsNoBroadcastRule() {
rules.NoBroadcast = true rules.NoBroadcast = true
} }
if rule.IsNoDarkVideoRule() {
rules.NoDarkVideo = true
}
} }
} }

View File

@ -3043,6 +3043,9 @@ export default {
this.webcam.darkVideo.lastAverage = rgb; this.webcam.darkVideo.lastAverage = rgb;
this.webcam.darkVideo.lastAverageColor = `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, 1)`; this.webcam.darkVideo.lastAverageColor = `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, 1)`;
// If they are exempt from the dark video rule, do not check their camera color.
if (this.jwt.rules.IsNoDarkVideoRule) return;
// If the average total color is below the threshold (too dark of a video). // If the average total color is below the threshold (too dark of a video).
let averageBrightness = Math.floor((rgb[0] + rgb[1] + rgb[2]) / 3); let averageBrightness = Math.floor((rgb[0] + rgb[1] + rgb[2]) / 3);
if (averageBrightness < this.webcam.darkVideo.threshold) { if (averageBrightness < this.webcam.darkVideo.threshold) {

View File

@ -331,7 +331,7 @@ export default {
<button class="button is-small mr-1 py-2 has-text-success" <button class="button is-small mr-1 py-2 has-text-success"
title="Translate this message using Google Translate" title="Translate this message using Google Translate"
@click.prevent="translate()"> @click.prevent="translate()">
<i class="fab fa-google"></i> <i class="fab fa-google has-text-success"></i>
</button> </button>
</div> </div>
@ -528,7 +528,7 @@ export default {
<!-- Google Translate --> <!-- Google Translate -->
<a href="#" class="dropdown-item" <a href="#" class="dropdown-item"
@click.prevent="translate()"> @click.prevent="translate()">
<i class="fab fa-google mr-1"></i> <i class="fab fa-google has-text-success mr-1"></i>
Google Translate <i class="fa fa-external-link ml-1"></i> Google Translate <i class="fa fa-external-link ml-1"></i>
</a> </a>