Loading NOTES.md +1 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,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. * flag abbreviations with values don't seem to work? Polishing. Review each command and put a + next to each as it is fully done. Loading batch/batch.go +0 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,6 @@ the first user.`) ask.CheckErr(err) ask.CheckErr(q.SeedUserSystem(ctx)) ask.CheckErr(q.SeedFolderGeneral(ctx)) ask.CheckErr(q.SeedGeneralOwner(ctx)) _, err = q.AddUser(ctx, storage.AddUserParams{ Login: login, Name: name, Loading folders/folders.go +26 −27 Original line number Diff line number Diff line Loading @@ -11,14 +11,14 @@ import ( // ValidFolder validates the folder name for this user. func ValidFolder(folder string) (storage.Folder, error) { if strings.Contains(folder, "%") { return storage.Folder{}, errors.New("Folder name cannot contain a %") if !IsAlphaNum(folder) { return storage.Folder{}, errors.New("Folder can only have letters and numbers") } correct := FindFolder(folder) if correct.Name == "" { return storage.Folder{}, errors.New("Unable to select the folder") } if !IsFolderAccess(correct.Name, this.User.Login) { if !IsFolderReadable(correct.Name, this.User.Login) { // TODO: Should be: // WRITE(6,'('' You are not allowed to access folder.'')') // WRITE(6,'('' See '',A,'' if you wish to access folder.'')') Loading @@ -35,35 +35,20 @@ const ( ) // CreateFolder creates a new folder. func CreateFolder(owner string, options storage.CreateFolderParams) error { func CreateFolder(options storage.CreateFolderParams) error { if !IsAlphaNum(options.Name) { return errors.New("Folder can only have letters and numbers") } options.Name = strings.ToUpper(options.Name) ctx := storage.Context() tx, err := this.Store.Begin() err := this.Q.CreateFolder(ctx, options) if err != nil { return err } defer tx.Rollback() qtx := this.Q.WithTx(tx) err = qtx.CreateFolder(ctx, options) if err != nil { return err } err = qtx.AddFolderOwner(ctx, storage.AddFolderOwnerParams{ Folder: options.Name, Login: owner, }) if err != nil { return err } // TODO: process this error a bit more to give a better error message. return tx.Commit() } // ListFolder provides a list of folders that this.User has access to. func ListFolder() ([]storage.ListFolderRow, error) { // TODO: need to check access. Loading @@ -87,16 +72,30 @@ func FindFolder(name string) storage.Folder { return folder } // IsFolderAccess checks if a user can access a folder. func IsFolderAccess(name, login string) bool { // IsFolderReadable checks if a user can read messages from a folder. func IsFolderReadable(name, login string) bool { ctx := storage.Context() admin, _ := this.Q.IsUserAdmin(ctx, login) if admin == 1 { return true } found, _ := this.Q.IsFolderReadable(ctx, storage.IsFolderReadableParams{ Name: name, Owner: login, }) return found == 1 } // IsFolderWriteable checks if a user can write messages into a folder. func IsFolderWriteable(name, login string) bool { ctx := storage.Context() admin, _ := this.Q.IsUserAdmin(ctx, login) if admin == 1 { return true } found, _ := this.Q.IsFolderAccess(ctx, storage.IsFolderAccessParams{ found, _ := this.Q.IsFolderWriteable(ctx, storage.IsFolderWriteableParams{ Name: name, Login: login, Owner: login, }) return found == 1 } Loading @@ -109,8 +108,8 @@ func IsFolderOwner(folder, login string) bool { return true } found, _ := this.Q.IsFolderOwner(ctx, storage.IsFolderOwnerParams{ Folder: folder, Login: login, Name: folder, Owner: login, }) return found == 1 } Loading folders/messages.go +4 −3 Original line number Diff line number Diff line Loading @@ -17,9 +17,11 @@ func CreateMessage(author, subject, message, folder string, permanent, shutdown if err != nil { return err } sysdef, err := this.Q.GetExpire(ctx) if days <= 0 { // TODO: Get from site config. days = 14 days = sysdef.DefaultExpire } else { days = min(days, sysdef.ExpireLimit) } exp := time.Now().AddDate(0, 0, int(days)) expiration = &exp Loading @@ -34,7 +36,6 @@ func CreateMessage(author, subject, message, folder string, permanent, shutdown Shutdown: int64(shutdown), Expiration: *expiration, }) // TODO: process this error a bit more to give a better error message. return err } Loading repl/command.go +7 −6 Original line number Diff line number Diff line Loading @@ -1132,11 +1132,11 @@ characteristics of the BULLETIN Utility. The following options are available: ACCESS ALWAYS BRIEF DEFAULT_EXPIRE EXPIRE_LIMIT FOLDER NOALWAYS NOBRIEF NONOTIFY NOPROMPT_EXPIRE NOREADNEW NOSHOWNEW NOSYSTEM NOTIFY PROMPT_EXPIRE READNEW SHOWNEW SYSTEM ALWAYS BRIEF DEFAULT_EXPIRE EXPIRE_LIMIT FOLDER NOALWAYS NOBRIEF NONOTIFY NOPROMPT_EXPIRE NOREADNEW NOSHOWNEW NOSYSTEM NOTIFY PROMPT_EXPIRE READNEW SHOWNEW SYSTEM `, Action: ActionSet, Commands: dclish.Commands{ Loading Loading @@ -1254,7 +1254,8 @@ on that command for more information. Format: SET FOLDER [folder-name]`, MaxArgs: 1, Action: ActionSetFolder, // This is an alias for SELECT so... Action: ActionSelect, Flags: dclish.Flags{ "/MARKED": { Description: ` Selects messages that have been marked (indicated by an asterisk). After Loading Loading
NOTES.md +1 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,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. * flag abbreviations with values don't seem to work? Polishing. Review each command and put a + next to each as it is fully done. Loading
batch/batch.go +0 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,6 @@ the first user.`) ask.CheckErr(err) ask.CheckErr(q.SeedUserSystem(ctx)) ask.CheckErr(q.SeedFolderGeneral(ctx)) ask.CheckErr(q.SeedGeneralOwner(ctx)) _, err = q.AddUser(ctx, storage.AddUserParams{ Login: login, Name: name, Loading
folders/folders.go +26 −27 Original line number Diff line number Diff line Loading @@ -11,14 +11,14 @@ import ( // ValidFolder validates the folder name for this user. func ValidFolder(folder string) (storage.Folder, error) { if strings.Contains(folder, "%") { return storage.Folder{}, errors.New("Folder name cannot contain a %") if !IsAlphaNum(folder) { return storage.Folder{}, errors.New("Folder can only have letters and numbers") } correct := FindFolder(folder) if correct.Name == "" { return storage.Folder{}, errors.New("Unable to select the folder") } if !IsFolderAccess(correct.Name, this.User.Login) { if !IsFolderReadable(correct.Name, this.User.Login) { // TODO: Should be: // WRITE(6,'('' You are not allowed to access folder.'')') // WRITE(6,'('' See '',A,'' if you wish to access folder.'')') Loading @@ -35,35 +35,20 @@ const ( ) // CreateFolder creates a new folder. func CreateFolder(owner string, options storage.CreateFolderParams) error { func CreateFolder(options storage.CreateFolderParams) error { if !IsAlphaNum(options.Name) { return errors.New("Folder can only have letters and numbers") } options.Name = strings.ToUpper(options.Name) ctx := storage.Context() tx, err := this.Store.Begin() err := this.Q.CreateFolder(ctx, options) if err != nil { return err } defer tx.Rollback() qtx := this.Q.WithTx(tx) err = qtx.CreateFolder(ctx, options) if err != nil { return err } err = qtx.AddFolderOwner(ctx, storage.AddFolderOwnerParams{ Folder: options.Name, Login: owner, }) if err != nil { return err } // TODO: process this error a bit more to give a better error message. return tx.Commit() } // ListFolder provides a list of folders that this.User has access to. func ListFolder() ([]storage.ListFolderRow, error) { // TODO: need to check access. Loading @@ -87,16 +72,30 @@ func FindFolder(name string) storage.Folder { return folder } // IsFolderAccess checks if a user can access a folder. func IsFolderAccess(name, login string) bool { // IsFolderReadable checks if a user can read messages from a folder. func IsFolderReadable(name, login string) bool { ctx := storage.Context() admin, _ := this.Q.IsUserAdmin(ctx, login) if admin == 1 { return true } found, _ := this.Q.IsFolderReadable(ctx, storage.IsFolderReadableParams{ Name: name, Owner: login, }) return found == 1 } // IsFolderWriteable checks if a user can write messages into a folder. func IsFolderWriteable(name, login string) bool { ctx := storage.Context() admin, _ := this.Q.IsUserAdmin(ctx, login) if admin == 1 { return true } found, _ := this.Q.IsFolderAccess(ctx, storage.IsFolderAccessParams{ found, _ := this.Q.IsFolderWriteable(ctx, storage.IsFolderWriteableParams{ Name: name, Login: login, Owner: login, }) return found == 1 } Loading @@ -109,8 +108,8 @@ func IsFolderOwner(folder, login string) bool { return true } found, _ := this.Q.IsFolderOwner(ctx, storage.IsFolderOwnerParams{ Folder: folder, Login: login, Name: folder, Owner: login, }) return found == 1 } Loading
folders/messages.go +4 −3 Original line number Diff line number Diff line Loading @@ -17,9 +17,11 @@ func CreateMessage(author, subject, message, folder string, permanent, shutdown if err != nil { return err } sysdef, err := this.Q.GetExpire(ctx) if days <= 0 { // TODO: Get from site config. days = 14 days = sysdef.DefaultExpire } else { days = min(days, sysdef.ExpireLimit) } exp := time.Now().AddDate(0, 0, int(days)) expiration = &exp Loading @@ -34,7 +36,6 @@ func CreateMessage(author, subject, message, folder string, permanent, shutdown Shutdown: int64(shutdown), Expiration: *expiration, }) // TODO: process this error a bit more to give a better error message. return err } Loading
repl/command.go +7 −6 Original line number Diff line number Diff line Loading @@ -1132,11 +1132,11 @@ characteristics of the BULLETIN Utility. The following options are available: ACCESS ALWAYS BRIEF DEFAULT_EXPIRE EXPIRE_LIMIT FOLDER NOALWAYS NOBRIEF NONOTIFY NOPROMPT_EXPIRE NOREADNEW NOSHOWNEW NOSYSTEM NOTIFY PROMPT_EXPIRE READNEW SHOWNEW SYSTEM ALWAYS BRIEF DEFAULT_EXPIRE EXPIRE_LIMIT FOLDER NOALWAYS NOBRIEF NONOTIFY NOPROMPT_EXPIRE NOREADNEW NOSHOWNEW NOSYSTEM NOTIFY PROMPT_EXPIRE READNEW SHOWNEW SYSTEM `, Action: ActionSet, Commands: dclish.Commands{ Loading Loading @@ -1254,7 +1254,8 @@ on that command for more information. Format: SET FOLDER [folder-name]`, MaxArgs: 1, Action: ActionSetFolder, // This is an alias for SELECT so... Action: ActionSelect, Flags: dclish.Flags{ "/MARKED": { Description: ` Selects messages that have been marked (indicated by an asterisk). After Loading