From 9fca0a4a1b2f238d109e7168bdf4a7648e226c9f Mon Sep 17 00:00:00 2001
From: Kevin Lyda <kevin@lyda.ie>
Date: Sat, 24 May 2025 19:51:08 +0100
Subject: [PATCH] Add completer; remove notify

---
 repl/command.go                          | 52 ++----------------------
 repl/folders.go                          |  3 --
 repl/set.go                              | 22 ----------
 repl/show.go                             |  7 ----
 storage/display.go                       |  3 +-
 storage/folders.sql.go                   | 26 ++----------
 storage/migrations/1_create_table.up.sql |  1 -
 storage/models.go                        |  1 -
 storage/queries/folders.sql              |  7 +---
 storage/standard.sql.go                  |  6 +--
 10 files changed, 12 insertions(+), 116 deletions(-)

diff --git a/repl/command.go b/repl/command.go
index 3740e46..ecfff20 100644
--- a/repl/command.go
+++ b/repl/command.go
@@ -270,11 +270,6 @@ BULLCOM.CLD.`,
 				OptArg:  true,
 				Default: "14",
 			},
-			"/NOTIFY": {
-				Description: `  Specifies  that  all users  automatically  have  NOTIFY set  for  this
-  folder. Only a  privileged user can use this qualifier.  (See HELP SET
-  NOTIFY for more information.)`,
-			},
 			"/OWNER": {
 				Description: `/OWNER=username
 
@@ -1136,9 +1131,8 @@ The following options are available:
 
   ACCESS           ALWAYS           BRIEF            DEFAULT_EXPIRE
   EXPIRE_LIMIT     FOLDER           NOALWAYS         NOBRIEF
-  NONOTIFY         NOPROMPT_EXPIRE  NOREADNEW        NOSHOWNEW
-  NOSYSTEM         NOTIFY           PROMPT_EXPIRE    READNEW
-  SHOWNEW          SYSTEM
+  NOPROMPT_EXPIRE  NOREADNEW        NOSHOWNEW        NOSYSTEM
+  PROMPT_EXPIRE    READNEW          SHOWNEW          SYSTEM
 `,
 		Action: ActionSet,
 		Commands: dclish.Commands{
@@ -1318,46 +1312,6 @@ on that command for more information.
 					},
 				},
 			},
-			"NOTIFY": {
-				Description: `Specifies whether you will be notified via a broadcast  message  when  a
-message is added to the selected folder.
-
-  Format:
-    SET NOTIFY
-
-In a cluster, if the logical name MAIL$SYSTEM_FLAGS is defined so that
-bit 1 is set, users will be notified no matter which node they are logged
-in to.  If you wish to disable this, you should define BULL_SYSTEM_FLAGS
-so that bit 1 is cleared.`,
-				Action: ActionSetNotify,
-				Flags: dclish.Flags{
-					"/ALL": {
-						Description: `  Specifies that the SET NOTIFY option  is the default for all users for
-  the specified folder. This is a privileged qualifier.`,
-					},
-					"/DEFAULT": {
-						Description: `  Specifies  that the  NOTIFY option  is the  default for  the specified
-  folder. This is a privileged qualifier.  It will only affect brand new
-  users (or  those that have  never logged in).  Use /ALL to  modify all
-  users.`,
-					},
-					"/PERMANENT": {
-						Description: `/[NO]PERMANENT
-
-  Specifies that  NOTIFY is a  permanent flag  and cannot be  changed by
-  the  individual. /DEFAULT  must  be specified.  This  is a  privileged
-  qualifier.`,
-					},
-				},
-			},
-			"NONOTIFY": {
-				Description: `Removes notification from the current folder or optional folder-name.
-
-  Format:
-    SET NONOTIFY [folder-name]`,
-				Action:  ActionSetNonotify,
-				MaxArgs: 1,
-			},
 			"PROMPT_EXPIRE": {
 				Description: `Specifies  that a  user will  be prompted  for an  expiration date  when
 adding a message. If the value  specified is greater than the expiration
@@ -1528,7 +1482,7 @@ The following options are available:
 		Action: ActionShow,
 		Commands: dclish.Commands{
 			"FLAGS": {
-				Description: `Shows whether BRIEF, NOTIFY, READNEW, or SHOWNEW has been set for the
+				Description: `Shows whether BRIEF, READNEW, or SHOWNEW has been set for the
 currently selected folder.
 `,
 				Action: ActionShowFlags,
diff --git a/repl/folders.go b/repl/folders.go
index 5b0631b..4e5fe8d 100644
--- a/repl/folders.go
+++ b/repl/folders.go
@@ -62,9 +62,6 @@ func ActionCreate(cmd *dclish.Command) error {
 	if cmd.Flags["/DESCRIPTION"].Value != "" {
 		options.Description = cmd.Flags["/DESCRIPTION"].Value
 	}
-	if cmd.Flags["/NOTIFY"].Value == "true" {
-		options.Notify = 1
-	}
 	if cmd.Flags["/READNEW"].Value == "true" {
 		options.Alert = 2
 	}
diff --git a/repl/set.go b/repl/set.go
index 5222acb..dc09468 100644
--- a/repl/set.go
+++ b/repl/set.go
@@ -122,28 +122,6 @@ func ActionSetExpireLimit(cmd *dclish.Command) error {
 	return this.Q.UpdateExpireLimit(ctx, value)
 }
 
-// ActionSetNotify handles the `SET NOTIFY` command.
-func ActionSetNotify(_ *dclish.Command) error {
-	// TODO: parse flags and args.
-	ctx := storage.Context()
-	this.Q.UpdateFolderNotify(ctx, storage.UpdateFolderNotifyParams{
-		Notify: 1,
-		Name:   this.Folder.Name,
-	})
-	return nil
-}
-
-// ActionSetNonotify handles the `SET NONOTIFY` command.
-func ActionSetNonotify(_ *dclish.Command) error {
-	// TODO: parse flags and args.
-	ctx := storage.Context()
-	this.Q.UpdateFolderNotify(ctx, storage.UpdateFolderNotifyParams{
-		Notify: 0,
-		Name:   this.Folder.Name,
-	})
-	return nil
-}
-
 // ActionSetPromptExpire handles the `SET PROMPT_EXPIRE` command.
 func ActionSetPromptExpire(_ *dclish.Command) error {
 	ctx := storage.Context()
diff --git a/repl/show.go b/repl/show.go
index 00de916..d4a6b00 100644
--- a/repl/show.go
+++ b/repl/show.go
@@ -24,10 +24,6 @@ func ActionShow(cmd *dclish.Command) error {
 func ActionShowFlags(_ *dclish.Command) error {
 	flagset := false
 	fmt.Printf("For the selected folder %s:\n", this.Folder.Name)
-	if this.Folder.Notify != 0 {
-		fmt.Println("  NOTIFY is set.")
-		flagset = true
-	}
 	if this.Folder.Alert != 0 {
 		fmt.Printf("  %s is set.\n",
 			strings.ToUpper(storage.AlertString(this.Folder.Alert)))
@@ -83,9 +79,6 @@ func ActionShowFolder(cmd *dclish.Command) error {
 	if folder.Always != 0 {
 		fmt.Println("  ALWAYS has been set.")
 	}
-	if this.Folder.Notify != 0 {
-		fmt.Println("  Default is NOTIFY.")
-	}
 	if this.Folder.Alert != 0 {
 		fmt.Printf("  %s is set.\n",
 			strings.ToUpper(storage.AlertString(this.Folder.Alert)))
diff --git a/storage/display.go b/storage/display.go
index 680e034..a1edaec 100644
--- a/storage/display.go
+++ b/storage/display.go
@@ -116,12 +116,11 @@ func (u User) String() string {
 
 // String displays a folder (mainly used for debugging).
 func (f Folder) String() string {
-	return fmt.Sprintf("Folder %s (%s) [a%d, !<%s>, n%d, sys%d, exp%d, v%d]",
+	return fmt.Sprintf("Folder %s (%s) [a%d, !<%s>, sys%d, exp%d, v%d]",
 		f.Name,
 		f.Description,
 		f.Always,
 		FolderAlertString(f.Alert),
-		f.Notify,
 		f.System,
 		f.Expire,
 		f.Visibility)
diff --git a/storage/folders.sql.go b/storage/folders.sql.go
index 374acf4..98722da 100644
--- a/storage/folders.sql.go
+++ b/storage/folders.sql.go
@@ -11,9 +11,9 @@ import (
 
 const createFolder = `-- name: CreateFolder :exec
 INSERT INTO folders
-    (name, always, alert, description, owner, notify, system, expire, visibility)
+    (name, always, alert, description, owner, system, expire, visibility)
   VALUES
-    (?, ?, ?, ?, ?, ?, ?, ?, ?)
+    (?, ?, ?, ?, ?, ?, ?, ?)
 `
 
 type CreateFolderParams struct {
@@ -22,7 +22,6 @@ type CreateFolderParams struct {
 	Alert       int64
 	Description string
 	Owner       string
-	Notify      int64
 	System      int64
 	Expire      int64
 	Visibility  int64
@@ -35,7 +34,6 @@ func (q *Queries) CreateFolder(ctx context.Context, arg CreateFolderParams) erro
 		arg.Alert,
 		arg.Description,
 		arg.Owner,
-		arg.Notify,
 		arg.System,
 		arg.Expire,
 		arg.Visibility,
@@ -44,7 +42,7 @@ func (q *Queries) CreateFolder(ctx context.Context, arg CreateFolderParams) erro
 }
 
 const findFolderExact = `-- name: FindFolderExact :one
-SELECT name, "always", alert, description, owner, notify, system, expire, visibility, create_at, update_at FROM folders where name = ?
+SELECT name, "always", alert, description, owner, system, expire, visibility, create_at, update_at FROM folders where name = ?
 `
 
 func (q *Queries) FindFolderExact(ctx context.Context, name string) (Folder, error) {
@@ -56,7 +54,6 @@ func (q *Queries) FindFolderExact(ctx context.Context, name string) (Folder, err
 		&i.Alert,
 		&i.Description,
 		&i.Owner,
-		&i.Notify,
 		&i.System,
 		&i.Expire,
 		&i.Visibility,
@@ -67,7 +64,7 @@ func (q *Queries) FindFolderExact(ctx context.Context, name string) (Folder, err
 }
 
 const findFolderPrefix = `-- name: FindFolderPrefix :one
-SELECT name, "always", alert, description, owner, notify, system, expire, visibility, create_at, update_at FROM folders where name LIKE ?
+SELECT name, "always", alert, description, owner, system, expire, visibility, create_at, update_at FROM folders where name LIKE ?
 ORDER BY name
 LIMIT 1
 `
@@ -81,7 +78,6 @@ func (q *Queries) FindFolderPrefix(ctx context.Context, name string) (Folder, er
 		&i.Alert,
 		&i.Description,
 		&i.Owner,
-		&i.Notify,
 		&i.System,
 		&i.Expire,
 		&i.Visibility,
@@ -285,20 +281,6 @@ func (q *Queries) UpdateFolderMain(ctx context.Context, arg UpdateFolderMainPara
 	return err
 }
 
-const updateFolderNotify = `-- name: UpdateFolderNotify :exec
-UPDATE folders SET notify = ? WHERE name = ?
-`
-
-type UpdateFolderNotifyParams struct {
-	Notify int64
-	Name   string
-}
-
-func (q *Queries) UpdateFolderNotify(ctx context.Context, arg UpdateFolderNotifyParams) error {
-	_, err := q.db.ExecContext(ctx, updateFolderNotify, arg.Notify, arg.Name)
-	return err
-}
-
 const updateFolderSystem = `-- name: UpdateFolderSystem :exec
 UPDATE folders SET system = ? WHERE name = ?
 `
diff --git a/storage/migrations/1_create_table.up.sql b/storage/migrations/1_create_table.up.sql
index df9ce8e..e81b148 100644
--- a/storage/migrations/1_create_table.up.sql
+++ b/storage/migrations/1_create_table.up.sql
@@ -40,7 +40,6 @@ CREATE TABLE folders (
   alert       INT          DEFAULT 1 NOT NULL,
   description VARCHAR(53)  DEFAULT 0 NOT NULL,
   owner       VARCHAR(12)  NOT NULL,
-  notify      INT          DEFAULT 0 NOT NULL,
   system      INT          DEFAULT 0 NOT NULL,
   expire      INT          DEFAULT 14 NOT NULL,
   --- public=0, semiprivate=1, private=2
diff --git a/storage/models.go b/storage/models.go
index 3efeab4..fd2c0cd 100644
--- a/storage/models.go
+++ b/storage/models.go
@@ -21,7 +21,6 @@ type Folder struct {
 	Alert       int64
 	Description string
 	Owner       string
-	Notify      int64
 	System      int64
 	Expire      int64
 	Visibility  int64
diff --git a/storage/queries/folders.sql b/storage/queries/folders.sql
index 881979d..7f965c5 100644
--- a/storage/queries/folders.sql
+++ b/storage/queries/folders.sql
@@ -1,8 +1,8 @@
 -- name: CreateFolder :exec
 INSERT INTO folders
-    (name, always, alert, description, owner, notify, system, expire, visibility)
+    (name, always, alert, description, owner, system, expire, visibility)
   VALUES
-    (?, ?, ?, ?, ?, ?, ?, ?, ?);
+    (?, ?, ?, ?, ?, ?, ?, ?);
 
 -- name: ListFolderForAdmin :many
 SELECT f.name, count(m.id) as count, f.description
@@ -45,9 +45,6 @@ UPDATE folders SET system = ? WHERE name = ?;
 -- name: UpdateFolderAlert :exec
 UPDATE folders SET alert = ? WHERE name = ?;
 
--- name: UpdateFolderNotify :exec
-UPDATE folders SET notify = ? WHERE name = ?;
-
 -- name: UpdateFolderVisibility :exec
 UPDATE folders SET visibility = ? WHERE name = ?;
 
diff --git a/storage/standard.sql.go b/storage/standard.sql.go
index 56080b8..47ad5d4 100644
--- a/storage/standard.sql.go
+++ b/storage/standard.sql.go
@@ -181,7 +181,7 @@ func (q *Queries) DeleteUser(ctx context.Context, login string) error {
 }
 
 const getFolder = `-- name: GetFolder :one
-SELECT name, "always", alert, description, owner, notify, system, expire, visibility, create_at, update_at FROM folders WHERE name = ?
+SELECT name, "always", alert, description, owner, system, expire, visibility, create_at, update_at FROM folders WHERE name = ?
 `
 
 func (q *Queries) GetFolder(ctx context.Context, name string) (Folder, error) {
@@ -193,7 +193,6 @@ func (q *Queries) GetFolder(ctx context.Context, name string) (Folder, error) {
 		&i.Alert,
 		&i.Description,
 		&i.Owner,
-		&i.Notify,
 		&i.System,
 		&i.Expire,
 		&i.Visibility,
@@ -378,7 +377,7 @@ func (q *Queries) ListFolderConfig(ctx context.Context) ([]FolderConfig, error)
 }
 
 const listFolders = `-- name: ListFolders :many
-SELECT name, "always", alert, description, owner, notify, system, expire, visibility, create_at, update_at FROM folders
+SELECT name, "always", alert, description, owner, system, expire, visibility, create_at, update_at FROM folders
 `
 
 func (q *Queries) ListFolders(ctx context.Context) ([]Folder, error) {
@@ -396,7 +395,6 @@ func (q *Queries) ListFolders(ctx context.Context) ([]Folder, error) {
 			&i.Alert,
 			&i.Description,
 			&i.Owner,
-			&i.Notify,
 			&i.System,
 			&i.Expire,
 			&i.Visibility,
-- 
GitLab