|
|
|
@ -278,6 +278,7 @@ type Share struct {
|
|
|
|
|
Downloaded int `json:"downloaded,omitempty"`
|
|
|
|
|
Expires *time.Time `json:"expires,omitempty"`
|
|
|
|
|
Unlocked bool `json:"unlocked"`
|
|
|
|
|
PasswordProtected bool `json:"password_protected,omitempty"`
|
|
|
|
|
SourceType *types.FileType `json:"source_type,omitempty"`
|
|
|
|
|
Owner user.User `json:"owner"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
|
|
@ -306,10 +307,11 @@ func BuildShare(s *ent.Share, base *url.URL, hasher hashid.Encoder, requester *e
|
|
|
|
|
Unlocked: unlocked,
|
|
|
|
|
Owner: user.BuildUserRedacted(owner, redactLevel, hasher),
|
|
|
|
|
Expired: inventory.IsShareExpired(s) != nil || expired,
|
|
|
|
|
Url: BuildShareLink(s, hasher, base),
|
|
|
|
|
Url: BuildShareLink(s, hasher, base, unlocked),
|
|
|
|
|
CreatedAt: s.CreatedAt,
|
|
|
|
|
Visited: s.Views,
|
|
|
|
|
SourceType: util.ToPtr(t),
|
|
|
|
|
PasswordProtected: s.Password != "",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if unlocked {
|
|
|
|
@ -436,10 +438,13 @@ func BuildEntity(extendedInfo *fs.FileExtendedInfo, e fs.Entity, hasher hashid.E
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BuildShareLink(s *ent.Share, hasher hashid.Encoder, base *url.URL) string {
|
|
|
|
|
func BuildShareLink(s *ent.Share, hasher hashid.Encoder, base *url.URL, unlocked bool) string {
|
|
|
|
|
shareId := hashid.EncodeShareID(hasher, s.ID)
|
|
|
|
|
if unlocked {
|
|
|
|
|
return routes.MasterShareUrl(base, shareId, s.Password).String()
|
|
|
|
|
}
|
|
|
|
|
return routes.MasterShareUrl(base, shareId, "").String()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BuildStoragePolicy(sp *ent.StoragePolicy, hasher hashid.Encoder) *StoragePolicy {
|
|
|
|
|
if sp == nil {
|
|
|
|
|