Loading editor/tview.go +4 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ import ( ) // Editor is the editor for text files. func Editor(placeholder, title string) (string, error) { func Editor(placeholder, title, message string) (string, error) { theme := tview.Theme{ PrimitiveBackgroundColor: tcell.ColorDefault, ContrastBackgroundColor: tcell.ColorDefault, Loading Loading @@ -138,6 +138,9 @@ Press Enter for more help, press Escape to return.`) return event }) if message != "" { textArea.SetText(message, true) } err := app.SetRoot(pages, true).Run() if err != nil { return "", err Loading folders/messages.go +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ func CreateMessage(author, subject, message, folder string, permanent, shutdown // ReadMessage reads a message for a user. func ReadMessage(login, folder string, msgid int64) (*storage.Message, error) { ctx := storage.Context() fmt.Printf("TODO: Make sure %s can read this message.\n", login) fmt.Printf("TODO(ReadMessage): Make sure %s can read this message.\n", login) msg, err := this.Q.ReadMessage(ctx, storage.ReadMessageParams{ Folder: folder, ID: msgid, Loading repl/command.go +1 −0 Original line number Diff line number Diff line Loading @@ -834,6 +834,7 @@ the same as the ADD command except for /NOINDENT and /EXTRACT. message. This is the default - suppress with /NOEXTRACT. The text of the message is indented with > at the beginning of each line. This can be suppressed with /NOINDENT.`, Default: "true", }, "/INDENT": { Description: ` See /EXTRACT for information on this qualifier. Loading repl/messages.go +43 −2 Original line number Diff line number Diff line Loading @@ -138,7 +138,10 @@ func ActionAdd(cmd *dclish.Command) error { } // TODO: check we have permission for shutdown and permanent message, err := editor.Editor(fmt.Sprintf("Enter message for '%s'...", optSubject), "Edit message") message, err := editor.Editor( fmt.Sprintf("Enter message for '%s'...", optSubject), "Edit message", "") if err != nil { return err } Loading Loading @@ -293,7 +296,45 @@ func ActionRead(cmd *dclish.Command) error { // ActionReply handles the `REPLY` command. func ActionReply(cmd *dclish.Command) error { fmt.Printf("TODO: unimplemented...\n%s\n", cmd.Description) extract := true if cmd.Flags["/EXTRACT"].Value == "false" { extract = false } indent := true if cmd.Flags["/INDENT"].Value == "false" { indent = false } fmt.Printf("TODO: getting message %d.\n", this.MsgID) original, err := folders.ReadMessage(this.User.Login, this.Folder.Name, this.MsgID) origMsg := "" if extract { if indent { origMsg = "> " + strings.Join(strings.Split(original.Message, "\n"), "\n> ") fmt.Println("TODO: extract and indent are true.") } else { origMsg = original.Message fmt.Println("TODO: extract is true.") } } else { fmt.Println("TODO: neither is true.") } // TODO; this isn't working - the message isn't getting loaded. subject := "Re: " + original.Subject message, err := editor.Editor( fmt.Sprintf("Enter message for '%s'...", subject), "Edit message", origMsg) if err != nil { fmt.Printf("ERROR: Editor failure (%s).\n", err) return nil } err = folders.CreateMessage(this.User.Login, subject, message, this.Folder.Name, 0, 0, nil) if err != nil { fmt.Printf("ERROR: CreateMessage failure (%s).\n", err) return nil } return nil } Loading storage/messages.sql.go +5 −5 Original line number Diff line number Diff line Loading @@ -15,12 +15,12 @@ INSERT INTO messages ( id, folder, author, subject, message, permanent, shutdown, expiration ) VALUES ( (SELECT COALESCE(MAX(id), 0) + 1 FROM messages AS m WHERE m.folder = ?1), ?2, ?1, ?3, ?4, ?5, ?6, ?7) ?1, ?2, ?3, ?4, ?5, ?6, ?7) ` type CreateMessageParams struct { Author string Folder string Author string Subject string Message string Permanent int64 Loading @@ -30,8 +30,8 @@ type CreateMessageParams struct { func (q *Queries) CreateMessage(ctx context.Context, arg CreateMessageParams) error { _, err := q.db.ExecContext(ctx, createMessage, arg.Author, arg.Folder, arg.Author, arg.Subject, arg.Message, arg.Permanent, Loading Loading @@ -162,7 +162,7 @@ func (q *Queries) LastMsgidIgnoringSeen(ctx context.Context, folder string) (int const nextMsgid = `-- name: NextMsgid :one SELECT CAST(COALESCE(MIN(id), 0) AS INT) FROM messages AS m WHERE m.folder = ?1 AND m.id > ?2 AND id NOT IN (SELECT id FROM seen AS s WHERE s.folder = ?1 AND s.login = ?3) AND id NOT IN (SELECT msgid FROM seen AS s WHERE s.folder = ?1 AND s.login = ?3) ` type NextMsgidParams struct { Loading Loading @@ -198,7 +198,7 @@ func (q *Queries) NextMsgidIgnoringSeen(ctx context.Context, arg NextMsgidIgnori const prevMsgid = `-- name: PrevMsgid :one SELECT CAST(COALESCE(MAX(id), 0) AS INT) FROM messages AS m WHERE m.folder = ?1 AND m.id < ?2 AND id NOT IN (SELECT id FROM seen AS s WHERE s.folder = ?1 AND s.login = ?3) AND id NOT IN (SELECT msgid FROM seen AS s WHERE s.folder = ?1 AND s.login = ?3) ` type PrevMsgidParams struct { Loading Loading
editor/tview.go +4 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ import ( ) // Editor is the editor for text files. func Editor(placeholder, title string) (string, error) { func Editor(placeholder, title, message string) (string, error) { theme := tview.Theme{ PrimitiveBackgroundColor: tcell.ColorDefault, ContrastBackgroundColor: tcell.ColorDefault, Loading Loading @@ -138,6 +138,9 @@ Press Enter for more help, press Escape to return.`) return event }) if message != "" { textArea.SetText(message, true) } err := app.SetRoot(pages, true).Run() if err != nil { return "", err Loading
folders/messages.go +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ func CreateMessage(author, subject, message, folder string, permanent, shutdown // ReadMessage reads a message for a user. func ReadMessage(login, folder string, msgid int64) (*storage.Message, error) { ctx := storage.Context() fmt.Printf("TODO: Make sure %s can read this message.\n", login) fmt.Printf("TODO(ReadMessage): Make sure %s can read this message.\n", login) msg, err := this.Q.ReadMessage(ctx, storage.ReadMessageParams{ Folder: folder, ID: msgid, Loading
repl/command.go +1 −0 Original line number Diff line number Diff line Loading @@ -834,6 +834,7 @@ the same as the ADD command except for /NOINDENT and /EXTRACT. message. This is the default - suppress with /NOEXTRACT. The text of the message is indented with > at the beginning of each line. This can be suppressed with /NOINDENT.`, Default: "true", }, "/INDENT": { Description: ` See /EXTRACT for information on this qualifier. Loading
repl/messages.go +43 −2 Original line number Diff line number Diff line Loading @@ -138,7 +138,10 @@ func ActionAdd(cmd *dclish.Command) error { } // TODO: check we have permission for shutdown and permanent message, err := editor.Editor(fmt.Sprintf("Enter message for '%s'...", optSubject), "Edit message") message, err := editor.Editor( fmt.Sprintf("Enter message for '%s'...", optSubject), "Edit message", "") if err != nil { return err } Loading Loading @@ -293,7 +296,45 @@ func ActionRead(cmd *dclish.Command) error { // ActionReply handles the `REPLY` command. func ActionReply(cmd *dclish.Command) error { fmt.Printf("TODO: unimplemented...\n%s\n", cmd.Description) extract := true if cmd.Flags["/EXTRACT"].Value == "false" { extract = false } indent := true if cmd.Flags["/INDENT"].Value == "false" { indent = false } fmt.Printf("TODO: getting message %d.\n", this.MsgID) original, err := folders.ReadMessage(this.User.Login, this.Folder.Name, this.MsgID) origMsg := "" if extract { if indent { origMsg = "> " + strings.Join(strings.Split(original.Message, "\n"), "\n> ") fmt.Println("TODO: extract and indent are true.") } else { origMsg = original.Message fmt.Println("TODO: extract is true.") } } else { fmt.Println("TODO: neither is true.") } // TODO; this isn't working - the message isn't getting loaded. subject := "Re: " + original.Subject message, err := editor.Editor( fmt.Sprintf("Enter message for '%s'...", subject), "Edit message", origMsg) if err != nil { fmt.Printf("ERROR: Editor failure (%s).\n", err) return nil } err = folders.CreateMessage(this.User.Login, subject, message, this.Folder.Name, 0, 0, nil) if err != nil { fmt.Printf("ERROR: CreateMessage failure (%s).\n", err) return nil } return nil } Loading
storage/messages.sql.go +5 −5 Original line number Diff line number Diff line Loading @@ -15,12 +15,12 @@ INSERT INTO messages ( id, folder, author, subject, message, permanent, shutdown, expiration ) VALUES ( (SELECT COALESCE(MAX(id), 0) + 1 FROM messages AS m WHERE m.folder = ?1), ?2, ?1, ?3, ?4, ?5, ?6, ?7) ?1, ?2, ?3, ?4, ?5, ?6, ?7) ` type CreateMessageParams struct { Author string Folder string Author string Subject string Message string Permanent int64 Loading @@ -30,8 +30,8 @@ type CreateMessageParams struct { func (q *Queries) CreateMessage(ctx context.Context, arg CreateMessageParams) error { _, err := q.db.ExecContext(ctx, createMessage, arg.Author, arg.Folder, arg.Author, arg.Subject, arg.Message, arg.Permanent, Loading Loading @@ -162,7 +162,7 @@ func (q *Queries) LastMsgidIgnoringSeen(ctx context.Context, folder string) (int const nextMsgid = `-- name: NextMsgid :one SELECT CAST(COALESCE(MIN(id), 0) AS INT) FROM messages AS m WHERE m.folder = ?1 AND m.id > ?2 AND id NOT IN (SELECT id FROM seen AS s WHERE s.folder = ?1 AND s.login = ?3) AND id NOT IN (SELECT msgid FROM seen AS s WHERE s.folder = ?1 AND s.login = ?3) ` type NextMsgidParams struct { Loading Loading @@ -198,7 +198,7 @@ func (q *Queries) NextMsgidIgnoringSeen(ctx context.Context, arg NextMsgidIgnori const prevMsgid = `-- name: PrevMsgid :one SELECT CAST(COALESCE(MAX(id), 0) AS INT) FROM messages AS m WHERE m.folder = ?1 AND m.id < ?2 AND id NOT IN (SELECT id FROM seen AS s WHERE s.folder = ?1 AND s.login = ?3) AND id NOT IN (SELECT msgid FROM seen AS s WHERE s.folder = ?1 AND s.login = ?3) ` type PrevMsgidParams struct { Loading