Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #373 from RocketChat/feature/validate_server_versi…
Browse files Browse the repository at this point in the history
…on.352

Validate server version and alert user when user tries to connect to it
  • Loading branch information
rafaelks authored Mar 24, 2017
2 parents 6382685 + 6492702 commit 7429c6a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def shared_pods

# Code utilities
pod 'SwiftyJSON'
pod 'semver'

# UI
pod 'SideMenuController'
Expand Down
5 changes: 4 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ PODS:
- SDWebImage (3.8.2):
- SDWebImage/Core (= 3.8.2)
- SDWebImage/Core (3.8.2)
- semver (1.0.0)
- SideMenuController (0.2.4)
- SlackTextViewController (1.9.5)
- Starscream (2.0.3)
Expand All @@ -69,6 +70,7 @@ DEPENDENCIES:
- NVActivityIndicatorView
- RealmSwift
- SDWebImage (~> 3.8)
- semver
- SideMenuController
- SlackTextViewController
- Starscream (~> 2.0.0)
Expand All @@ -95,13 +97,14 @@ SPEC CHECKSUMS:
Realm: d27b758e12d62a3371879a065d4c40aa212c5a54
RealmSwift: 9556c0fe0f0cfecacfb755ae9e68ff379fc6bead
SDWebImage: 098e97e6176540799c27e804c96653ee0833d13c
semver: efe6bf4af25bffab18d442592771be392210b5ce
SideMenuController: b463d2b3aa58e2afe57f57a07938fa9a647894ca
SlackTextViewController: fbcdadbb8090673f604484ff5b6eb8d77baed42a
Starscream: 3fdd5c277e57cca6b5c406d274e3f34a7c88f2ce
SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220
TSMarkdownParser: 114779f14d46e7fc6d9880d4797e5abcc01f92c3
URBMediaFocusViewController: 26779e301fe75ec0152fbe8b476bd06ccee9f9b3

PODFILE CHECKSUM: ddb7c3e672b9fde92752fcd4b57fa8a2c6116722
PODFILE CHECKSUM: ba9d77b7ee1abf5cb7a1edf9ef743f9b8dfefe5c

COCOAPODS: 1.1.1
18 changes: 17 additions & 1 deletion Rocket.Chat/Controllers/Auth/ConnectServerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit
import SwiftyJSON
import semver

final class ConnectServerViewController: BaseViewController {

Expand Down Expand Up @@ -149,10 +150,25 @@ final class ConnectServerViewController: BaseViewController {
let json = JSON(data: data)
Log.debug(json.rawString())

guard json["version"].string != nil else {
guard let version = json["version"].string else {
return completion(nil, true)
}

if let minVersion = Bundle.main.object(forInfoDictionaryKey: "RC_MIN_SERVER_VERSION") as? String {
if Semver.lt(version, minVersion) {
let alert = UIAlertController(
title: localized("alert.connection.invalid_version.title"),
message: String(format: localized("alert.connection.invalid_version.message"), version, minVersion),
preferredStyle: .alert
)

alert.addAction(UIAlertAction(title: localized("global.ok"), style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)

return completion(nil, true)
}
}

completion(json, false)
} else {
completion(nil, true)
Expand Down
2 changes: 2 additions & 0 deletions Rocket.Chat/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>RC_MIN_SERVER_VERSION</key>
<string>0.54.0</string>
</dict>
</plist>
3 changes: 3 additions & 0 deletions Rocket.Chat/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"alert.connection.invalid_url.title" = "Oops!";
"alert.connection.invalid_url.message" = "The URL you entered is invalid. Check it and try again, please!";

"alert.connection.invalid_version.title" = "Oops!";
"alert.connection.invalid_version.message" = "The server you're trying to connect is using a version that's not supported by the app anymore: %@.\n\nWe require version %@.";

// Socket Connection
"connection.offline.banner.message" = "You're offline, try connecting again";

Expand Down

0 comments on commit 7429c6a

Please sign in to comment.