Skip to content

Comments

feat: Added an ability to share by a link a file inside a shared drive#4681

Open
shepilov wants to merge 2 commits intomasterfrom
feat/shared_drive_share_by_link
Open

feat: Added an ability to share by a link a file inside a shared drive#4681
shepilov wants to merge 2 commits intomasterfrom
feat/shared_drive_share_by_link

Conversation

@shepilov
Copy link
Contributor

Summary

Add share-by-link functionality for shared drives, allowing both owners and members to create and revoke public links for files within a shared drive.

@shepilov shepilov requested a review from a team as a code owner February 19, 2026 15:43
@shepilov shepilov force-pushed the feat/shared_drive_share_by_link branch from d964e8e to 835811d Compare February 19, 2026 16:18
@shepilov shepilov force-pushed the feat/shared_drive_share_by_link branch from 835811d to 5fcd5bf Compare February 19, 2026 16:24
type APIPermission struct {
*permission.Permission
included []jsonapi.Object
PublicLink string `json:"public_link,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, it was initial idea to custruct URL for the shared resource on backend

Comment on lines +502 to +509
// getSharingDir returns the directory linked to the drive sharing.
func getSharingDir(inst *instance.Instance, s *sharing.Sharing) (*vfs.DirDoc, error) {
dir, err := s.GetSharingDir(inst)
if err != nil {
return nil, jsonapi.NotFound(errors.New("shared drive not found"))
}
return dir, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

[nit] This function is only used by ChangesFeed and doesn't really do much more than calling s.GetSharingDir(inst) directly in ChangedFeed would.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I think I was going to use the validateSharedDrivePermission function and then forgot about it

}

// CreateSharedDrivePermissionHandler creates a share-by-link permission for a file in a shared drive.
func CreateSharedDrivePermissionHandler(c echo.Context, inst *instance.Instance, s *sharing.Sharing) error {
Copy link
Member

Choose a reason for hiding this comment

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

[nit] I find the name of this function a bit confusing.
I think specifying the type of permission would be useful (e.g. CreateSharedDriveLinkPermissionHandler).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not too long?


// HandleCreateShareByLink is the common handler for creating share-by-link permissions.
// It handles parsing, optional additional validation, creation via CreateShareSet, and response formatting.
func HandleCreateShareByLink(c echo.Context, inst *instance.Instance, extraValidate ValidatePermissionsFn, skipValidation bool) error {
Copy link
Member

Choose a reason for hiding this comment

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

This name is a lot clearer! 👍

Comment on lines +126 to +136
var subdoc permission.Permission
if _, err := jsonapi.Bind(c.Request().Body, &subdoc); err != nil {
return err
}

// Run additional validation if provided (e.g., for shared drives)
if extraValidate != nil {
if err := extraValidate(subdoc.Permissions); err != nil {
return err
}
}
Copy link
Member

Choose a reason for hiding this comment

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

We usually return bad request errors only if there are no permission errors. I would expect to see those after the call to middlewares.GetPermission(c).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just a code from the old createPermission function. I thin if we need to change the API, we need to check how it's used by the client

Copy link
Member

Choose a reason for hiding this comment

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

You changed the order in which the code is called though.

}

// RevokeSharedDrivePermission revokes a share-by-link permission for a file in a shared drive.
func RevokeSharedDrivePermission(c echo.Context, inst *instance.Instance, s *sharing.Sharing) error {
Copy link
Member

Choose a reason for hiding this comment

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

[nit] Same thing here: adding the type of permission to the function name would be helpful.

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.

2 participants