feat(profile): options to select why kind of share links to show in user's profile (#2453)

This commit is contained in:
Aaron Liu
2025-08-12 09:52:47 +08:00
parent bb3db2e326
commit b0057fe92f
7 changed files with 101 additions and 65 deletions

View File

@@ -137,6 +137,16 @@ func (s *ListShareService) ListInUserProfile(c *gin.Context, uid int) (*ListShar
hasher := dep.HashIDEncoder()
shareClient := dep.ShareClient()
targetUser, err := dep.UserClient().GetActiveByID(c, uid)
if err != nil {
return nil, serializer.NewError(serializer.CodeDBError, "Failed to get user", err)
}
if targetUser.Settings != nil && targetUser.Settings.ShareLinksInProfile == types.ProfileHideShare {
return nil, serializer.NewError(serializer.CodeParamErr, "User has disabled share links in profile", nil)
}
publicOnly := targetUser.Settings == nil || targetUser.Settings.ShareLinksInProfile == types.ProfilePublicShareOnly
args := &inventory.ListShareArgs{
PaginationArgs: &inventory.PaginationArgs{
UseCursorPagination: true,
@@ -146,7 +156,7 @@ func (s *ListShareService) ListInUserProfile(c *gin.Context, uid int) (*ListShar
OrderBy: s.OrderBy,
},
UserID: uid,
PublicOnly: true,
PublicOnly: publicOnly,
}
ctx := context.WithValue(c, inventory.LoadShareUser{}, true)