Loading folders/folders.go +1 −5 Original line number Diff line number Diff line Loading @@ -46,11 +46,7 @@ func CreateFolder(options storage.CreateFolderParams) error { options.Name = strings.ToUpper(options.Name) ctx := storage.Context() err := this.Q.CreateFolder(ctx, options) if err != nil { return err } return err return this.Q.CreateFolder(ctx, options) } // ListFolder provides a list of folders that this.User has access to. Loading folders/messages.go +17 −8 Original line number Diff line number Diff line Loading @@ -60,7 +60,9 @@ func MarkSeen(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.SetMessageSeen(ctx, this.User.Login, this.Folder.Name, msgid) if err := this.Q.SetMessageSeen(ctx, this.User.Login, this.Folder.Name, msgid); err != nil { return err } } return nil } Loading @@ -70,7 +72,9 @@ func MarkUnseen(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.UnsetMessageSeen(ctx, this.User.Login, this.Folder.Name, msgid) if err := this.Q.UnsetMessageSeen(ctx, this.User.Login, this.Folder.Name, msgid); err != nil { return err } } return nil } Loading Loading @@ -143,7 +147,9 @@ func DeleteMessages(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.DeleteMessage(ctx, msgid, this.Folder.Name) if err := this.Q.DeleteMessage(ctx, msgid, this.Folder.Name); err != nil { return err } } return nil } Loading @@ -152,8 +158,7 @@ func DeleteMessages(msgids []int64) error { func DeleteAllMessages() error { ctx := storage.Context() _ = this.Q.DeleteAllMessages(ctx, this.Folder.Name) return nil return this.Q.DeleteAllMessages(ctx, this.Folder.Name) } // SetMark sets a mark for message(s). Loading @@ -161,17 +166,21 @@ func SetMark(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.AddMark(ctx, this.Folder.Name, this.User.Login, msgid) if err := this.Q.AddMark(ctx, this.Folder.Name, this.User.Login, msgid); err != nil { return err } } return nil } // UnsetMark sets a mark for message(s). // UnsetMark removes a mark for message(s). func UnsetMark(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.DeleteMark(ctx, this.Folder.Name, this.User.Login, msgid) if err := this.Q.DeleteMark(ctx, this.Folder.Name, this.User.Login, msgid); err != nil { return err } } return nil } repl/misc.go +7 −5 Original line number Diff line number Diff line package repl import ( "errors" "fmt" "os" "git.lyda.ie/pp/bulletin/dclish" ) // ErrExit is a sentinel error returned by EXIT and QUIT to cleanly // exit the REPL loop without calling os.Exit directly. var ErrExit = errors.New("exit") // ActionQuit handles the `QUIT` command. This exits BULLETIN. func ActionQuit(_ *dclish.Command) error { fmt.Println("QUIT") os.Exit(0) return nil return ErrExit } // ActionExit handles the `EXIT` command. This exits BULLETIN. func ActionExit(_ *dclish.Command) error { fmt.Println("EXIT") os.Exit(0) return nil return ErrExit } repl/repl.go +7 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package repl import ( "errors" "fmt" "os" "path" Loading Loading @@ -60,11 +61,11 @@ func Loop() error { line, err := rl.Readline() if err != nil { if err.Error() == "Interrupt" { _ = commands.ParseAndRun("QUIT") fmt.Println("QUIT") } else if err.Error() == "EOF" { _ = commands.ParseAndRun("EXIT") fmt.Println("EXIT") } return err return nil } if len(line) == 0 { continue Loading @@ -83,6 +84,9 @@ func Loop() error { line = "READ " + line } err = commands.ParseAndRun(line) if errors.Is(err, ErrExit) { return nil } if err != nil { fmt.Printf("ERROR: %s.\n", err) } Loading storage/broadcast.sql.go +4 −3 Original line number Diff line number Diff line Loading @@ -11,15 +11,16 @@ import ( ) const createBroadcast = `-- name: CreateBroadcast :exec INSERT INTO broadcast INSERT OR REPLACE INTO broadcast (author, bell, message) VALUES (?, ?, ?) ` // CreateBroadcast adds a new broadcast message. // CreateBroadcast adds a new broadcast message. If the author already // has a broadcast, it is replaced. // // INSERT INTO broadcast // INSERT OR REPLACE INTO broadcast // (author, bell, message) // VALUES // (?, ?, ?) Loading Loading
folders/folders.go +1 −5 Original line number Diff line number Diff line Loading @@ -46,11 +46,7 @@ func CreateFolder(options storage.CreateFolderParams) error { options.Name = strings.ToUpper(options.Name) ctx := storage.Context() err := this.Q.CreateFolder(ctx, options) if err != nil { return err } return err return this.Q.CreateFolder(ctx, options) } // ListFolder provides a list of folders that this.User has access to. Loading
folders/messages.go +17 −8 Original line number Diff line number Diff line Loading @@ -60,7 +60,9 @@ func MarkSeen(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.SetMessageSeen(ctx, this.User.Login, this.Folder.Name, msgid) if err := this.Q.SetMessageSeen(ctx, this.User.Login, this.Folder.Name, msgid); err != nil { return err } } return nil } Loading @@ -70,7 +72,9 @@ func MarkUnseen(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.UnsetMessageSeen(ctx, this.User.Login, this.Folder.Name, msgid) if err := this.Q.UnsetMessageSeen(ctx, this.User.Login, this.Folder.Name, msgid); err != nil { return err } } return nil } Loading Loading @@ -143,7 +147,9 @@ func DeleteMessages(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.DeleteMessage(ctx, msgid, this.Folder.Name) if err := this.Q.DeleteMessage(ctx, msgid, this.Folder.Name); err != nil { return err } } return nil } Loading @@ -152,8 +158,7 @@ func DeleteMessages(msgids []int64) error { func DeleteAllMessages() error { ctx := storage.Context() _ = this.Q.DeleteAllMessages(ctx, this.Folder.Name) return nil return this.Q.DeleteAllMessages(ctx, this.Folder.Name) } // SetMark sets a mark for message(s). Loading @@ -161,17 +166,21 @@ func SetMark(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.AddMark(ctx, this.Folder.Name, this.User.Login, msgid) if err := this.Q.AddMark(ctx, this.Folder.Name, this.User.Login, msgid); err != nil { return err } } return nil } // UnsetMark sets a mark for message(s). // UnsetMark removes a mark for message(s). func UnsetMark(msgids []int64) error { ctx := storage.Context() for _, msgid := range msgids { _ = this.Q.DeleteMark(ctx, this.Folder.Name, this.User.Login, msgid) if err := this.Q.DeleteMark(ctx, this.Folder.Name, this.User.Login, msgid); err != nil { return err } } return nil }
repl/misc.go +7 −5 Original line number Diff line number Diff line package repl import ( "errors" "fmt" "os" "git.lyda.ie/pp/bulletin/dclish" ) // ErrExit is a sentinel error returned by EXIT and QUIT to cleanly // exit the REPL loop without calling os.Exit directly. var ErrExit = errors.New("exit") // ActionQuit handles the `QUIT` command. This exits BULLETIN. func ActionQuit(_ *dclish.Command) error { fmt.Println("QUIT") os.Exit(0) return nil return ErrExit } // ActionExit handles the `EXIT` command. This exits BULLETIN. func ActionExit(_ *dclish.Command) error { fmt.Println("EXIT") os.Exit(0) return nil return ErrExit }
repl/repl.go +7 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package repl import ( "errors" "fmt" "os" "path" Loading Loading @@ -60,11 +61,11 @@ func Loop() error { line, err := rl.Readline() if err != nil { if err.Error() == "Interrupt" { _ = commands.ParseAndRun("QUIT") fmt.Println("QUIT") } else if err.Error() == "EOF" { _ = commands.ParseAndRun("EXIT") fmt.Println("EXIT") } return err return nil } if len(line) == 0 { continue Loading @@ -83,6 +84,9 @@ func Loop() error { line = "READ " + line } err = commands.ParseAndRun(line) if errors.Is(err, ErrExit) { return nil } if err != nil { fmt.Printf("ERROR: %s.\n", err) } Loading
storage/broadcast.sql.go +4 −3 Original line number Diff line number Diff line Loading @@ -11,15 +11,16 @@ import ( ) const createBroadcast = `-- name: CreateBroadcast :exec INSERT INTO broadcast INSERT OR REPLACE INTO broadcast (author, bell, message) VALUES (?, ?, ?) ` // CreateBroadcast adds a new broadcast message. // CreateBroadcast adds a new broadcast message. If the author already // has a broadcast, it is replaced. // // INSERT INTO broadcast // INSERT OR REPLACE INTO broadcast // (author, bell, message) // VALUES // (?, ?, ?) Loading