Skip to content

Commit

Permalink
added the watermark text for the Secure View mode
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 committed May 13, 2024
1 parent f74dfaa commit dfd2941
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/enhancement-add-watermark-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Add watermark text

We've added the watermark text for the Secure View mode.

https://github.com/owncloud/ocis/pull/9144
18 changes: 18 additions & 0 deletions services/collaboration/pkg/connector/fileconnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"path"
"strconv"
"strings"
"time"

appproviderv1beta1 "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1"
Expand Down Expand Up @@ -533,6 +534,7 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (FileInfo, error) {
fileInfo.DisableExport = true
fileInfo.DisableCopy = true
fileInfo.DisablePrint = true
fileInfo.WatermarkText = f.ensureWatermarkText(wopiContext.User)
}

// user logic from reva wopi driver #TODO: refactor
Expand Down Expand Up @@ -565,3 +567,19 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (FileInfo, error) {
logger.Debug().Msg("CheckFileInfo: success")
return fileInfo, nil
}

func (f *FileConnector) ensureWatermarkText(user *userv1beta1.User) (watermarkText string) {
if f.cfg.Commons != nil {
watermarkText = f.cfg.Commons.OcisURL
}
if user != nil {
text := user.GetUsername() + " " + user.GetMail()
if strings.TrimSpace(text) != "" {
watermarkText = strings.TrimSpace(text)
}
}
if watermarkText == "" {
watermarkText = "Watermark"
}
return
}
3 changes: 3 additions & 0 deletions services/collaboration/pkg/connector/fileconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
cs3mocks "github.com/cs3org/reva/v2/tests/cs3mocks/mocks"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
"github.com/owncloud/ocis/v2/services/collaboration/pkg/config"
"github.com/owncloud/ocis/v2/services/collaboration/pkg/connector"
"github.com/owncloud/ocis/v2/services/collaboration/pkg/middleware"
Expand All @@ -32,6 +33,7 @@ var _ = Describe("FileConnector", func() {
App: config.App{
LockName: "testName_for_unittests", // Only the LockName is used
},
Commons: &shared.Commons{OcisURL: "https://ocis.com"},
}
gatewayClient = &cs3mocks.GatewayAPIClient{}
fc = connector.NewFileConnector(gatewayClient, cfg)
Expand Down Expand Up @@ -856,6 +858,7 @@ var _ = Describe("FileConnector", func() {
IsAnonymousUser: true,
UserId: "guest-zzz000",
UserFriendlyName: "guest zzz000",
WatermarkText: "Pet Shaft",
}

newFileInfo, err := fc.CheckFileInfo(ctx)
Expand Down

0 comments on commit dfd2941

Please sign in to comment.