Repository navigation
feat(drivers/onedrive_app): support mounting SharePoint site document library - #3252
AkashiCoin wants to merge 3 commits into
Conversation
- 新增 `is_sharepoint` 与 `site_id` 两个配置项,开启后走 `/sites/{siteId}/drive` 而不是 `/users/{email}/drive`
- 新增 `NormalizeSiteID`,接受 `siteId,siteGuid,webGuid`、`host:/sites/name`、站点 URL 和站点集合根 URL 四种写法
- 路径形式的 site 标识在 `Init` 阶段解析成 Graph 的逗号形式并回写存储,因为 `/sites/{path}:/` 后面不能继续拼 `/drive`
- `Init` 对 SharePoint 模式校验 `site_id`,非 SharePoint 模式校验 `email` 非空
- 配额查询 `getDrive` 同步区分两种模式
- 补充 `NormalizeSiteID` 与 URL 拼接的单元测试
Co-authored-by: Claude <81847+claude@users.noreply.github.com>
- 说明裸域名会解析成站点集合根站点,其默认文档库通常为空 - 补充完整站点 URL 也会被解析成 ID 形式 - 合并为两句话,缩短表单提示气泡长度 Co-authored-by: Claude <81847+claude@users.noreply.github.com>
|
[P2] SharePoint 根站点 URL 会被规范化成错误的标识。NormalizeSiteID("https://contoso.sharepoint.com") 返回 "contoso.sharepoint.com:",随后请求 /sites/contoso.sharepoint.com:。Graph 的主机名寻址形式是 /sites/contoso.sharepoint.com,冒号形式用于带路径的站点。要单独处理空路径和根路径,只有存在站点子路径时才拼接冒号。 依据:https://learn.microsoft.com/en-us/graph/api/site-get?view=graph-rest-1.0 Generated by ChatGPT-6.1-Sol Medium |
- `NormalizeSiteID` 对空站点路径走 `/sites/{hostname}` 主机名寻址,只有存在站点子路径时才生成 `/sites/{hostname}:/{path}:`
- 统一 `host:/path/:` 这类多重尾字符为单个冒号
- 补充裸主机名、带尾斜杠主机名、`host:/` 三种输入的用例
Co-authored-by: Claude <81847+claude@users.noreply.github.com>
@jyxjjj 改了,分类做了处理,并增加了测试 |
已补充文档和前端显示。 |
Summary / 摘要
OnedriveAPP(the client-credentials variant of the OneDrive driver) hardcodes the Graph path to/v1.0/users/{email}/drive/root, so it can only reach a user's OneDrive. This adds an opt-in SharePoint mode that targets a site's default document library.User-visible behavior changes:
is_sharepoint(bool, defaultfalse) andsite_id(string) fields. Withis_sharepointenabled, requests go to/v1.0/sites/{siteId}/driveinstead of/v1.0/users/{email}/drive.site_idaccepts<host>,<siteGuid>,<webGuid>,<host>:/sites/<name>, or a full site URL.is_sharepointdefaults tofalse, which keeps the original/users/{email}/drivepath unchanged.Important implementation changes:
InitviaGET /v1.0/sites/{id}?$select=id, and the resulting opaque ID is written back to the storage record.host,<siteGuid>,<webGuid>form and the path formhost:/sites/<name>, but only the opaque form can be followed by/drive— the path form's trailing colon terminates the segment and any suffix returns400 Url specified is invalid. Since the driver builds URLs like/drive/root:/<path>:, normalization has to happen up front, and the resolved ID is persisted so subsequentInits and cold starts use it directly.Initvalidatessite_idin SharePoint mode andemailin user mode.getDrive(quota reporting) follows the same mode switch.Config/storage changes: two new fields are added to
Addition, so existing storage records gain empty defaults on read-back. No migration is required and no existing field changes meaning./ 此 PR 包含破坏性变更。
/ 此 PR 修改了公开 API、配置、存储格式或迁移行为。
/ 此 PR 需要关联仓库同步修改。
Related Issues / 关联 Issue
Relates to OpenListTeam/OpenList-Frontend#724
Relates to OpenListTeam/OpenList-Docs#394
Testing / 测试
go test ./...Commands run:
gofmt -l drivers/onedrive_app/ # no output
go vet ./drivers/onedrive_app/
go test ./drivers/onedrive_app/
go test ./...
Platform: Windows 11, Go 1.27.3, local build of this branch.
Manual verification against a real tenant using client credentials and application permission
Sites.ReadWrite.All:site_idsupplied as a full URL, as<host>:/sites/<name>, and in the opaque comma form — all three mount correctly, and the resolved ID is persistedroot_folder_path, verified both before and after a restarthttps://contoso.sharepoint.com) resolves to the root site rather than the sub-site; its default library is separate from sub-site libraries and typically empty, so this is documented in the field help rather than rejectedNot covered:
globalregion was exercised against a live tenant;cn/us/deshare the same code path but were not validated.Sites.ReadWrite.Allwas tested; scopedSites.Selectedwas not.App Packages) are out of scope — the driver uses the site's default library.Checklist / 检查清单
/ 我已阅读 CONTRIBUTING。
/ 我确认此贡献符合仓库许可证、贡献规范和行为准则。
gofmt,go fmt, orprettierwhere applicable./ 我已按适用情况使用
gofmt、go fmt或prettier格式化变更代码。/ 我已在适用情况下请求相关维护者或代码所有者审查。
AI Disclosure / AI 使用声明
/ 此 PR 包含 AI 辅助内容。
Tools used / 使用工具:
Usage scope / 使用范围:
Code generation / 代码生成
Refactoring / 重构
Documentation / 文档
Tests / 测试
Translation / 翻译
Review assistance / 审查辅助
I have reviewed and validated all AI-assisted content included in this PR.
/ 我已审核并验证此 PR 中的所有 AI 辅助内容。
I have ensured that all AI-assisted commits include
Co-Authored-Byattribution./ 我已确保所有 AI 辅助提交都包含
Co-Authored-By归属信息。I can reproduce all AI-assisted content included in this PR without any AI tools.
/ 我可以在没有任何 AI 工具的情况下重现此 PR 中包含的所有 AI 辅助内容。