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 ee1eccb commit 57d4224
Show file tree
Hide file tree
Showing 2 changed files with 19 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
14 changes: 14 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(ctx, statRes.GetInfo().GetOwner())
}

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

func (f *FileConnector) ensureWatermarkText(ctx context.Context, info *userv1beta1.UserId) (watermarkText string) {
watermarkText = f.cfg.Commons.OcisURL
u, err := f.gwc.GetUser(ctx, &userv1beta1.GetUserRequest{UserId: info, SkipFetchingUserGroups: true})
if err == nil && u.Status.Code == rpcv1beta1.Code_CODE_OK {
text := u.GetUser().GetDisplayName() + " " + u.GetUser().GetMail()
if strings.TrimSpace(watermarkText) != "" {
watermarkText = text
}
}
return
}

0 comments on commit 57d4224

Please sign in to comment.