Let channels configure whether to permit photos

This commit is contained in:
Noah 2024-05-13 18:51:54 -07:00
parent 745c282650
commit 747f4fd5d4
3 changed files with 22 additions and 12 deletions

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 = 11
var currentVersion = 12
// Config for your BareRTC app.
type Config struct {
@ -94,10 +94,11 @@ func (c Config) GetChannel(id string) (Channel, bool) {
// Channel config for a default public room.
type Channel struct {
ID string // Like "lobby"
Name string // Like "Main Chat Room"
Icon string `toml:",omitempty"` // CSS class names for room icon (optional)
VIP bool // For VIP users only
ID string // Like "lobby"
Name string // Like "Main Chat Room"
Icon string `toml:",omitempty"` // CSS class names for room icon (optional)
VIP bool // For VIP users only
PermitPhotos bool // photos are allowed to be shared
// ChatServer messages to send to the user immediately upon connecting.
WelcomeMessages []string
@ -151,11 +152,13 @@ func DefaultConfig() Config {
WelcomeMessages: []string{
"Welcome to the Off Topic channel!",
},
PermitPhotos: true,
},
{
ID: "vip",
Name: "VIPs Only",
VIP: true,
ID: "vip",
Name: "VIPs Only",
VIP: true,
PermitPhotos: true,
WelcomeMessages: []string{
"This channel is only for operators and VIPs.",
},

View File

@ -544,7 +544,7 @@ func (s *Server) SendWhoList() {
// VIP flags: if we are in MutuallySecret mode, only VIPs can see
// other VIP flags on the Who List.
if config.Current.VIP.MutuallySecret {
if sub.IsVIP() || sub.IsAdmin() {
if sub.IsVIP() {
who.VIP = user.JWTClaims.VIP
}
} else {

View File

@ -631,9 +631,16 @@ export default {
return status === null || status.name !== "online";
},
canUploadFile() {
// Public channels: OK
if (!this.channel.indexOf('@') === 0) {
return true;
// Public channels: check whether it PermitsPhotos.
if (!this.isDM) {
for (let cfg of this.config.channels) {
if (cfg.ID === this.channel && cfg.PermitPhotos) {
return true;
}
}
// By default: channels do not permit photos.
return false;
}
// User is an admin?