Commit 3957fec3 authored by Kevin Lyda's avatar Kevin Lyda
Browse files

Address minor bugs

parent 4c235f1d
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -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.
+17 −8
Original line number Diff line number Diff line
@@ -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
}
@@ -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
}
@@ -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
}
@@ -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).
@@ -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
}
+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
}
+7 −3
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
package repl

import (
	"errors"
	"fmt"
	"os"
	"path"
@@ -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
@@ -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)
		}
+4 −3
Original line number Diff line number Diff line
@@ -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