fix(training): 支持 HTTP 附件访问地址
This commit is contained in:
@@ -207,7 +207,7 @@ final class TrainingRemoteReadingViewModel {
|
||||
} catch { saveContentError(error, epoch: epoch) }
|
||||
}
|
||||
|
||||
/// 点击附件时取得可直接交给系统浏览器的有效 HTTPS 链接,不附 App Token。
|
||||
/// 点击附件时取得有效 HTTP/HTTPS 链接,原样交给系统浏览器,不附 App Token。
|
||||
func authorizeAttachment(id: String) async -> TrainingAttachmentLink? {
|
||||
guard !isAuthorizingAttachment, let course, !isInvalidated else { return nil }
|
||||
let epoch = generation
|
||||
@@ -216,7 +216,9 @@ final class TrainingRemoteReadingViewModel {
|
||||
do {
|
||||
let link = try await service.attachmentURL(courseID: course.id, attachmentID: id, taskID: taskID)
|
||||
try await checkIdentity(epoch)
|
||||
guard link.url.scheme?.lowercased() == "https", link.url.host != nil, link.expiresAt > now() else {
|
||||
let scheme = link.url.scheme?.lowercased()
|
||||
guard scheme == "http" || scheme == "https", link.url.host?.isEmpty == false,
|
||||
link.url.user == nil, link.url.password == nil, link.expiresAt > now() else {
|
||||
throw TrainingRemoteError.paramInvalid("附件访问地址无效或已过期,请重试")
|
||||
}
|
||||
contentErrorMessage = nil
|
||||
|
||||
Reference in New Issue
Block a user