Loading repl/command.go +2 −3 Original line number Diff line number Diff line Loading @@ -1647,9 +1647,8 @@ have done this.`, Description: `/FOLDER=[foldername] Specifies to display the latest message that was read by the user(s) for the specified foldername. A newsgroup can be specified, but the info can only be shown if the user has subscribed to the newsgroup. If the foldername is not specified, the selected folder will be used.`, for the specified foldername. If the foldername is not specified, the selected folder will be used.`, }, "/SINCE": { Description: `/SINCE=[date] Loading repl/show.go +18 −1 Original line number Diff line number Diff line Loading @@ -115,8 +115,25 @@ func ActionShowPrivileges(_ *dclish.Command) error { } // ActionShowUser handles the `SHOW USER` command. func ActionShowUser(_ *dclish.Command) error { func ActionShowUser(cmd *dclish.Command) error { showAll := false if cmd.Flags["/ALL"].Value == "true" { // TODO: Check permissions. showAll = true } showLogin := false if cmd.Flags["/LOGIN"].Value == "true" { // TODO: Check permissions. showLogin = true } folder := this.Folder if cmd.Flags["/FOLDER"].Value != "" { // TODO: Check permissions. folder = folders.FindFolder(cmd.Flags["/FOLDER"].Value) } since := cmd.Flags["/FOLDER"].Value fmt.Println("TODO: implement ActionShowUser.") fmt.Printf("TODO: %t %t %s %s.\n", showAll, showLogin, folder.Name, since) return nil } Loading storage/migrations/1_create_table.up.sql +10 −0 Original line number Diff line number Diff line Loading @@ -121,12 +121,22 @@ CREATE TABLE messages ( CREATE INDEX messages_idx_shutdown ON messages(shutdown); CREATE INDEX messages_idx_expiration ON messages(expiration); CREATE TRIGGER messages_after_update_update_at AFTER UPDATE ON messages FOR EACH ROW WHEN NEW.update_at = OLD.update_at --- avoid infinite loop BEGIN UPDATE messages SET update_at=CURRENT_TIMESTAMP WHERE folder=NEW.folder AND id=NEW.id; END; CREATE TABLE seen ( login VARCHAR(25) REFERENCES users(login) ON DELETE CASCADE ON UPDATE CASCADE NOT NULL, folder VARCHAR(25) REFERENCES folders(name) ON DELETE CASCADE ON UPDATE CASCADE NOT NULL, msgid INT NOT NULL, create_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, --- Nothing to update in this table. PRIMARY KEY (folder, login, msgid), CONSTRAINT read_fk_id_folder FOREIGN KEY (msgid, folder) Loading storage/models.go +4 −3 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ type Seen struct { Login string Folder string Msgid int64 CreateAt time.Time } type System struct { Loading storage/standard.sql.go +14 −4 Original line number Diff line number Diff line Loading @@ -376,7 +376,7 @@ func (q *Queries) GetOwners(ctx context.Context, folder string) ([]Owner, error) } const getSeen = `-- name: GetSeen :one SELECT login, folder, msgid FROM seen WHERE folder = ? AND login = ? AND msgid = ? SELECT login, folder, msgid, create_at FROM seen WHERE folder = ? AND login = ? AND msgid = ? ` type GetSeenParams struct { Loading @@ -388,7 +388,12 @@ type GetSeenParams struct { func (q *Queries) GetSeen(ctx context.Context, arg GetSeenParams) (Seen, error) { row := q.db.QueryRowContext(ctx, getSeen, arg.Folder, arg.Login, arg.Msgid) var i Seen err := row.Scan(&i.Login, &i.Folder, &i.Msgid) err := row.Scan( &i.Login, &i.Folder, &i.Msgid, &i.CreateAt, ) return i, err } Loading Loading @@ -600,7 +605,7 @@ func (q *Queries) ListOwners(ctx context.Context) ([]Owner, error) { } const listSeen = `-- name: ListSeen :many SELECT login, folder, msgid FROM seen SELECT login, folder, msgid, create_at FROM seen ` func (q *Queries) ListSeen(ctx context.Context) ([]Seen, error) { Loading @@ -612,7 +617,12 @@ func (q *Queries) ListSeen(ctx context.Context) ([]Seen, error) { var items []Seen for rows.Next() { var i Seen if err := rows.Scan(&i.Login, &i.Folder, &i.Msgid); err != nil { if err := rows.Scan( &i.Login, &i.Folder, &i.Msgid, &i.CreateAt, ); err != nil { return nil, err } items = append(items, i) Loading Loading
repl/command.go +2 −3 Original line number Diff line number Diff line Loading @@ -1647,9 +1647,8 @@ have done this.`, Description: `/FOLDER=[foldername] Specifies to display the latest message that was read by the user(s) for the specified foldername. A newsgroup can be specified, but the info can only be shown if the user has subscribed to the newsgroup. If the foldername is not specified, the selected folder will be used.`, for the specified foldername. If the foldername is not specified, the selected folder will be used.`, }, "/SINCE": { Description: `/SINCE=[date] Loading
repl/show.go +18 −1 Original line number Diff line number Diff line Loading @@ -115,8 +115,25 @@ func ActionShowPrivileges(_ *dclish.Command) error { } // ActionShowUser handles the `SHOW USER` command. func ActionShowUser(_ *dclish.Command) error { func ActionShowUser(cmd *dclish.Command) error { showAll := false if cmd.Flags["/ALL"].Value == "true" { // TODO: Check permissions. showAll = true } showLogin := false if cmd.Flags["/LOGIN"].Value == "true" { // TODO: Check permissions. showLogin = true } folder := this.Folder if cmd.Flags["/FOLDER"].Value != "" { // TODO: Check permissions. folder = folders.FindFolder(cmd.Flags["/FOLDER"].Value) } since := cmd.Flags["/FOLDER"].Value fmt.Println("TODO: implement ActionShowUser.") fmt.Printf("TODO: %t %t %s %s.\n", showAll, showLogin, folder.Name, since) return nil } Loading
storage/migrations/1_create_table.up.sql +10 −0 Original line number Diff line number Diff line Loading @@ -121,12 +121,22 @@ CREATE TABLE messages ( CREATE INDEX messages_idx_shutdown ON messages(shutdown); CREATE INDEX messages_idx_expiration ON messages(expiration); CREATE TRIGGER messages_after_update_update_at AFTER UPDATE ON messages FOR EACH ROW WHEN NEW.update_at = OLD.update_at --- avoid infinite loop BEGIN UPDATE messages SET update_at=CURRENT_TIMESTAMP WHERE folder=NEW.folder AND id=NEW.id; END; CREATE TABLE seen ( login VARCHAR(25) REFERENCES users(login) ON DELETE CASCADE ON UPDATE CASCADE NOT NULL, folder VARCHAR(25) REFERENCES folders(name) ON DELETE CASCADE ON UPDATE CASCADE NOT NULL, msgid INT NOT NULL, create_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, --- Nothing to update in this table. PRIMARY KEY (folder, login, msgid), CONSTRAINT read_fk_id_folder FOREIGN KEY (msgid, folder) Loading
storage/models.go +4 −3 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ type Seen struct { Login string Folder string Msgid int64 CreateAt time.Time } type System struct { Loading
storage/standard.sql.go +14 −4 Original line number Diff line number Diff line Loading @@ -376,7 +376,7 @@ func (q *Queries) GetOwners(ctx context.Context, folder string) ([]Owner, error) } const getSeen = `-- name: GetSeen :one SELECT login, folder, msgid FROM seen WHERE folder = ? AND login = ? AND msgid = ? SELECT login, folder, msgid, create_at FROM seen WHERE folder = ? AND login = ? AND msgid = ? ` type GetSeenParams struct { Loading @@ -388,7 +388,12 @@ type GetSeenParams struct { func (q *Queries) GetSeen(ctx context.Context, arg GetSeenParams) (Seen, error) { row := q.db.QueryRowContext(ctx, getSeen, arg.Folder, arg.Login, arg.Msgid) var i Seen err := row.Scan(&i.Login, &i.Folder, &i.Msgid) err := row.Scan( &i.Login, &i.Folder, &i.Msgid, &i.CreateAt, ) return i, err } Loading Loading @@ -600,7 +605,7 @@ func (q *Queries) ListOwners(ctx context.Context) ([]Owner, error) { } const listSeen = `-- name: ListSeen :many SELECT login, folder, msgid FROM seen SELECT login, folder, msgid, create_at FROM seen ` func (q *Queries) ListSeen(ctx context.Context) ([]Seen, error) { Loading @@ -612,7 +617,12 @@ func (q *Queries) ListSeen(ctx context.Context) ([]Seen, error) { var items []Seen for rows.Next() { var i Seen if err := rows.Scan(&i.Login, &i.Folder, &i.Msgid); err != nil { if err := rows.Scan( &i.Login, &i.Folder, &i.Msgid, &i.CreateAt, ); err != nil { return nil, err } items = append(items, i) Loading