refactor(graph): use BaseGraphService.publicBaseURL consistently#2770
refactor(graph): use BaseGraphService.publicBaseURL consistently#2770dschmidt wants to merge 1 commit into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | -2 |
🟢 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 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.
733b13e to
6194af0
Compare
There was a problem hiding this comment.
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.webURLForResourcehelper to build/f/<resource-id>URLs frompublicBaseURL. - Inlined usage of
g.publicBaseURLfor/s/<token>public share link URLs. - Converted
cs3ResourceToDriveItemandformatDriveItemsintoBaseGraphServicemethods 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.
6194af0 to
5d5a1fd
Compare
Summary
Follow-up to #2744.
drive.WebUrl,driveItem.WebUrland the public sharelink WebUrl all derive from the same config value
(
graph.spaces.webdav_base), but onlydriveItem.WebUrlwas using thepre-parsed
BaseGraphService.publicBaseURLintroduced in #2744. The othertwo re-parsed the config on every call.
BaseGraphService.webURLForResourcefor the/f/<id>URLs (usedby both
drive.WebUrlanddriveItem.WebUrl)g.publicBaseURLfor the single/s/<token>public share linkcase in
libreGraphPermissionFromCS3PublicSharecs3ResourceToDriveItemandformatDriveItemsfrom freefunctions into
BaseGraphServicemethods so they pick uploggerandpublicBaseURLfrom the receiver instead of being threaded through 7call sites. This also aligns them with the surrounding code:
BaseGraphServicealready exposes ~15 similar methods, so the two freefunctions 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/...cleango test ./services/graph/pkg/service/v0/...passes (incl. existingTestCS3ResourceToDriveItemPopulatesWebUrl)