Skip to content

Commit

Permalink
use owncloud namespace for lock details
Browse files Browse the repository at this point in the history
Co-authored-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj and butonic committed Aug 28, 2023
1 parent cd206e6 commit a80cc3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions internal/http/services/owncloud/ocdav/locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (cls *cs3LS) Create(ctx context.Context, now time.Time, details LockDetails
u := ctxpkg.ContextMustGetUser(ctx)

// add metadata via opaque
// TODO: upate cs3api: https://github.com/cs3org/cs3apis/issues/213
o := utils.AppendPlainToOpaque(nil, "lockownername", u.GetDisplayName())
o = utils.AppendPlainToOpaque(o, "locktime", now.Format(time.RFC3339))

Expand Down Expand Up @@ -560,7 +561,7 @@ func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) {

lockdiscovery := strings.Builder{}
lockdiscovery.WriteString(xml.Header)
lockdiscovery.WriteString("<d:prop xmlns:d=\"DAV:\"><d:lockdiscovery><d:activelock>\n")
lockdiscovery.WriteString("<d:prop xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\"><d:lockdiscovery><d:activelock>\n")
lockdiscovery.WriteString(" <d:locktype><d:write/></d:locktype>\n")
lockdiscovery.WriteString(" <d:lockscope><d:exclusive/></d:lockscope>\n")
lockdiscovery.WriteString(fmt.Sprintf(" <d:depth>%s</d:depth>\n", depth))
Expand All @@ -580,10 +581,10 @@ func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) {
lockdiscovery.WriteString(fmt.Sprintf(" <d:lockroot><d:href>%s</d:href></d:lockroot>\n", prop.Escape(href)))
}
if ld.OwnerName != "" {
lockdiscovery.WriteString(fmt.Sprintf(" <d:ownername>%s</d:ownername>\n", prop.Escape(ld.OwnerName)))
lockdiscovery.WriteString(fmt.Sprintf(" <oc:ownername>%s</oc:ownername>\n", prop.Escape(ld.OwnerName)))
}
if !ld.Locktime.IsZero() {
lockdiscovery.WriteString(fmt.Sprintf(" <d:locktime>%s</d:locktime>\n", prop.Escape(ld.Locktime.Format(time.RFC3339))))
lockdiscovery.WriteString(fmt.Sprintf(" <oc:locktime>%s</oc:locktime>\n", prop.Escape(ld.Locktime.Format(time.RFC3339))))
}

lockdiscovery.WriteString("</d:activelock></d:lockdiscovery></d:prop>")
Expand Down
8 changes: 4 additions & 4 deletions internal/http/services/owncloud/ocdav/propfind/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -1637,14 +1637,14 @@ func activeLocks(log *zerolog.Logger, lock *provider.Lock) string {
}

if un := utils.ReadPlainFromOpaque(lock.Opaque, "lockownername"); un != "" {
activelocks.WriteString("<d:ownername>")
activelocks.WriteString("<oc:ownername>")
activelocks.WriteString(un)
activelocks.WriteString("</d:ownername>")
activelocks.WriteString("</oc:ownername>")
}
if lt := utils.ReadPlainFromOpaque(lock.Opaque, "locktime"); lt != "" {
activelocks.WriteString("<d:locktime>")
activelocks.WriteString("<oc:locktime>")
activelocks.WriteString(lt)
activelocks.WriteString("</d:locktime>")
activelocks.WriteString("</oc:locktime>")
}
activelocks.WriteString("<d:timeout>")
activelocks.WriteString(expiration)
Expand Down

0 comments on commit a80cc3e

Please sign in to comment.