Skip to content

feat(sharing): allow custom share IDs#2353

Open
MuelNova wants to merge 1 commit intoOpenListTeam:mainfrom
MuelNova:main
Open

feat(sharing): allow custom share IDs#2353
MuelNova wants to merge 1 commit intoOpenListTeam:mainfrom
MuelNova:main

Conversation

@MuelNova
Copy link
Copy Markdown

@MuelNova MuelNova commented Apr 11, 2026

Description / 描述

Allow users to set custom share IDs when creating or updating shares, instead of
being limited to random 8-12 character IDs.

Changes:

  • Expand sharing ID column from char(12) to varchar(64) to support longer custom
    IDs
  • Add new_id field to UpdateSharingReq for renaming existing share IDs
  • Add server-side ID validation: max 64 characters, allowing letters, numbers,
    underscores, hyphens, and CJK characters
  • Add duplicate ID conflict check when updating share IDs
  • Add customize_share_id permission (bit 15) to control which users can set custom
    IDs
  • Cache invalidation on ID update

允许用户在创建或更新分享时设置自定义分享 ID,而不是只能使用随机生成的 8-12 位 ID。

Motivation and Context / 背景

Random share IDs like aB3xK9mQ are hard to remember. Custom IDs (e.g. my-photos,
project-docs) make share links more readable and memorable.

随机分享 ID 难以记忆,自定义 ID 让分享链接更易读、更好记。

Closes #1806

How Has This Been Tested? / 测试

  • Verified GORM AutoMigrate correctly alters column from char(12) to
    varchar(64)
  • Tested custom ID creation via API with valid/invalid IDs
  • Tested ID rename via new_id field in update request
  • Tested duplicate ID rejection
  • Tested permission check: users without customize_share_id permission cannot set
    custom IDs

Checklist / 检查清单

   - Change sharing ID column from char(12) to varchar(64)
   - Add new_id field to UpdateSharingReq for renaming share IDs
   - Add ID validation (max 64 chars, alphanumeric/CJK/hyphens/underscores)
   - Add conflict check when updating share ID
   - Add customize_share_id permission (bit 15)

   Closes OpenListTeam#1806
Copy link
Copy Markdown
Member

@jyxjjj jyxjjj left a comment

Choose a reason for hiding this comment

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

⚠️ Reverted as a mistake

Changing a DB column requires a schema migration/upgrade, which is not handled in this PR.

Please include proper migration codes.

Copy link
Copy Markdown
Member

@jyxjjj jyxjjj left a comment

Choose a reason for hiding this comment

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

I'm sorry for my mistake, I overlooked the AutoMigrate.

@MuelNova
Copy link
Copy Markdown
Author

I'm sorry for my mistake, I overlooked the AutoMigrate.

Yes, GORM will handle this automatically. Thank you for your reviewing :D

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.

[Feature] 自定义分享ID

2 participants