Skip to content

feat: add owner_open_id config and auto-grant permission after doc creation#76

Open
ilittle7 wants to merge 1 commit intoriba2534:mainfrom
ilittle7:feat/owner-open-id
Open

feat: add owner_open_id config and auto-grant permission after doc creation#76
ilittle7 wants to merge 1 commit intoriba2534:mainfrom
ilittle7:feat/owner-open-id

Conversation

@ilittle7
Copy link
Copy Markdown

Summary

  • Add owner_open_id config field as an alternative to owner_email for granting document permissions after creation
  • owner_open_id takes priority over owner_email when both are configured
  • Auto-grant full_access permission after doc create, bitable create, file mkdir, file copy, and doc import-file
  • Auto-transfer ownership when transfer_ownership: true is set

Motivation

Personal Feishu accounts that registered with a phone number (without enterprise email) cannot use email-based permission APIs — the API returns Invalid parameter (code 1063001). Using openid as the member type works for all accounts.

Config

# Priority: owner_open_id > owner_email
owner_open_id: "ou_xxxx"          # env: FEISHU_OWNER_OPEN_ID
owner_email: "user@example.com"   # env: FEISHU_OWNER_EMAIL (fallback)
transfer_ownership: true          # optional: transfer doc ownership to owner

Changes

File Change
internal/config/config.go Add OwnerOpenID field, GetOwner() method, env binding, default template
internal/config/config_test.go Tests for new field, env var, GetOwner() priority logic
cmd/owner_grant.go New grantOwnerPermission() helper function
cmd/create_document.go Call grantOwnerPermission after doc create
cmd/bitable_create.go Call grantOwnerPermission after bitable create
cmd/import_file.go Call grantOwnerPermission after file import
cmd/copy_file.go Call grantOwnerPermission after file copy
cmd/create_folder.go Call grantOwnerPermission after folder create
cmd/config_get.go Add owner_open_id to help text

Test plan

  • All existing tests pass (go test ./...)
  • New tests for OwnerOpenID from env var
  • New tests for OwnerOpenID from config file
  • New tests for GetOwner() priority (open_id > email > none)
  • Manual test: create doc with owner_open_id configured

🤖 Generated with Claude Code

…eation

Add `owner_open_id` config field as an alternative to `owner_email` for
granting document permissions. This solves the issue where personal Feishu
accounts without enterprise email cannot use email-based permission APIs.

Changes:
- Add `owner_open_id` config field (priority over `owner_email`)
- Add `Config.GetOwner()` method returning (memberType, memberID)
- Auto-grant full_access permission after doc/bitable/folder/file creation
- Auto-transfer ownership when `transfer_ownership: true`
- Add env var support: `FEISHU_OWNER_OPEN_ID`
- Add tests for new config field and GetOwner priority logic

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant