diff --git a/NOTES.md b/NOTES.md index ca0a0bb1812887cfe9f0ac05f7a5776ac9bedea4..2e325420f0a0d5844aa81cbfcf4f4bfa67c2b376 100644 --- a/NOTES.md +++ b/NOTES.md @@ -36,6 +36,7 @@ Switch between MAIL and BULLETIN modes? MAIL commands are documented * Review sql queries and clean out the ones not used. * Review sql queries and find duplicates. * Use [dupl](https://github.com/mibk/dupl) to find things to generalise. + There's a `make dupl` target. * flag abbreviations with values don't seem to work? Polishing. Review each command and put a + next to each as it is diff --git a/repl/folders.go b/repl/folders.go index 4e5fe8d9e6c8c872ee19017950ebbbd64f0ede53..c8b7f4a49b39b4094a819242e14f41534325ca29 100644 --- a/repl/folders.go +++ b/repl/folders.go @@ -119,6 +119,7 @@ func ActionCreate(cmd *dclish.Command) error { } // ActionSelect handles the `SELECT` command. This selects a folder. +// This is based on `SELECT_FOLDER` in bulletin5.for. func ActionSelect(cmd *dclish.Command) error { if strings.Contains(cmd.Args[0], "%") { return errors.New("Folder name cannot contain a %") @@ -133,23 +134,31 @@ func ActionSelect(cmd *dclish.Command) error { fmt.Printf("Folder has been set to '%s'.\n", folder.Name) return nil } - // TODO: Should be: - // WRITE(6,'('' You are not allowed to access folder.'')') - // WRITE(6,'('' See '',A,'' if you wish to access folder.'')') return errors.New("Unable to select the folder") } // ActionModify handles the `MODIFY` command. This modifies a folder. +// This is based on `MODIFY_FOLDER` in bulletin1.for. func ActionModify(cmd *dclish.Command) error { if this.User.Login != this.Folder.Owner && this.User.Admin == 0 { return errors.New("Must be folder owner or admin to modify the folder") } + var err error description := this.Folder.Description if cmd.Flags["/DESCRIPTION"].Set { - description = cmd.Flags["/DESCRIPTION"].Value + description, err = ask.GetLine("Enter one line description of folder: ") + if err != nil { + return err + } + if len(description) > 53 { + return errors.New("Description must be < 53 characters") + } } owner := this.Folder.Owner if cmd.Flags["/OWNER"].Set { + if this.User.Admin == 0 { + return errors.New("Must be an admin to modify the folder owner") + } owner = cmd.Flags["/OWNER"].Value } name := this.Folder.Name @@ -161,7 +170,7 @@ func ActionModify(cmd *dclish.Command) error { } ctx := storage.Context() - err := this.Q.UpdateFolderMain(ctx, storage.UpdateFolderMainParams{ + err = this.Q.UpdateFolderMain(ctx, storage.UpdateFolderMainParams{ Description: description, Owner: owner, NewName: name,