Skip to content

Commit

Permalink
encode ids with base32
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Dec 1, 2023
1 parent 1a5af73 commit 7d97c00
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions internal/http/services/owncloud/ocgraph/drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package ocgraph

import (
"context"
"encoding/base64"
"encoding/base32"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -148,8 +148,8 @@ func getDrivesForShares(ctx context.Context, gw gateway.GatewayAPIClient) ([]*li
// TODO (gdelmont): filter out the rejected shares

// the prefix of the remote_item.id and rootid
idPrefix := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("#s%s", stat.Info.Path)))
resourceIdEnc := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s!%s", stat.Info.Id.StorageId, stat.Info.Id.OpaqueId)))
idPrefix := base32.StdEncoding.EncodeToString([]byte(fmt.Sprintf("#s%s", stat.Info.Path)))
resourceIdEnc := base32.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s!%s", stat.Info.Id.StorageId, stat.Info.Id.OpaqueId)))

space := &libregraph.Drive{
Id: libregraph.PtrString(fmt.Sprintf("%s$%s!%s", shareJailID, shareJailID, share.Id.OpaqueId)),
Expand Down Expand Up @@ -212,24 +212,6 @@ func (s *svc) cs3StorageSpaceToDrive(user *userpb.User, space *providerpb.Storag
},
}

// for the mountpoint type the space_id used by the web to build the webdav request
// is taken from `root.remoteItem.id`
if space.SpaceType == "mountpoint" {
r := space.RootInfo
id := base64.StdEncoding.EncodeToString([]byte(space.RootInfo.Path))
drive.Root.RemoteItem = &libregraph.RemoteItem{
DriveAlias: libregraph.PtrString(space.RootInfo.Path[1:]),
ETag: libregraph.PtrString(r.Etag),
Id: libregraph.PtrString(id),
Folder: &libregraph.Folder{},
LastModifiedDateTime: libregraph.PtrTime(time.Unix(int64(r.Mtime.Seconds), int64(r.Mtime.Nanos))),
Name: libregraph.PtrString(space.Name),
Path: libregraph.PtrString("/"),
RootId: libregraph.PtrString(id),
Size: libregraph.PtrInt64(int64(r.Size)),
}
}

drive.Root.WebDavUrl = libregraph.PtrString(fullUrl(s.c.WebDavBase, space.RootInfo.Path))
drive.WebUrl = libregraph.PtrString(fullUrl(s.c.WebBase, space.RootInfo.Path))

Expand Down

0 comments on commit 7d97c00

Please sign in to comment.