Loading repl/accounts.go +70 −20 Original line number Diff line number Diff line Loading @@ -10,15 +10,18 @@ import ( "git.lyda.ie/kevin/bulletin/storage" "git.lyda.ie/kevin/bulletin/this" "git.lyda.ie/kevin/bulletin/users" "github.com/pkg/errors" ) // ActionUser handles the `USER` command. // ActionUser handles the USER command - it prints out help for all the // USER subcommands. This is new to the Go version of BULLETIN. func ActionUser(cmd *dclish.Command) error { fmt.Println(cmd.Description) return nil } // ActionUserAdd handles the `USER ADD` command. // ActionUserAdd handles the `USER ADD` command. This is used to add a // new user. This is new to the Go version of BULLETIN. func ActionUserAdd(cmd *dclish.Command) error { ctx := storage.Context() login := strings.ToUpper(cmd.Args[0]) Loading Loading @@ -46,7 +49,10 @@ func ActionUserAdd(cmd *dclish.Command) error { return nil } // ActionUserList handles the `USER LIST` command. // ActionUserList handles the `USER LIST` command. This lists all the // users. For now this is limited to only the admin users. // // This is new to the Go version of BULLETIN. func ActionUserList(_ *dclish.Command) error { if this.User.Admin == 0 { fmt.Println("ERROR: You are not an admin.") Loading @@ -64,7 +70,10 @@ func ActionUserList(_ *dclish.Command) error { return nil } // ActionUserDelete handles the `USER DELETE` command. // ActionUserDelete handles the `USER DELETE` command. This will delete // the named user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserDelete(cmd *dclish.Command) error { if this.User.Admin == 0 { fmt.Println("ERROR: You are not an admin.") Loading Loading @@ -109,12 +118,18 @@ func actionUserEnable(cmd *dclish.Command, disabled int64, doing string) error { return nil } // ActionUserEnable handles the `USER ENABLE` command. // ActionUserEnable handles the `USER ENABLE` command. This enables // a user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserEnable(cmd *dclish.Command) error { return actionUserEnable(cmd, 0, "enable") } // ActionUserDisable handles the `USER DISABLE` command. // ActionUserDisable handles the `USER DISABLE` command. This disables // a user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserDisable(cmd *dclish.Command) error { return actionUserEnable(cmd, 1, "disable") } Loading @@ -126,8 +141,10 @@ func actionUserAdmin(cmd *dclish.Command, admin int64, doing string) error { } u, err := users.ValidExistingLogin(this.Q, cmd.Args[0]) if err != nil || u.Login == "" { fmt.Println("ERROR: User not found.") return nil return errors.New("User not found") } if u.Login == this.User.Login || u.Login == "SYSTEM" { return errors.New("Invalid user given") } if u.Admin == admin { fmt.Printf("User is already %s.\n", doing) Loading @@ -136,19 +153,24 @@ func actionUserAdmin(cmd *dclish.Command, admin int64, doing string) error { ctx := storage.Context() err = this.Q.UpdateUserAdmin(ctx, admin, u.Login) if err != nil { fmt.Printf("ERROR: Failed to make user %s (%s).\n", doing, err) return nil return errors.Errorf("Failed to make user %s (%s)", doing, err) } fmt.Printf("User is now %s.\n", doing) return nil } // ActionUserAdmin handles the `USER ADMIN` command. // ActionUserAdmin handles the `USER ADMIN` command. This makes the given // user an admin. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserAdmin(cmd *dclish.Command) error { return actionUserAdmin(cmd, 1, "an admin") } // ActionUserNoadmin handles the `USER NOADMIN` command. // ActionUserNoadmin handles the `USER NOADMIN` command. This removes the // admin bit from a given user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserNoadmin(cmd *dclish.Command) error { return actionUserAdmin(cmd, 0, "not an admin") } Loading Loading @@ -177,17 +199,26 @@ func actionUserMod(cmd *dclish.Command, mod int64, doing string) error { return nil } // ActionUserMod handles the `USER MOD` command. // ActionUserMod handles the `USER MOD` command. Makes given the user a // moderator. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserMod(cmd *dclish.Command) error { return actionUserMod(cmd, 1, "a moderator") } // ActionUserNomod handles the `USER NOMOD` command. // ActionUserNomod handles the `USER NOMOD` command. Removes the // moderator bit from the given user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserNomod(cmd *dclish.Command) error { return actionUserMod(cmd, 0, "not a moderator") } // ActionUserName handles the `USER LIST` command. // ActionUserName handles the `USER NAME` command. Updates the user's // name. Only the admin can use the two argument version of this command. // // This is new to the Go version of BULLETIN. func ActionUserName(cmd *dclish.Command) error { if len(cmd.Args) == 2 && this.User.Admin == 0 { fmt.Println("ERROR: You are not an admin.") Loading @@ -212,13 +243,19 @@ func ActionUserName(cmd *dclish.Command) error { return nil } // ActionSSH handles the `SSH` command. // ActionSSH handles the `SSH` command. This prints the help for all the // SSH commands. These are used to manage the authorized_keys file. // These are new to the Go version of BULLETIN. func ActionSSH(cmd *dclish.Command) error { fmt.Println(cmd.Description) return nil } // ActionSSHAdd handles the `SSH ADD` command. // ActionSSHAdd handles the `SSH ADD` command. This adds a given ssh key // to the authorized_keys file for the given user. An admin can add // a new public key for another user. // // This is new to the Go version of BULLETIN. func ActionSSHAdd(cmd *dclish.Command) error { if this.User.Admin == 0 && len(cmd.Args) == 1 { fmt.Println("ERROR: You are not an admin.") Loading @@ -243,7 +280,11 @@ func ActionSSHAdd(cmd *dclish.Command) error { return nil } // ActionSSHList handles the `SSH LIST` command. // ActionSSHList handles the `SSH LIST` command. This lists all the // public keys for this user. An admin can list public keys for another // user. // // This is new to the Go version of BULLETIN. func ActionSSHList(cmd *dclish.Command) error { if this.User.Admin == 0 && len(cmd.Args) == 1 { fmt.Println("ERROR: You are not an admin.") Loading @@ -267,7 +308,11 @@ func ActionSSHList(cmd *dclish.Command) error { return nil } // ActionSSHDelete handles the `SSH DELETE` command. // ActionSSHDelete handles the `SSH DELETE` command. Removes ssh public // keys for a user. And admin can specify a different user to remove // public keys for. // // This is new to the Go version of BULLETIN. func ActionSSHDelete(cmd *dclish.Command) error { if this.User.Admin == 0 && len(cmd.Args) == 1 { fmt.Println("ERROR: You are not an admin.") Loading Loading @@ -309,7 +354,12 @@ func ActionSSHDelete(cmd *dclish.Command) error { return nil } // ActionSSHFetch handles the `SSH FETCH` command. // ActionSSHFetch handles the `SSH FETCH` command. This command pulls // public keys from code sites. It's the quickest way to // add a number of keys for a user. An admin can do this // for another user. // // This is new to the Go version of BULLETIN. func ActionSSHFetch(cmd *dclish.Command) error { login := this.User.Login sitename := cmd.Args[0] Loading repl/folders.go +8 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ import ( ) // ActionIndex handles the `INDEX` command. This lists all the folders. // // This originally existed as the subroutine FULL_DIR in bulletin9.for. func ActionIndex(cmd *dclish.Command) error { if cmd.Flags["/MARKED"].Set { Loading Loading @@ -48,6 +50,8 @@ func ActionIndex(cmd *dclish.Command) error { } // ActionCreate handles the `CREATE` command. This creates a folder. // // This originally existed as the subroutine CREATE_FOLDER in bulletin4.for. func ActionCreate(cmd *dclish.Command) error { // Populate options... options := storage.CreateFolderParams{} Loading Loading @@ -118,6 +122,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], "%") { Loading @@ -137,6 +142,7 @@ func ActionSelect(cmd *dclish.Command) error { } // 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 { Loading Loading @@ -179,6 +185,8 @@ func ActionModify(cmd *dclish.Command) error { } // ActionRemove handles the `REMOVE` command. This modifies a folder. // // This originally existed as the subroutine REMOVE_FOLDER in bulletin5.for. func ActionRemove(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 delete the folder") Loading repl/help.go +4 −1 Original line number Diff line number Diff line Loading @@ -191,7 +191,10 @@ func findHelp(hmap map[string]string, args []string, fullcmd string) string { return helptext } // ActionHelp handles the `HELP` command. // ActionHelp handles the `HELP` command. This provides help taxt // for each command. // // This originally existed as the subroutine HELP in bulletin8.for. func ActionHelp(cmd *dclish.Command) error { if len(cmd.Args) == 0 { fmt.Printf("%s\n", helpmap["HELP"]) Loading repl/mail.go +6 −0 Original line number Diff line number Diff line Loading @@ -7,16 +7,22 @@ import ( ) // ActionForward handles the `FORWARD` command. // // This originally existed as the subroutine MAIL in bulletin1.for. func ActionForward(_ *dclish.Command) error { return errors.New("Mail system is not yet implemented (see issue 9)") } // ActionMail handles the `MAIL` command. // // This originally existed as the subroutine MAIL in bulletin1.for. func ActionMail(_ *dclish.Command) error { return errors.New("Mail system is not yet implemented (see issue 9)") } // ActionRespond handles the `RESPOND` command. // // This originally existed as the subroutine RESPOND_MAIL in bulletin2.for. func ActionRespond(_ *dclish.Command) error { return errors.New("Mail system is not yet implemented (see issue 9)") } repl/messages.go +56 −13 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ import ( // ActionDirectory handles the `DIRECTORY` command. This lists all the // messages in the current folder. // // This originally existed as the subroutines DIRECTORY in bulletin0.for // and DIRECTORY_FOLDERS in bulletin5.for. func ActionDirectory(cmd *dclish.Command) error { showExpiration := false if cmd.Flags["/EXPIRATION"].Value == "true" { Loading Loading @@ -55,6 +58,8 @@ func ActionDirectory(cmd *dclish.Command) error { } // ActionAdd handles the `ADD` command. This adds a message to a folder. // // This originally existed as the subroutine ADD in bulletin.for. func ActionAdd(cmd *dclish.Command) error { ctx := storage.Context() Loading Loading @@ -177,7 +182,10 @@ func ActionAdd(cmd *dclish.Command) error { return nil } // ActionCurrent handles the `CURRENT` command. // ActionCurrent handles the `CURRENT` command. This shows the head of // the current message. // // This originally existed as... not sure. func ActionCurrent(_ *dclish.Command) error { msg, err := folders.GetMessage(this.User.Login, this.Folder.Name, this.MsgID) if err != nil { Loading @@ -191,7 +199,10 @@ func ActionCurrent(_ *dclish.Command) error { return nil } // ActionBack handles the `BACK` command. // ActionBack handles the `BACK` command. Goes back and shows the previous // message. // // This originally existed as... not sure. func ActionBack(_ *dclish.Command) error { msgid := folders.PrevMsgid(this.User.Login, this.Folder.Name, this.MsgID) if msgid == 0 { Loading @@ -211,6 +222,8 @@ func ActionBack(_ *dclish.Command) error { // ActionChange handles the `CHANGE` command. This replaces or modifies // an existing message. // // This originally existed as... not sure. func ActionChange(cmd *dclish.Command) error { var err error isAdmin := this.User.Admin == 1 Loading Loading @@ -387,7 +400,10 @@ func ActionChange(cmd *dclish.Command) error { return nil } // ActionFirst handles the `FIRST` command. // ActionFirst handles the `FIRST` command. Prints the first message in // a folder. // // This originally existed as... not sure. func ActionFirst(_ *dclish.Command) error { msgid := folders.FirstMessage(this.Folder.Name) if msgid == 0 { Loading @@ -405,7 +421,9 @@ func ActionFirst(_ *dclish.Command) error { return nil } // ActionLast handles the `LAST` command. // ActionLast handles the `LAST` command. Prints the last message. // // This originally existed as... not sure. func ActionLast(_ *dclish.Command) error { msgid := folders.LastMessage(this.Folder.Name) if msgid == 0 { Loading @@ -423,7 +441,9 @@ func ActionLast(_ *dclish.Command) error { return nil } // ActionNext handles the `NEXT` command. // ActionNext handles the `NEXT` command. Shows the next message. // // This originally existed as... not sure. func ActionNext(_ *dclish.Command) error { msgid := folders.NextMsgid(this.User.Login, this.Folder.Name, this.MsgID) if msgid == 0 { Loading @@ -442,7 +462,11 @@ func ActionNext(_ *dclish.Command) error { return nil } // ActionPrint handles the `PRINT` command. // ActionPrint handles the `PRINT` command. This sends the message in // a way that the terminal will redirect it to an attached printer. Not // many (any?) terminals support it now. // // This originally existed as the subroutine PRINT in bulletin1.for. func ActionPrint(cmd *dclish.Command) error { all := false if cmd.Flags["/ALL"].Value == "true" { Loading Loading @@ -477,7 +501,10 @@ func ActionPrint(cmd *dclish.Command) error { return nil } // ActionRead handles the `READ` command. // ActionRead handles the `READ` command. Increment (except the first // time it's a called in a folder) and reads the message. // // This originally existed as the subroutine READ_MSG in bulletin1.for. func ActionRead(cmd *dclish.Command) error { defer func() { this.ReadFirstCall = false }() msgid := this.MsgID Loading Loading @@ -505,7 +532,10 @@ func ActionRead(cmd *dclish.Command) error { return nil } // ActionReply handles the `REPLY` command. // ActionReply handles the `REPLY` command. Used to create a reply to // a message. // // This originally existed as the subroutine REPLY in bulletin.for. func ActionReply(cmd *dclish.Command) error { extract := true if cmd.Flags["/EXTRACT"].Value == "false" { Loading Loading @@ -543,7 +573,9 @@ func ActionReply(cmd *dclish.Command) error { return nil } // ActionSeen handles the `SEEN` command. // ActionSeen handles the `SEEN` command. Marks messages as seen. // // This originally existed as... not sure. func ActionSeen(cmd *dclish.Command) error { var err error msgids := []int64{this.MsgID} Loading @@ -560,7 +592,9 @@ func ActionSeen(cmd *dclish.Command) error { return nil } // ActionUnseen handles the `UNSEEN` command. // ActionUnseen handles the `UNSEEN` command. Marks messages as unseen. // // This originally existed as... not sure. func ActionUnseen(cmd *dclish.Command) error { var err error msgids := []int64{this.MsgID} Loading @@ -577,7 +611,11 @@ func ActionUnseen(cmd *dclish.Command) error { return nil } // ActionDelete handles the `DELETE` command. // ActionDelete handles the `DELETE` command. This deletes a message. // As of now this is permanent. It would need to be changed to support // UNDELETE. // // This originally existed as the subroutine DELETE_MSG in bulletin0.for. func ActionDelete(cmd *dclish.Command) error { var err error Loading Loading @@ -617,7 +655,9 @@ func ActionDelete(cmd *dclish.Command) error { return nil } // ActionMark handles the `MARK` command. // ActionMark handles the `MARK` command. This sets a MARK on messages. // // This originally existed as... not sure. func ActionMark(cmd *dclish.Command) error { var err error msgids := []int64{this.MsgID} Loading @@ -634,7 +674,10 @@ func ActionMark(cmd *dclish.Command) error { return nil } // ActionUnmark handles the `UNMARK` command. // ActionUnmark handles the `UNMARK` command. This removes a MARK on // messages. // // This originally existed as... not sure. func ActionUnmark(cmd *dclish.Command) error { var err error msgids := []int64{this.MsgID} Loading Loading
repl/accounts.go +70 −20 Original line number Diff line number Diff line Loading @@ -10,15 +10,18 @@ import ( "git.lyda.ie/kevin/bulletin/storage" "git.lyda.ie/kevin/bulletin/this" "git.lyda.ie/kevin/bulletin/users" "github.com/pkg/errors" ) // ActionUser handles the `USER` command. // ActionUser handles the USER command - it prints out help for all the // USER subcommands. This is new to the Go version of BULLETIN. func ActionUser(cmd *dclish.Command) error { fmt.Println(cmd.Description) return nil } // ActionUserAdd handles the `USER ADD` command. // ActionUserAdd handles the `USER ADD` command. This is used to add a // new user. This is new to the Go version of BULLETIN. func ActionUserAdd(cmd *dclish.Command) error { ctx := storage.Context() login := strings.ToUpper(cmd.Args[0]) Loading Loading @@ -46,7 +49,10 @@ func ActionUserAdd(cmd *dclish.Command) error { return nil } // ActionUserList handles the `USER LIST` command. // ActionUserList handles the `USER LIST` command. This lists all the // users. For now this is limited to only the admin users. // // This is new to the Go version of BULLETIN. func ActionUserList(_ *dclish.Command) error { if this.User.Admin == 0 { fmt.Println("ERROR: You are not an admin.") Loading @@ -64,7 +70,10 @@ func ActionUserList(_ *dclish.Command) error { return nil } // ActionUserDelete handles the `USER DELETE` command. // ActionUserDelete handles the `USER DELETE` command. This will delete // the named user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserDelete(cmd *dclish.Command) error { if this.User.Admin == 0 { fmt.Println("ERROR: You are not an admin.") Loading Loading @@ -109,12 +118,18 @@ func actionUserEnable(cmd *dclish.Command, disabled int64, doing string) error { return nil } // ActionUserEnable handles the `USER ENABLE` command. // ActionUserEnable handles the `USER ENABLE` command. This enables // a user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserEnable(cmd *dclish.Command) error { return actionUserEnable(cmd, 0, "enable") } // ActionUserDisable handles the `USER DISABLE` command. // ActionUserDisable handles the `USER DISABLE` command. This disables // a user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserDisable(cmd *dclish.Command) error { return actionUserEnable(cmd, 1, "disable") } Loading @@ -126,8 +141,10 @@ func actionUserAdmin(cmd *dclish.Command, admin int64, doing string) error { } u, err := users.ValidExistingLogin(this.Q, cmd.Args[0]) if err != nil || u.Login == "" { fmt.Println("ERROR: User not found.") return nil return errors.New("User not found") } if u.Login == this.User.Login || u.Login == "SYSTEM" { return errors.New("Invalid user given") } if u.Admin == admin { fmt.Printf("User is already %s.\n", doing) Loading @@ -136,19 +153,24 @@ func actionUserAdmin(cmd *dclish.Command, admin int64, doing string) error { ctx := storage.Context() err = this.Q.UpdateUserAdmin(ctx, admin, u.Login) if err != nil { fmt.Printf("ERROR: Failed to make user %s (%s).\n", doing, err) return nil return errors.Errorf("Failed to make user %s (%s)", doing, err) } fmt.Printf("User is now %s.\n", doing) return nil } // ActionUserAdmin handles the `USER ADMIN` command. // ActionUserAdmin handles the `USER ADMIN` command. This makes the given // user an admin. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserAdmin(cmd *dclish.Command) error { return actionUserAdmin(cmd, 1, "an admin") } // ActionUserNoadmin handles the `USER NOADMIN` command. // ActionUserNoadmin handles the `USER NOADMIN` command. This removes the // admin bit from a given user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserNoadmin(cmd *dclish.Command) error { return actionUserAdmin(cmd, 0, "not an admin") } Loading Loading @@ -177,17 +199,26 @@ func actionUserMod(cmd *dclish.Command, mod int64, doing string) error { return nil } // ActionUserMod handles the `USER MOD` command. // ActionUserMod handles the `USER MOD` command. Makes given the user a // moderator. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserMod(cmd *dclish.Command) error { return actionUserMod(cmd, 1, "a moderator") } // ActionUserNomod handles the `USER NOMOD` command. // ActionUserNomod handles the `USER NOMOD` command. Removes the // moderator bit from the given user. Only the admin can use this command. // // This is new to the Go version of BULLETIN. func ActionUserNomod(cmd *dclish.Command) error { return actionUserMod(cmd, 0, "not a moderator") } // ActionUserName handles the `USER LIST` command. // ActionUserName handles the `USER NAME` command. Updates the user's // name. Only the admin can use the two argument version of this command. // // This is new to the Go version of BULLETIN. func ActionUserName(cmd *dclish.Command) error { if len(cmd.Args) == 2 && this.User.Admin == 0 { fmt.Println("ERROR: You are not an admin.") Loading @@ -212,13 +243,19 @@ func ActionUserName(cmd *dclish.Command) error { return nil } // ActionSSH handles the `SSH` command. // ActionSSH handles the `SSH` command. This prints the help for all the // SSH commands. These are used to manage the authorized_keys file. // These are new to the Go version of BULLETIN. func ActionSSH(cmd *dclish.Command) error { fmt.Println(cmd.Description) return nil } // ActionSSHAdd handles the `SSH ADD` command. // ActionSSHAdd handles the `SSH ADD` command. This adds a given ssh key // to the authorized_keys file for the given user. An admin can add // a new public key for another user. // // This is new to the Go version of BULLETIN. func ActionSSHAdd(cmd *dclish.Command) error { if this.User.Admin == 0 && len(cmd.Args) == 1 { fmt.Println("ERROR: You are not an admin.") Loading @@ -243,7 +280,11 @@ func ActionSSHAdd(cmd *dclish.Command) error { return nil } // ActionSSHList handles the `SSH LIST` command. // ActionSSHList handles the `SSH LIST` command. This lists all the // public keys for this user. An admin can list public keys for another // user. // // This is new to the Go version of BULLETIN. func ActionSSHList(cmd *dclish.Command) error { if this.User.Admin == 0 && len(cmd.Args) == 1 { fmt.Println("ERROR: You are not an admin.") Loading @@ -267,7 +308,11 @@ func ActionSSHList(cmd *dclish.Command) error { return nil } // ActionSSHDelete handles the `SSH DELETE` command. // ActionSSHDelete handles the `SSH DELETE` command. Removes ssh public // keys for a user. And admin can specify a different user to remove // public keys for. // // This is new to the Go version of BULLETIN. func ActionSSHDelete(cmd *dclish.Command) error { if this.User.Admin == 0 && len(cmd.Args) == 1 { fmt.Println("ERROR: You are not an admin.") Loading Loading @@ -309,7 +354,12 @@ func ActionSSHDelete(cmd *dclish.Command) error { return nil } // ActionSSHFetch handles the `SSH FETCH` command. // ActionSSHFetch handles the `SSH FETCH` command. This command pulls // public keys from code sites. It's the quickest way to // add a number of keys for a user. An admin can do this // for another user. // // This is new to the Go version of BULLETIN. func ActionSSHFetch(cmd *dclish.Command) error { login := this.User.Login sitename := cmd.Args[0] Loading
repl/folders.go +8 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ import ( ) // ActionIndex handles the `INDEX` command. This lists all the folders. // // This originally existed as the subroutine FULL_DIR in bulletin9.for. func ActionIndex(cmd *dclish.Command) error { if cmd.Flags["/MARKED"].Set { Loading Loading @@ -48,6 +50,8 @@ func ActionIndex(cmd *dclish.Command) error { } // ActionCreate handles the `CREATE` command. This creates a folder. // // This originally existed as the subroutine CREATE_FOLDER in bulletin4.for. func ActionCreate(cmd *dclish.Command) error { // Populate options... options := storage.CreateFolderParams{} Loading Loading @@ -118,6 +122,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], "%") { Loading @@ -137,6 +142,7 @@ func ActionSelect(cmd *dclish.Command) error { } // 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 { Loading Loading @@ -179,6 +185,8 @@ func ActionModify(cmd *dclish.Command) error { } // ActionRemove handles the `REMOVE` command. This modifies a folder. // // This originally existed as the subroutine REMOVE_FOLDER in bulletin5.for. func ActionRemove(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 delete the folder") Loading
repl/help.go +4 −1 Original line number Diff line number Diff line Loading @@ -191,7 +191,10 @@ func findHelp(hmap map[string]string, args []string, fullcmd string) string { return helptext } // ActionHelp handles the `HELP` command. // ActionHelp handles the `HELP` command. This provides help taxt // for each command. // // This originally existed as the subroutine HELP in bulletin8.for. func ActionHelp(cmd *dclish.Command) error { if len(cmd.Args) == 0 { fmt.Printf("%s\n", helpmap["HELP"]) Loading
repl/mail.go +6 −0 Original line number Diff line number Diff line Loading @@ -7,16 +7,22 @@ import ( ) // ActionForward handles the `FORWARD` command. // // This originally existed as the subroutine MAIL in bulletin1.for. func ActionForward(_ *dclish.Command) error { return errors.New("Mail system is not yet implemented (see issue 9)") } // ActionMail handles the `MAIL` command. // // This originally existed as the subroutine MAIL in bulletin1.for. func ActionMail(_ *dclish.Command) error { return errors.New("Mail system is not yet implemented (see issue 9)") } // ActionRespond handles the `RESPOND` command. // // This originally existed as the subroutine RESPOND_MAIL in bulletin2.for. func ActionRespond(_ *dclish.Command) error { return errors.New("Mail system is not yet implemented (see issue 9)") }
repl/messages.go +56 −13 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ import ( // ActionDirectory handles the `DIRECTORY` command. This lists all the // messages in the current folder. // // This originally existed as the subroutines DIRECTORY in bulletin0.for // and DIRECTORY_FOLDERS in bulletin5.for. func ActionDirectory(cmd *dclish.Command) error { showExpiration := false if cmd.Flags["/EXPIRATION"].Value == "true" { Loading Loading @@ -55,6 +58,8 @@ func ActionDirectory(cmd *dclish.Command) error { } // ActionAdd handles the `ADD` command. This adds a message to a folder. // // This originally existed as the subroutine ADD in bulletin.for. func ActionAdd(cmd *dclish.Command) error { ctx := storage.Context() Loading Loading @@ -177,7 +182,10 @@ func ActionAdd(cmd *dclish.Command) error { return nil } // ActionCurrent handles the `CURRENT` command. // ActionCurrent handles the `CURRENT` command. This shows the head of // the current message. // // This originally existed as... not sure. func ActionCurrent(_ *dclish.Command) error { msg, err := folders.GetMessage(this.User.Login, this.Folder.Name, this.MsgID) if err != nil { Loading @@ -191,7 +199,10 @@ func ActionCurrent(_ *dclish.Command) error { return nil } // ActionBack handles the `BACK` command. // ActionBack handles the `BACK` command. Goes back and shows the previous // message. // // This originally existed as... not sure. func ActionBack(_ *dclish.Command) error { msgid := folders.PrevMsgid(this.User.Login, this.Folder.Name, this.MsgID) if msgid == 0 { Loading @@ -211,6 +222,8 @@ func ActionBack(_ *dclish.Command) error { // ActionChange handles the `CHANGE` command. This replaces or modifies // an existing message. // // This originally existed as... not sure. func ActionChange(cmd *dclish.Command) error { var err error isAdmin := this.User.Admin == 1 Loading Loading @@ -387,7 +400,10 @@ func ActionChange(cmd *dclish.Command) error { return nil } // ActionFirst handles the `FIRST` command. // ActionFirst handles the `FIRST` command. Prints the first message in // a folder. // // This originally existed as... not sure. func ActionFirst(_ *dclish.Command) error { msgid := folders.FirstMessage(this.Folder.Name) if msgid == 0 { Loading @@ -405,7 +421,9 @@ func ActionFirst(_ *dclish.Command) error { return nil } // ActionLast handles the `LAST` command. // ActionLast handles the `LAST` command. Prints the last message. // // This originally existed as... not sure. func ActionLast(_ *dclish.Command) error { msgid := folders.LastMessage(this.Folder.Name) if msgid == 0 { Loading @@ -423,7 +441,9 @@ func ActionLast(_ *dclish.Command) error { return nil } // ActionNext handles the `NEXT` command. // ActionNext handles the `NEXT` command. Shows the next message. // // This originally existed as... not sure. func ActionNext(_ *dclish.Command) error { msgid := folders.NextMsgid(this.User.Login, this.Folder.Name, this.MsgID) if msgid == 0 { Loading @@ -442,7 +462,11 @@ func ActionNext(_ *dclish.Command) error { return nil } // ActionPrint handles the `PRINT` command. // ActionPrint handles the `PRINT` command. This sends the message in // a way that the terminal will redirect it to an attached printer. Not // many (any?) terminals support it now. // // This originally existed as the subroutine PRINT in bulletin1.for. func ActionPrint(cmd *dclish.Command) error { all := false if cmd.Flags["/ALL"].Value == "true" { Loading Loading @@ -477,7 +501,10 @@ func ActionPrint(cmd *dclish.Command) error { return nil } // ActionRead handles the `READ` command. // ActionRead handles the `READ` command. Increment (except the first // time it's a called in a folder) and reads the message. // // This originally existed as the subroutine READ_MSG in bulletin1.for. func ActionRead(cmd *dclish.Command) error { defer func() { this.ReadFirstCall = false }() msgid := this.MsgID Loading Loading @@ -505,7 +532,10 @@ func ActionRead(cmd *dclish.Command) error { return nil } // ActionReply handles the `REPLY` command. // ActionReply handles the `REPLY` command. Used to create a reply to // a message. // // This originally existed as the subroutine REPLY in bulletin.for. func ActionReply(cmd *dclish.Command) error { extract := true if cmd.Flags["/EXTRACT"].Value == "false" { Loading Loading @@ -543,7 +573,9 @@ func ActionReply(cmd *dclish.Command) error { return nil } // ActionSeen handles the `SEEN` command. // ActionSeen handles the `SEEN` command. Marks messages as seen. // // This originally existed as... not sure. func ActionSeen(cmd *dclish.Command) error { var err error msgids := []int64{this.MsgID} Loading @@ -560,7 +592,9 @@ func ActionSeen(cmd *dclish.Command) error { return nil } // ActionUnseen handles the `UNSEEN` command. // ActionUnseen handles the `UNSEEN` command. Marks messages as unseen. // // This originally existed as... not sure. func ActionUnseen(cmd *dclish.Command) error { var err error msgids := []int64{this.MsgID} Loading @@ -577,7 +611,11 @@ func ActionUnseen(cmd *dclish.Command) error { return nil } // ActionDelete handles the `DELETE` command. // ActionDelete handles the `DELETE` command. This deletes a message. // As of now this is permanent. It would need to be changed to support // UNDELETE. // // This originally existed as the subroutine DELETE_MSG in bulletin0.for. func ActionDelete(cmd *dclish.Command) error { var err error Loading Loading @@ -617,7 +655,9 @@ func ActionDelete(cmd *dclish.Command) error { return nil } // ActionMark handles the `MARK` command. // ActionMark handles the `MARK` command. This sets a MARK on messages. // // This originally existed as... not sure. func ActionMark(cmd *dclish.Command) error { var err error msgids := []int64{this.MsgID} Loading @@ -634,7 +674,10 @@ func ActionMark(cmd *dclish.Command) error { return nil } // ActionUnmark handles the `UNMARK` command. // ActionUnmark handles the `UNMARK` command. This removes a MARK on // messages. // // This originally existed as... not sure. func ActionUnmark(cmd *dclish.Command) error { var err error msgids := []int64{this.MsgID} Loading