diff --git a/common/common.go b/common/common.go index e79d7118..d0d64a31 100644 --- a/common/common.go +++ b/common/common.go @@ -73,12 +73,13 @@ const ( // Supported protocols const ( - ProtocolSFTP = "SFTP" - ProtocolSCP = "SCP" - ProtocolSSH = "SSH" - ProtocolFTP = "FTP" - ProtocolWebDAV = "DAV" - ProtocolHTTP = "HTTP" + ProtocolSFTP = "SFTP" + ProtocolSCP = "SCP" + ProtocolSSH = "SSH" + ProtocolFTP = "FTP" + ProtocolWebDAV = "DAV" + ProtocolHTTP = "HTTP" + ProtocolDataRetention = "DataRetention" ) // Upload modes diff --git a/common/dataretention.go b/common/dataretention.go index b44c1b70..80450667 100644 --- a/common/dataretention.go +++ b/common/dataretention.go @@ -69,7 +69,8 @@ func (c *ActiveRetentionChecks) Add(check RetentionCheck, user *dataprovider.Use // we silently ignore file patterns user.Filters.FilePatterns = nil conn := NewBaseConnection("", "", "", "", *user) - conn.ID = fmt.Sprintf("retention_check_%v", user.Username) + conn.SetProtocol(ProtocolDataRetention) + conn.ID = fmt.Sprintf("data_retention_%v", user.Username) check.Username = user.Username check.StartTime = util.GetTimeAsMsSinceEpoch(time.Now()) check.conn = conn diff --git a/common/dataretention_test.go b/common/dataretention_test.go index b5b4f277..94047e39 100644 --- a/common/dataretention_test.go +++ b/common/dataretention_test.go @@ -124,7 +124,8 @@ func TestEmailNotifications(t *testing.T) { }, } conn := NewBaseConnection("", "", "", "", user) - conn.ID = fmt.Sprintf("retention_check_%v", user.Username) + conn.SetProtocol(ProtocolDataRetention) + conn.ID = fmt.Sprintf("data_retention_%v", user.Username) check.conn = conn err = check.sendNotification(time.Now(), nil) assert.NoError(t, err) @@ -177,7 +178,8 @@ func TestRetentionPermissionsAndGetFolder(t *testing.T) { } conn := NewBaseConnection("", "", "", "", user) - conn.ID = fmt.Sprintf("retention_check_%v", user.Username) + conn.SetProtocol(ProtocolDataRetention) + conn.ID = fmt.Sprintf("data_retention_%v", user.Username) check.conn = conn check.updateUserPermissions() assert.Equal(t, []string{dataprovider.PermListItems, dataprovider.PermDelete}, conn.User.Permissions["/"]) diff --git a/docs/custom-actions.md b/docs/custom-actions.md index a1421787..34c6fe0f 100644 --- a/docs/custom-actions.md +++ b/docs/custom-actions.md @@ -45,7 +45,7 @@ The external program can also read the following environment variables: - `SFTPGO_ACTION_BUCKET`, non-empty for S3, GCS and Azure backends - `SFTPGO_ACTION_ENDPOINT`, non-empty for S3, SFTP and Azure backend if configured. For Azure this is the endpoint, if configured - `SFTPGO_ACTION_STATUS`, integer. Status for `upload`, `download` and `ssh_cmd` actions. 0 means a generic error occurred. 1 means no error, 2 means quota exceeded error -- `SFTPGO_ACTION_PROTOCOL`, string. Possible values are `SSH`, `SFTP`, `SCP`, `FTP`, `DAV`, `HTTP` +- `SFTPGO_ACTION_PROTOCOL`, string. Possible values are `SSH`, `SFTP`, `SCP`, `FTP`, `DAV`, `HTTP`, `DataRetention` - `SFTPGO_ACTION_OPEN_FLAGS`, integer. File open flags, can be non-zero for `pre-upload` action. If `SFTPGO_ACTION_FILE_SIZE` is greater than zero and `SFTPGO_ACTION_OPEN_FLAGS&512 == 0` the target file will not be truncated Previous global environment variables aren't cleared when the script is called. @@ -63,7 +63,7 @@ If the `hook` defines an HTTP URL then this URL will be invoked as HTTP POST. Th - `bucket`, inlcuded for S3, GCS and Azure backends - `endpoint`, included for S3, SFTP and Azure backend if configured. For Azure this is the endpoint, if configured - `status`, integer. Status for `upload`, `download` and `ssh_cmd` actions. 0 means a generic error occurred. 1 means no error, 2 means quota exceeded error -- `protocol`, string. Possible values are `SSH`, `SFTP`, `SCP`, `FTP`, `DAV`, `HTTP` +- `protocol`, string. Possible values are `SSH`, `SFTP`, `SCP`, `FTP`, `DAV`, `HTTP`, `DataRetention` - `open_flags`, integer. File open flags, can be non-zero for `pre-upload` action. If `file_size` is greater than zero and `file_size&512 == 0` the target file will not be truncated The HTTP hook will use the global configuration for HTTP clients and will respect the retry configurations. @@ -101,4 +101,4 @@ The structure for SFTPGo users can be found within the [OpenAPI schema](../httpd ## Pub/Sub services -You can forward SFTPGo events to serveral publish/subscribe systems using the [sftpgo-plugin-pubsub](https://github.com/sftpgo/sftpgo-plugin-pubsub). The notifiers SFTPGo plugins are not suitable for interactive actions such as `pre-*` events. Their scope is to simply forward events to external services. A custom hook is a better choice if you need to react to `pre-*` events. +You can forward SFTPGo events to several publish/subscribe systems using the [sftpgo-plugin-pubsub](https://github.com/sftpgo/sftpgo-plugin-pubsub). The notifiers SFTPGo plugins are not suitable for interactive actions such as `pre-*` events. Their scope is to simply forward events to external services. A custom hook is a better choice if you need to react to `pre-*` events. diff --git a/docs/logs.md b/docs/logs.md index 4e08b302..f714fc9d 100644 --- a/docs/logs.md +++ b/docs/logs.md @@ -20,7 +20,7 @@ The logs can be divided into the following categories: - `username`, string - `file_path` string - `connection_id` string. Unique connection identifier - - `protocol` string. `SFTP`, `SCP`, `SSH`, `FTP`, `HTTP`, `DAV` + - `protocol` string. `SFTP`, `SCP`, `SSH`, `FTP`, `HTTP`, `DAV`, `DataRetention` - `ftp_mode`, string. `active` or `passive`. Included only for `FTP` protocol - **"command logs"**, SFTP/SCP command logs: - `sender` string. `Rename`, `Rmdir`, `Mkdir`, `Symlink`, `Remove`, `Chmod`, `Chown`, `Chtimes`, `Truncate`, `SSHCommand`