Skip to content

refactor(graph): use BaseGraphService.publicBaseURL consistently#2770

Open
dschmidt wants to merge 1 commit into
opencloud-eu:mainfrom
dschmidt:refactor/share-public-base-url-for-drive-weburl
Open

refactor(graph): use BaseGraphService.publicBaseURL consistently#2770
dschmidt wants to merge 1 commit into
opencloud-eu:mainfrom
dschmidt:refactor/share-public-base-url-for-drive-weburl

Conversation

@dschmidt
Copy link
Copy Markdown
Contributor

@dschmidt dschmidt commented May 15, 2026

Summary

Follow-up to #2744. drive.WebUrl, driveItem.WebUrl and the public share
link WebUrl all derive from the same config value
(graph.spaces.webdav_base), but only driveItem.WebUrl was using the
pre-parsed BaseGraphService.publicBaseURL introduced in #2744. The other
two re-parsed the config on every call.

  • Adds BaseGraphService.webURLForResource for the /f/<id> URLs (used
    by both drive.WebUrl and driveItem.WebUrl)
  • Inlines g.publicBaseURL for the single /s/<token> public share link
    case in libreGraphPermissionFromCS3PublicShare
  • Converts cs3ResourceToDriveItem and formatDriveItems from free
    functions into BaseGraphService methods so they pick up logger and
    publicBaseURL from the receiver instead of being threaded through 7
    call sites. This also aligns them with the surrounding code:
    BaseGraphService already exposes ~15 similar methods, so the two free
    functions were the odd ones out.

Pure refactor: all three WebUrls are constructed from the same source as
before, no behavior change.

Test plan

  • go build ./services/graph/... clean
  • go test ./services/graph/pkg/service/v0/... passes (incl. existing
    TestCS3ResourceToDriveItemPopulatesWebUrl)
  • CI green

@dschmidt dschmidt marked this pull request as draft May 15, 2026 12:19
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 15, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · -2 duplication

Metric Results
Complexity 0
Duplication -2

View in Codacy

🟢 Coverage 91.30% diff coverage · +0.00% coverage variation

Metric Results
Coverage variation +0.00% coverage variation (-1.00%)
Diff coverage 91.30% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (55dbd40) 81402 18667 22.93%
Head commit (5d5a1fd) 81388 (-14) 18665 (-2) 22.93% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#2770) 23 21 91.30%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@dschmidt dschmidt force-pushed the refactor/share-public-base-url-for-drive-weburl branch 2 times, most recently from 733b13e to 6194af0 Compare May 15, 2026 12:48
@dschmidt dschmidt changed the title refactor(graph): reuse publicBaseURL for drive WebUrl refactor(graph): use BaseGraphService.publicBaseURL consistently May 15, 2026
@dschmidt dschmidt marked this pull request as ready for review May 15, 2026 12:55
@dschmidt dschmidt requested review from Copilot and micbar May 15, 2026 12:56
@dschmidt dschmidt added the Type:Maintenance E.g. technical debt, packaging, etc. label May 15, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors Graph service URL construction so drive.WebUrl, driveItem.WebUrl, and public share link webUrl all consistently derive from the pre-parsed BaseGraphService.publicBaseURL (parsed once from graph.spaces.webdav_base), avoiding repeated parsing and reducing parameter threading.

Changes:

  • Added BaseGraphService.webURLForResource helper to build /f/<resource-id> URLs from publicBaseURL.
  • Inlined usage of g.publicBaseURL for /s/<token> public share link URLs.
  • Converted cs3ResourceToDriveItem and formatDriveItems into BaseGraphService methods and updated call sites + tests accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
services/graph/pkg/service/v0/follow.go Uses receiver method cs3ResourceToDriveItem instead of passing logger/base URL.
services/graph/pkg/service/v0/drives.go Sets drive.WebUrl via webURLForResource (no per-call URL parse).
services/graph/pkg/service/v0/driveitems.go Moves drive item formatting/building to BaseGraphService methods and uses webURLForResource for DriveItem.WebUrl.
services/graph/pkg/service/v0/driveitems_weburl_test.go Updates tests to call the new receiver method and keeps existing URL expectations.
services/graph/pkg/service/v0/base.go Adds webURLForResource, switches getDriveItem and public share link URL generation to use publicBaseURL.
services/graph/pkg/service/v0/api_driveitem_permissions.go Updates permissions service to use receiver method cs3ResourceToDriveItem.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

drive.WebUrl, driveItem.WebUrl and the public share link WebUrl all
derive from the same config value (graph.spaces.webdav_base), but only
driveItem.WebUrl used the pre-parsed BaseGraphService.publicBaseURL.
The other two re-parsed the config on every call.

Add a webURLForResource method on BaseGraphService for the /f/<id> URLs
(used twice, with a *string return matching the libregraph DriveItem
field shape), and inline g.publicBaseURL for the single /s/<token>
share-link case. Convert cs3ResourceToDriveItem and formatDriveItems
from free functions into BaseGraphService methods so they pick up
logger and publicBaseURL from the receiver. This also aligns them with
the surrounding code: BaseGraphService already exposes ~15 similar
methods, so the two free functions were the odd ones out.

Net: all three WebUrls are now constructed from a single pre-parsed
URL, and the (g.logger, g.publicBaseURL) plumbing at 7 call sites
disappears.
@dschmidt dschmidt force-pushed the refactor/share-public-base-url-for-drive-weburl branch from 6194af0 to 5d5a1fd Compare May 15, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type:Maintenance E.g. technical debt, packaging, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants