1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-29 08:27:55 +00:00

update-sharelink-with-new-dl-url (#7155)

This commit is contained in:
Ranjiwei 2024-12-06 21:42:04 +08:00 committed by GitHub
parent b484b45f1a
commit f4d15fb574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 4 deletions

View File

@ -53,7 +53,7 @@ class LinkDetails extends React.Component {
onCopyDownloadLink = () => {
const { sharedLinkInfo } = this.props;
copy(`${sharedLinkInfo.link}?dl=1`);
copy(`${sharedLinkInfo.download_link}`);
toaster.success(gettext('Direct download link is copied to the clipboard.'));
};
@ -177,12 +177,12 @@ class LinkDetails extends React.Component {
copyLink={this.onCopySharedLink}
/>
</dd>
{!sharedLinkInfo.is_dir && sharedLinkInfo.permissions.can_download && ( // just for file
{!sharedLinkInfo.is_dir && sharedLinkInfo.permissions.can_download && sharedLinkInfo.show_download_link && ( // just for file
<>
<dt className="text-secondary font-weight-normal">{gettext('Direct download link')}</dt>
<dd>
<SharedLink
link={`${sharedLinkInfo.link}?dl=1`}
link={`${sharedLinkInfo.download_link}`}
linkExpired={sharedLinkInfo.is_expired}
copyLink={this.onCopyDownloadLink}
/>

View File

@ -19,6 +19,8 @@ class ShareLink {
this.ctime = object.ctime;
this.password = object.password;
this.user_scope = object.user_scope;
this.download_link = object.download_link;
this.show_download_link = object.show_download_link;
}
}

View File

@ -38,7 +38,7 @@ from seahub.share.utils import VALID_SHARE_LINK_SCOPE, SCOPE_SPECIFIC_USERS, SCO
from seahub.utils import gen_shared_link, is_org_context, normalize_file_path, \
normalize_dir_path, is_pro_version, get_file_type_and_ext, \
check_filename_with_rename, gen_file_upload_url, \
get_password_strength_level, is_valid_password, is_valid_email, string2list
get_password_strength_level, is_valid_password, is_valid_email, string2list, gen_file_get_url_by_sharelink
from seahub.utils.file_op import if_locked_by_online_office
from seahub.utils.file_types import IMAGE, VIDEO, XMIND
from seahub.utils.file_tags import get_tagged_files, get_files_tags_in_dir
@ -108,6 +108,8 @@ def get_share_link_info(fileshare):
data['token'] = token
data['link'] = gen_shared_link(token, fileshare.s_type)
data['download_link'] = gen_file_get_url_by_sharelink(token)
data['show_download_link'] = fileshare.show_download_link
data['view_cnt'] = fileshare.view_cnt
data['ctime'] = ctime
data['expire_date'] = expire_date
@ -284,6 +286,8 @@ class ShareLinks(APIView):
link_info['is_dir'] = True if s_type == 'd' else False
link_info['token'] = token
link_info['link'] = gen_shared_link(token, s_type)
link_info['download_link'] = gen_file_get_url_by_sharelink(token)
link_info['show_download_link'] = fs.show_download_link
link_info['view_cnt'] = fs.view_cnt
link_info['ctime'] = datetime_to_isoformat_timestr(fs.ctime) if fs.ctime else ''
link_info['expire_date'] = datetime_to_isoformat_timestr(fs.expire_date) if fs.expire_date else ''

View File

@ -409,6 +409,14 @@ class FileShare(models.Model):
return '%s/f/%s/' % (service_url, self.token)
else:
return '%s/d/%s/' % (service_url, self.token)
@property
def show_download_link(self):
if self.is_encrypted():
return False
if self.user_scope != 'all_users':
return False
return True
def get_permissions(self):
perm_dict = {}