-
Notifications
You must be signed in to change notification settings - Fork 438
[NEW] Use REST API to upload files with fallback to older servers #1058
Conversation
@@ -76,6 +76,20 @@ class UploadManager { | |||
|
|||
// swiftlint:disable function_body_length | |||
func uploadToUFSFile(store: String, file: FileUpload, subscription: Subscription, progress: UploadProgressBlock, completion: @escaping UploadCompletionBlock) { | |||
|
|||
if let api = API.current() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't API.current() always return something valid? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not how it's working currently. I use the Auth object from AuthManager.isAuthenticated() to build it.
@cardoso Take a look here in the code below, we're using a different Rocket.Chat.iOS/Rocket.Chat/Managers/Uploader/UploadManager.swift Lines 42 to 60 in ce206a6
|
Codecov Report
@@ Coverage Diff @@
## develop #1058 +/- ##
==========================================
+ Coverage 39.86% 44.06% +4.2%
==========================================
Files 254 257 +3
Lines 14307 14419 +112
Branches 742 791 +49
==========================================
+ Hits 5703 6354 +651
+ Misses 8144 7599 -545
- Partials 460 466 +6
Continue to review full report at Codecov.
|
completion(nil, false) | ||
}, errored: { error in | ||
if case .version = error { | ||
// TODO: Remove Upload fallback after Rocket.Chat 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo Violation: TODOs should be avoided (Remove Upload fallback after R...). (todo)
@rafaelks ready for review 👍 thanks for the help!! |
completion(response, true) | ||
return | ||
} | ||
completion(nil, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we send the error to the completion block? I think would be interesting to show the error message here, example: file limit is 2MB
.
Blocked by RocketChat/Rocket.Chat#9096 |
… into feat/upload_http.1055
completion?() | ||
}, errored: { error in | ||
if case .version = error { | ||
// TODO: Remove Upload fallback after Rocket.Chat 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo Violation: TODOs should be avoided (Remove Upload fallback after R...). (todo)
@rafaelks now it's showing error messages (unblocked by RocketChat/Rocket.Chat#9108) |
}) | ||
} | ||
|
||
func deletePushToken(token: String? = PushManager.getDeviceToken()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is deletePushToken method here? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No good reason 😊 thanks for spotting it 😂
|
||
api.fetch(req, succeeded: { result in | ||
if let error = result.error { | ||
Alert(key: "alert.upload_error").withMessage(error).present() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status code 2xx with error (I know it's API's fault)? 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♀️
@RocketChat/ios
Closes #1055