sojorn/go-backend/internal/config/moderation.go
Patrick Britton 9726cb2ad4 feat: implement comprehensive AI moderation for all content types
- Add AI moderation to comments (was missing protection)
- Enhance post moderation to analyze images, videos, thumbnails
- Add FlagComment method for comment flagging
- Extract media URLs for comprehensive content analysis
- Update moderation config and models
- Add OpenAI and Google Vision API integration
- Fix database connection to use localhost

This ensures all text, image, and video content is protected by AI moderation.
2026-02-05 07:47:37 -06:00

37 lines
952 B
Go

package config
import (
"os"
)
// ModerationConfig holds configuration for AI moderation services
type ModerationConfig struct {
OpenAIKey string
GoogleKey string
Enabled bool
}
// NewModerationConfig creates a new moderation configuration
func NewModerationConfig() *ModerationConfig {
return &ModerationConfig{
OpenAIKey: os.Getenv("OPENAI_API_KEY"),
GoogleKey: os.Getenv("GOOGLE_VISION_API_KEY"),
Enabled: os.Getenv("MODERATION_ENABLED") != "false",
}
}
// IsConfigured returns true if the moderation service is properly configured
func (c *ModerationConfig) IsConfigured() bool {
return c.Enabled && (c.OpenAIKey != "" || c.GoogleKey != "")
}
// HasOpenAI returns true if OpenAI moderation is configured
func (c *ModerationConfig) HasOpenAI() bool {
return c.OpenAIKey != ""
}
// HasGoogleVision returns true if Google Vision API is configured
func (c *ModerationConfig) HasGoogleVision() bool {
return c.GoogleKey != ""
}