Loading NOTES.md +4 −3 Original line number Diff line number Diff line Loading @@ -29,15 +29,15 @@ repl.commands? * Run [godoc](http://localhost:6060/) and then review where the help text is lacking. * ~~Move to a storage layer.~~ * this.Folder should be a storage.Folder. * Implement each command. * Next: folder commands - ~~CREATE~~, ~~REMOVE~~, MODIFY, ~~INDEX~~, ~~SELECT~~ * Messages: ~~ADD~~, ~~CURRENT~~, ~~DIRECTORY~~, ~~BACK~~, CHANGE, ~~FIRST~~, ~~NEXT~~, ~~READ~~, DELETE ~~FIRST~~, ~~NEXT~~, ~~READ~~, ~~DELETE~~ * Messages edit: CHANGE, REPLY, FORWARD * Moving messages: COPY, MOVE * Compound commands: SET and SHOW - make HELP work for them. * Mail: MAIL, FORWARD, * Run this.Skew.Safe() before... each command? each write? * Handle broadcast messages - have bulletin watch a directory and display files from it. Then have them delete the file if it's older than 5 minutes (allow for failure) Loading Loading @@ -71,7 +71,8 @@ Done: * ~~expire~~ * ~~Add a pager~~ * ~~SHOW VERSION~~ * Check db version; notify user if it changes; refuse to write to db if it has. * ~~Check db version; notify user if it changes; refuse to write to db if it has.~~ * ~~this.Folder should be a storage.Folder.~~ ## Module links Loading folders/folders.go +8 −8 Original line number Diff line number Diff line Loading @@ -10,19 +10,19 @@ import ( ) // ValidFolder validates the folder name for this user. func ValidFolder(folder string) (string, error) { func ValidFolder(folder string) (storage.Folder, error) { if strings.Contains(folder, "%") { return "", errors.New("Folder name cannot contain a %") return storage.Folder{}, errors.New("Folder name cannot contain a %") } correct := FindFolder(folder) if correct == "" { return "", errors.New("Unable to select the folder") if correct.Name == "" { return storage.Folder{}, errors.New("Unable to select the folder") } if !IsFolderAccess(correct, this.User.Login) { if !IsFolderAccess(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.'')') return "", errors.New("Unable to select the folder") return storage.Folder{}, errors.New("Unable to select the folder") } return correct, nil } Loading Loading @@ -77,10 +77,10 @@ func ListFolder() ([]storage.ListFolderRow, error) { } // FindFolder finds a folder based on the prefix. func FindFolder(name string) string { func FindFolder(name string) storage.Folder { ctx := storage.Context() folder, _ := this.Q.FindFolderExact(ctx, name) if folder != "" { if folder.Name != "" { return folder } folder, _ = this.Q.FindFolderPrefix(ctx, name) Loading folders/messages.go +23 −2 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ func MarkSeen(msgids []int64) error { for _, msgid := range msgids { this.Q.SetMessageSeen(ctx, storage.SetMessageSeenParams{ Login: this.User.Login, Folder: this.Folder, Folder: this.Folder.Name, Msgid: msgid, }) } Loading @@ -81,7 +81,7 @@ func MarkUnseen(msgids []int64) error { for _, msgid := range msgids { this.Q.UnsetMessageSeen(ctx, storage.UnsetMessageSeenParams{ Login: this.User.Login, Folder: this.Folder, Folder: this.Folder.Name, Msgid: msgid, }) } Loading Loading @@ -137,3 +137,24 @@ func ListMessages(folder string) ([]storage.Message, error) { rows, err := this.Q.ListMessages(ctx, folder) return rows, err } // DeleteMessages deletes a list of messages. func DeleteMessages(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { this.Q.DeleteMessage(ctx, storage.DeleteMessageParams{ Folder: this.Folder.Name, ID: msgid, }) } return nil } // DeleteAllMessages deletes all messages in a folder. func DeleteAllMessages() error { ctx := storage.Context() this.Q.DeleteAllMessages(ctx, this.Folder.Name) return nil } repl/command.go +2 −16 Original line number Diff line number Diff line Loading @@ -396,8 +396,7 @@ of the message again, you can enter the CURRENT command. message is deleted. Only the original owner or a privileged user can delete a message. Note that the message is not deleted immediately, but its expiration is set 15 minutes in the future. This is to allow a user to recover the message using the UNDELETE command. If you want the message deleted immediately, use the /IMMEDIATE qualifier. to recover the message using the UNDELETE command. Format: DELETE [message_number][-message_number1] Loading @@ -410,26 +409,13 @@ specified if the folder is remote. The key words CURRENT and LAST can also be specified in the range in, place of an actual number, i.e. CURRENT-LAST, 1-CURRENT, etc.`, MaxArgs: 1, Action: ActionDelete, Flags: dclish.Flags{ "/ALL": { Description: ` Specifies to delete all the messages in the folder. Note: This will not work for remote folders. Only one message can be deleted from a remote folder at a time.`, }, "/IMMEDIATE": { Description: ` Specifies that the message is to be deleted immediately.`, }, "/SUBJECT": { Description: `/SUBJECT=subject Specifies the subject of the bulletin to be deleted at a remote DECNET node. The DECNET node must be specified with the /NODE qualifier. The specified subject need not be the exact subject of the message. It can be a substring of the subject. This is in case you have forgotten the exact subject that was specified. Case is not critical either. You will be notified if the deletion was successful.`, OptArg: true, }, }, }, "DIRECTORY": { Loading repl/folders.go +3 −3 Original line number Diff line number Diff line Loading @@ -101,12 +101,12 @@ func ActionSelect(cmd *dclish.Command) error { return errors.New("Folder name cannot contain a %") } folder := folders.FindFolder(cmd.Args[0]) if folder == "" { if folder.Name == "" { return errors.New("Unable to select the folder") } if folders.IsFolderAccess(folder, this.User.Login) { if folders.IsFolderAccess(folder.Name, this.User.Login) { this.Folder = folder fmt.Printf("Folder has been set to '%s'.\n", folder) fmt.Printf("Folder has been set to '%s'.\n", folder.Name) return nil } // TODO: Should be: Loading Loading
NOTES.md +4 −3 Original line number Diff line number Diff line Loading @@ -29,15 +29,15 @@ repl.commands? * Run [godoc](http://localhost:6060/) and then review where the help text is lacking. * ~~Move to a storage layer.~~ * this.Folder should be a storage.Folder. * Implement each command. * Next: folder commands - ~~CREATE~~, ~~REMOVE~~, MODIFY, ~~INDEX~~, ~~SELECT~~ * Messages: ~~ADD~~, ~~CURRENT~~, ~~DIRECTORY~~, ~~BACK~~, CHANGE, ~~FIRST~~, ~~NEXT~~, ~~READ~~, DELETE ~~FIRST~~, ~~NEXT~~, ~~READ~~, ~~DELETE~~ * Messages edit: CHANGE, REPLY, FORWARD * Moving messages: COPY, MOVE * Compound commands: SET and SHOW - make HELP work for them. * Mail: MAIL, FORWARD, * Run this.Skew.Safe() before... each command? each write? * Handle broadcast messages - have bulletin watch a directory and display files from it. Then have them delete the file if it's older than 5 minutes (allow for failure) Loading Loading @@ -71,7 +71,8 @@ Done: * ~~expire~~ * ~~Add a pager~~ * ~~SHOW VERSION~~ * Check db version; notify user if it changes; refuse to write to db if it has. * ~~Check db version; notify user if it changes; refuse to write to db if it has.~~ * ~~this.Folder should be a storage.Folder.~~ ## Module links Loading
folders/folders.go +8 −8 Original line number Diff line number Diff line Loading @@ -10,19 +10,19 @@ import ( ) // ValidFolder validates the folder name for this user. func ValidFolder(folder string) (string, error) { func ValidFolder(folder string) (storage.Folder, error) { if strings.Contains(folder, "%") { return "", errors.New("Folder name cannot contain a %") return storage.Folder{}, errors.New("Folder name cannot contain a %") } correct := FindFolder(folder) if correct == "" { return "", errors.New("Unable to select the folder") if correct.Name == "" { return storage.Folder{}, errors.New("Unable to select the folder") } if !IsFolderAccess(correct, this.User.Login) { if !IsFolderAccess(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.'')') return "", errors.New("Unable to select the folder") return storage.Folder{}, errors.New("Unable to select the folder") } return correct, nil } Loading Loading @@ -77,10 +77,10 @@ func ListFolder() ([]storage.ListFolderRow, error) { } // FindFolder finds a folder based on the prefix. func FindFolder(name string) string { func FindFolder(name string) storage.Folder { ctx := storage.Context() folder, _ := this.Q.FindFolderExact(ctx, name) if folder != "" { if folder.Name != "" { return folder } folder, _ = this.Q.FindFolderPrefix(ctx, name) Loading
folders/messages.go +23 −2 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ func MarkSeen(msgids []int64) error { for _, msgid := range msgids { this.Q.SetMessageSeen(ctx, storage.SetMessageSeenParams{ Login: this.User.Login, Folder: this.Folder, Folder: this.Folder.Name, Msgid: msgid, }) } Loading @@ -81,7 +81,7 @@ func MarkUnseen(msgids []int64) error { for _, msgid := range msgids { this.Q.UnsetMessageSeen(ctx, storage.UnsetMessageSeenParams{ Login: this.User.Login, Folder: this.Folder, Folder: this.Folder.Name, Msgid: msgid, }) } Loading Loading @@ -137,3 +137,24 @@ func ListMessages(folder string) ([]storage.Message, error) { rows, err := this.Q.ListMessages(ctx, folder) return rows, err } // DeleteMessages deletes a list of messages. func DeleteMessages(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { this.Q.DeleteMessage(ctx, storage.DeleteMessageParams{ Folder: this.Folder.Name, ID: msgid, }) } return nil } // DeleteAllMessages deletes all messages in a folder. func DeleteAllMessages() error { ctx := storage.Context() this.Q.DeleteAllMessages(ctx, this.Folder.Name) return nil }
repl/command.go +2 −16 Original line number Diff line number Diff line Loading @@ -396,8 +396,7 @@ of the message again, you can enter the CURRENT command. message is deleted. Only the original owner or a privileged user can delete a message. Note that the message is not deleted immediately, but its expiration is set 15 minutes in the future. This is to allow a user to recover the message using the UNDELETE command. If you want the message deleted immediately, use the /IMMEDIATE qualifier. to recover the message using the UNDELETE command. Format: DELETE [message_number][-message_number1] Loading @@ -410,26 +409,13 @@ specified if the folder is remote. The key words CURRENT and LAST can also be specified in the range in, place of an actual number, i.e. CURRENT-LAST, 1-CURRENT, etc.`, MaxArgs: 1, Action: ActionDelete, Flags: dclish.Flags{ "/ALL": { Description: ` Specifies to delete all the messages in the folder. Note: This will not work for remote folders. Only one message can be deleted from a remote folder at a time.`, }, "/IMMEDIATE": { Description: ` Specifies that the message is to be deleted immediately.`, }, "/SUBJECT": { Description: `/SUBJECT=subject Specifies the subject of the bulletin to be deleted at a remote DECNET node. The DECNET node must be specified with the /NODE qualifier. The specified subject need not be the exact subject of the message. It can be a substring of the subject. This is in case you have forgotten the exact subject that was specified. Case is not critical either. You will be notified if the deletion was successful.`, OptArg: true, }, }, }, "DIRECTORY": { Loading
repl/folders.go +3 −3 Original line number Diff line number Diff line Loading @@ -101,12 +101,12 @@ func ActionSelect(cmd *dclish.Command) error { return errors.New("Folder name cannot contain a %") } folder := folders.FindFolder(cmd.Args[0]) if folder == "" { if folder.Name == "" { return errors.New("Unable to select the folder") } if folders.IsFolderAccess(folder, this.User.Login) { if folders.IsFolderAccess(folder.Name, this.User.Login) { this.Folder = folder fmt.Printf("Folder has been set to '%s'.\n", folder) fmt.Printf("Folder has been set to '%s'.\n", folder.Name) return nil } // TODO: Should be: Loading