Checkpoint audio-only Skald fork work
This commit is contained in:
+22
-22
@@ -151,7 +151,7 @@ func (u UserDescription) MarshalJSON() ([]byte, error) {
|
||||
// about the JSON file it was deserialised from.
|
||||
type Description struct {
|
||||
// The file this was deserialised from. This is not necessarily
|
||||
// the name of the hall, for example in case of a subgroup.
|
||||
// the name of the hall, for example in case of a subhall.
|
||||
FileName string `json:"-"`
|
||||
|
||||
// The modtime and size of the file. These are used to detect
|
||||
@@ -159,8 +159,8 @@ type Description struct {
|
||||
modTime time.Time `json:"-"`
|
||||
fileSize int64 `json:"-"`
|
||||
|
||||
// Whether this is an automatically generated subgroup
|
||||
isSubgroup bool `json:"-"`
|
||||
// Whether this is an automatically generated subhall
|
||||
isSubhall bool `json:"-"`
|
||||
|
||||
// The user-friendly hall name
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
@@ -199,8 +199,8 @@ type Description struct {
|
||||
// Whether creating tokens is allowed
|
||||
UnrestrictedTokens bool `json:"unrestricted-tokens,omitempty"`
|
||||
|
||||
// Whether subgroups are created on the fly.
|
||||
AutoSubgroups bool `json:"auto-subgroups,omitempty"`
|
||||
// Whether subhalls are created on the fly.
|
||||
AutoSubhalls bool `json:"auto-subhalls,omitempty"`
|
||||
|
||||
// Whether to lock the hall when the last op logs out.
|
||||
Autolock bool `json:"autolock,omitempty"`
|
||||
@@ -231,7 +231,7 @@ type Description struct {
|
||||
Op []ClientPattern `json:"op,omitempty"`
|
||||
Presenter []ClientPattern `json:"presenter,omitempty"`
|
||||
Other []ClientPattern `json:"other,omitempty"`
|
||||
AllowSubgroups bool `json:"allow-subgroups,omitempty"`
|
||||
AllowSubhalls bool `json:"allow-subhalls,omitempty"`
|
||||
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
|
||||
}
|
||||
|
||||
@@ -244,20 +244,20 @@ func maxHistoryAge(desc *Description) time.Duration {
|
||||
return DefaultMaxHistoryAge
|
||||
}
|
||||
|
||||
func getDescriptionFile[T any](name string, allowSubgroups bool, get func(string) (T, error)) (T, string, bool, error) {
|
||||
isSubgroup := false
|
||||
func getDescriptionFile[T any](name string, allowSubhalls bool, get func(string) (T, error)) (T, string, bool, error) {
|
||||
isSubhall := false
|
||||
for name != "" {
|
||||
fileName := filepath.Join(
|
||||
Directory, path.Clean("/"+name)+".json",
|
||||
)
|
||||
r, err := get(fileName)
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
return r, fileName, isSubgroup, err
|
||||
return r, fileName, isSubhall, err
|
||||
}
|
||||
if !allowSubgroups {
|
||||
if !allowSubhalls {
|
||||
break
|
||||
}
|
||||
isSubgroup = true
|
||||
isSubhall = true
|
||||
name, _ = path.Split(name)
|
||||
name = strings.TrimRight(name, "/")
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func GetSanitisedDescription(name string) (*Description, string, error) {
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if d.isSubgroup {
|
||||
if d.isSubhall {
|
||||
return nil, "", os.ErrNotExist
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ func rewriteDescriptionFile(filename string, desc *Description) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !conf.WritableGroups {
|
||||
if !conf.WritableHalls {
|
||||
return ErrDescriptionsNotWritable
|
||||
}
|
||||
|
||||
@@ -439,9 +439,9 @@ func rewriteDescriptionFile(filename string, desc *Description) error {
|
||||
}
|
||||
|
||||
// readDescription reads a hall's description from disk
|
||||
func readDescription(name string, allowSubgroups bool) (*Description, error) {
|
||||
r, fileName, isSubgroup, err :=
|
||||
getDescriptionFile(name, allowSubgroups, os.Open)
|
||||
func readDescription(name string, allowSubhalls bool) (*Description, error) {
|
||||
r, fileName, isSubhall, err :=
|
||||
getDescriptionFile(name, allowSubhalls, os.Open)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -469,11 +469,11 @@ func readDescription(name string, allowSubgroups bool) (*Description, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if isSubgroup {
|
||||
if !desc.AutoSubgroups {
|
||||
if isSubhall {
|
||||
if !desc.AutoSubhalls {
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
desc.isSubgroup = true
|
||||
desc.isSubhall = true
|
||||
desc.Public = false
|
||||
desc.Description = ""
|
||||
}
|
||||
@@ -490,9 +490,9 @@ func upgradeDescription(desc *Description) error {
|
||||
desc.AllowAnonymous = false
|
||||
}
|
||||
|
||||
if desc.AllowSubgroups {
|
||||
desc.AutoSubgroups = true
|
||||
desc.AllowSubgroups = false
|
||||
if desc.AllowSubhalls {
|
||||
desc.AutoSubhalls = true
|
||||
desc.AllowSubhalls = false
|
||||
}
|
||||
|
||||
upgradePassword := func(pw *Password) Password {
|
||||
|
||||
Reference in New Issue
Block a user