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 #2062 from RocketChat/beta
Browse files Browse the repository at this point in the history
[RELEASE] Merge BETA into MASTER
  • Loading branch information
rafaelks authored Jul 23, 2018
2 parents 1ed0cdc + c420b1e commit dfe2659
Show file tree
Hide file tree
Showing 68 changed files with 692 additions and 858 deletions.
15 changes: 7 additions & 8 deletions Rocket.Chat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
335F4F03207A31D3005E14AF /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335F4F02207A31D3005E14AF /* NotificationManager.swift */; };
3397604920EA72EE0054758A /* RuntimeAttributesThemeableViewSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3397604820EA72EE0054758A /* RuntimeAttributesThemeableViewSpec.swift */; };
339B692B2050449700F97392 /* KeyboardFrameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 339B6929205042D300F97392 /* KeyboardFrameView.swift */; };
33A1BB0520FE312900AFA7D4 /* ChatMessageVideoView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 412A95D51FD94ED000954AA6 /* ChatMessageVideoView.xib */; };
33A1BB0720FF75D600AFA7D4 /* BaseSubscriptionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33A1BB0620FF75D600AFA7D4 /* BaseSubscriptionCell.swift */; };
33A5C9BE206A561400FE1C8F /* emojiNames.json in Resources */ = {isa = PBXBuildFile; fileRef = 33A5C9BD206A561400FE1C8F /* emojiNames.json */; };
33A5C9CA206A565800FE1C8F /* symbols.json in Resources */ = {isa = PBXBuildFile; fileRef = 33A5C9C1206A565800FE1C8F /* symbols.json */; };
33A5C9CB206A565800FE1C8F /* travel.json in Resources */ = {isa = PBXBuildFile; fileRef = 33A5C9C2206A565800FE1C8F /* travel.json */; };
Expand Down Expand Up @@ -177,7 +179,6 @@
412731D51DE0A55C00FC45A0 /* ChatPreviewModeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 412731D41DE0A55C00FC45A0 /* ChatPreviewModeView.xib */; };
412731D71DE0A89B00FC45A0 /* ChatPreviewModeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 412731D61DE0A89B00FC45A0 /* ChatPreviewModeView.swift */; };
412A95D61FD94ED000954AA6 /* ChatMessageVideoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 412A95D41FD94ED000954AA6 /* ChatMessageVideoView.swift */; };
412A95D71FD94ED000954AA6 /* ChatMessageVideoView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 412A95D51FD94ED000954AA6 /* ChatMessageVideoView.xib */; };
412BCC851E55C6A300F7F4EE /* ChatMessageTextView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 412BCC841E55C6A300F7F4EE /* ChatMessageTextView.xib */; };
412BCC871E55C6B800F7F4EE /* ChatMessageTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 412BCC861E55C6B800F7F4EE /* ChatMessageTextView.swift */; };
412BCC8B1E55D4AA00F7F4EE /* UIColorCSSColorsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 412BCC8A1E55D4AA00F7F4EE /* UIColorCSSColorsExtension.swift */; };
Expand Down Expand Up @@ -736,7 +737,6 @@
B5893BF61F6C4B1D00365768 /* UserReviewManagerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5893BF51F6C4B1D00365768 /* UserReviewManagerSpec.swift */; };
D10E9C1A1F643457007F1796 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D10E9C191F643457007F1796 /* Channel.swift */; };
D10E9C1E1F643474007F1796 /* ChannelModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = D10E9C1D1F643474007F1796 /* ChannelModelMapping.swift */; };
D10E9C201F6434A7007F1796 /* NSRangeExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D10E9C1F1F6434A7007F1796 /* NSRangeExtensions.swift */; };
D10E9C221F643616007F1796 /* MentionModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = D10E9C211F643616007F1796 /* MentionModelMapping.swift */; };
D12D34031F69C76400AED992 /* SubscriptionExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12D34021F69C76400AED992 /* SubscriptionExtensions.swift */; };
D1411A2A1F6777F300D6EDF7 /* ChannelSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1411A291F6777F300D6EDF7 /* ChannelSpec.swift */; };
Expand Down Expand Up @@ -903,6 +903,7 @@
335F4F02207A31D3005E14AF /* NotificationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = "<group>"; };
3397604820EA72EE0054758A /* RuntimeAttributesThemeableViewSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuntimeAttributesThemeableViewSpec.swift; sourceTree = "<group>"; };
339B6929205042D300F97392 /* KeyboardFrameView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardFrameView.swift; sourceTree = "<group>"; };
33A1BB0620FF75D600AFA7D4 /* BaseSubscriptionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseSubscriptionCell.swift; sourceTree = "<group>"; };
33A5C9BD206A561400FE1C8F /* emojiNames.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = emojiNames.json; sourceTree = "<group>"; };
33A5C9C1206A565800FE1C8F /* symbols.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = symbols.json; sourceTree = "<group>"; };
33A5C9C2206A565800FE1C8F /* travel.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = travel.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1539,7 +1540,6 @@
BCF38696E8EC385488688390 /* Pods-Rocket.Chat.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Rocket.Chat.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Rocket.Chat/Pods-Rocket.Chat.debug.xcconfig"; sourceTree = "<group>"; };
D10E9C191F643457007F1796 /* Channel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Channel.swift; sourceTree = "<group>"; };
D10E9C1D1F643474007F1796 /* ChannelModelMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChannelModelMapping.swift; sourceTree = "<group>"; };
D10E9C1F1F6434A7007F1796 /* NSRangeExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSRangeExtensions.swift; sourceTree = "<group>"; };
D10E9C211F643616007F1796 /* MentionModelMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MentionModelMapping.swift; sourceTree = "<group>"; };
D12D34021F69C76400AED992 /* SubscriptionExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubscriptionExtensions.swift; sourceTree = "<group>"; };
D1411A291F6777F300D6EDF7 /* ChannelSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChannelSpec.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2235,7 +2235,6 @@
41E991D31D343A9F00BDDCA8 /* DateExtension.swift */,
77CCB6BD1F8D0597004BBF67 /* DictionaryExtensions.swift */,
41FC9E07209B3A6300FED485 /* NSAttributedStringExtensions.swift */,
D10E9C1F1F6434A7007F1796 /* NSRangeExtensions.swift */,
80A2A2AA2073BD0800857DAF /* RealmCurrent.swift */,
8076FDA8204853DE00114F28 /* RealmExecute.swift */,
8076FDA32048533000114F28 /* String+Random.swift */,
Expand Down Expand Up @@ -2304,6 +2303,7 @@
4147CE7C1F5EAAB300C322C3 /* ServerCell.swift */,
41FBF4EA20BD8C650080D00D /* ServerCell.xib */,
4192054B1D52F4FC004EEC5F /* SubscriptionCell.swift */,
33A1BB0620FF75D600AFA7D4 /* BaseSubscriptionCell.swift */,
41778EB820ED4C2C007F72F9 /* SubscriptionCellCondensed.swift */,
41DE687C20C6D57F00AA5EC8 /* SubscriptionSortingCell.swift */,
41DE688020C6EBE600AA5EC8 /* SubscriptionSortingCell.xib */,
Expand Down Expand Up @@ -3677,7 +3677,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = Rocket.Chat;
TargetAttributes = {
41DF76DE1D2C50710028DBF8 = {
Expand Down Expand Up @@ -3761,10 +3761,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
412A95D71FD94ED000954AA6 /* ChatMessageVideoView.xib in Resources */,
33A1BB0520FE312900AFA7D4 /* ChatMessageVideoView.xib in Resources */,
14F8A25D202E64B200175FDC /* [email protected] in Resources */,
411D40CD20D28150001A1035 /* ChannelInfoBasicCell.xib in Resources */,
412A95D71FD94ED000954AA6 /* ChatMessageVideoView.xib in Resources */,
33A5C9CC206A565800FE1C8F /* regional.json in Resources */,
412EF3C62050507C001689A3 /* ReusableViewText.xib in Resources */,
14F8A224202E5CBF00175FDC /* [email protected] in Resources */,
Expand Down Expand Up @@ -4255,7 +4254,6 @@
4153E80520504BE700FBC26B /* ReusableViewText.swift in Sources */,
419ECCA61F3CA58A005F224B /* ChatControllerDocuments.swift in Sources */,
14BAFADE20308EE50054A2E6 /* DrawingBrushWidthViewController.swift in Sources */,
D10E9C201F6434A7007F1796 /* NSRangeExtensions.swift in Sources */,
807FB53D2044B49800E21429 /* Emojione+Transform.swift in Sources */,
7798B4191F852D670074B2F4 /* CustomField.swift in Sources */,
4156250820BEDCD100D20576 /* ServersListViewModel.swift in Sources */,
Expand Down Expand Up @@ -4528,6 +4526,7 @@
413FB6C11FE17D7D00F010AA /* UIViewExtentions.swift in Sources */,
8076FDB0204856AF00114F28 /* AuthCanBlockMessage.swift in Sources */,
8076FDA9204853DE00114F28 /* RealmExecute.swift in Sources */,
33A1BB0720FF75D600AFA7D4 /* BaseSubscriptionCell.swift in Sources */,
806EFA5E209BF1AC00D0D650 /* SubscriptionReadRequest.swift in Sources */,
9960C8302063F0C8004A034C /* WebBrowserTableViewController.swift in Sources */,
140A95E4202F536D003FD564 /* DrawingViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "0940"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 1 addition & 0 deletions Rocket.Chat/API/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ final class API: APIFetcher {
requestMiddlewares.append(VersionMiddleware(api: self))
}

// swiftlint:disable function_body_length
@discardableResult
func fetch<R: APIRequest>(_ request: R, options: APIRequestOptionSet = [], sessionDelegate: URLSessionTaskDelegate? = nil,
completion: ((_ result: APIResponse<R.APIResourceType>) -> Void)?) -> URLSessionTask? {
Expand Down
29 changes: 24 additions & 5 deletions Rocket.Chat/API/Clients/MessagesClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SwiftyJSON
struct MessagesClient: APIClient {
let api: AnyAPIFetcher

// swiftlint:disable function_body_length
func sendMessage(_ message: Message, subscription: Subscription, realm: Realm? = Realm.current) {
guard let id = message.identifier else { return }
let subscriptionIdentifier = subscription.rid
Expand All @@ -28,7 +29,12 @@ struct MessagesClient: APIClient {
}

func updateMessage(json: JSON) {
if message.isInvalidated {
return
}

let server = AuthManager.selectedServerHost()

AnalyticsManager.log(event: .messageSent(subscriptionType: subscription.type.rawValue, server: server))

try? realm?.write {
Expand All @@ -44,6 +50,10 @@ struct MessagesClient: APIClient {

func setMessageOffline() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
if message.isInvalidated {
return
}

try? realm?.write {
message.temporary = false
message.failed = true
Expand All @@ -70,7 +80,9 @@ struct MessagesClient: APIClient {
switch error {
case .version:
SubscriptionManager.sendTextMessage(message, completion: { response in
updateMessage(json: response.result["result"])
DispatchQueue.main.async {
updateMessage(json: response.result["result"])
}
})
default:
setMessageOffline()
Expand All @@ -80,6 +92,8 @@ struct MessagesClient: APIClient {
}
}

// swiftlint:enable function_body_length

func sendMessage(text: String, subscription: Subscription, id: String = String.random(18), user: User? = AuthManager.currentUser(), realm: Realm? = Realm.current) {
let message = Message()
message.internalType = ""
Expand Down Expand Up @@ -178,6 +192,7 @@ struct MessagesClient: APIClient {
return true
}

// swiftlint:disable function_body_length
@discardableResult
func reactMessage(_ message: Message, emoji: String, user: User? = AuthManager.currentUser(), realm: Realm? = Realm.current) -> Bool {
guard let id = message.identifier, let username = user?.username else {
Expand Down Expand Up @@ -233,11 +248,13 @@ struct MessagesClient: APIClient {
case .version:
// version fallback
MessageManager.react(message, emoji: emoji, completion: { _ in
AnalyticsManager.log(
event: .reaction(
subscriptionType: message.subscription?.type.rawValue ?? ""
DispatchQueue.main.async {
AnalyticsManager.log(
event: .reaction(
subscriptionType: message.subscription?.type.rawValue ?? ""
)
)
)
}
})
default:
Alert.defaultError.present()
Expand All @@ -247,4 +264,6 @@ struct MessagesClient: APIClient {

return true
}

// swiftlint:enable function_body_length
}
2 changes: 1 addition & 1 deletion Rocket.Chat/API/Clients/SpotlightClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct SpotlightClient: APIClient {
}, completion: {
completion(resource.raw, false)
})
case .error(let _):
case .error:
completion(nil, true)
}
}
Expand Down
2 changes: 2 additions & 0 deletions Rocket.Chat/API/Requests/General/PublicSettingsRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ final class PublicSettingsRequest: APIRequest {
"CAS_enabled",
"CAS_login_url",
"API_Gitlab_URL",
"API_Wordpress_URL",
"Accounts_ShowFormLogin",
"Accounts_RegistrationForm",
"Accounts_PasswordReset",
Expand All @@ -50,6 +51,7 @@ final class PublicSettingsRequest: APIRequest {
"Accounts_AllowUsernameChange",
"Accounts_AllowEmailChange",
"Accounts_AllowPasswordChange",
"Accounts_OAuth_Wordpress_server_type",
"FileUpload_Storage_Type",
"Message_HideType_uj",
"Message_HideType_ul",
Expand Down
6 changes: 5 additions & 1 deletion Rocket.Chat/API/Requests/General/SpotlightRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ final class SpotlightRequest: APIRequest {
let query: String?

init(query: String) {
self.query = "query=\(query)"
if let encodedQuery = query.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
self.query = "query=\(encodedQuery)"
} else {
self.query = ""
}
}
}

Expand Down
31 changes: 28 additions & 3 deletions Rocket.Chat/Controllers/Auth/AuthTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ class AuthTableViewController: BaseTableViewController {

override func viewDidLoad() {
super.viewDidLoad()

title = serverURL.host

guard let settings = serverPublicSettings else { return }

if !settings.isUsernameEmailAuthenticationEnabled {
emailAuthRow.registerButton.isHidden = true
emailAuthRow.isHidden = true
authSeparatorRow.isHidden = true
} else {
emailAuthRow.registerButton.isHidden = settings.registrationForm != .isPublic
}
Expand Down Expand Up @@ -190,14 +192,33 @@ class AuthTableViewController: BaseTableViewController {
return
}

let loginService = loginServices[button.tag]
let loginService = LoginService(value: loginServices[button.tag])
if loginService.service == "gitlab", let url = serverPublicSettings?.gitlabUrl {
loginServices[button.tag].serverUrl = url
try? realm.write {
loginService.serverUrl = url
}
}

if loginService.service == "wordpress" {
if let url = serverPublicSettings?.wordpressUrl, !url.isEmpty {
loginService.serverUrl = url

/*
NOTE: If should be this, but API is broken
serverPublicSettings?.oauthWordpressServerType == "custom"
*/

loginService.mapWordPressCustom()
} else { // oauthWordPressServerType == wordpress-com
loginService.mapWordPress()
} // missing implementation for wp-oauth-server

try? realm.write {
realm.add(loginService, update: true)
}
}

switch loginService.type {
case .cas:
presentCASViewController(for: loginService)
Expand Down Expand Up @@ -328,7 +349,11 @@ extension AuthTableViewController {

return LoginServiceTableViewCell.rowHeight
case kEmailAuthSection:
return loginServices.count > 0 ? EmailAuthTableViewCell.rowHeightBelowSeparator : EmailAuthTableViewCell.rowHeight
if loginServices.count > 0 {
return emailAuthRow.isHidden ? .leastNonzeroMagnitude : EmailAuthTableViewCell.rowHeightBelowSeparator
}

return EmailAuthTableViewCell.rowHeight
default:
return 0
}
Expand Down
12 changes: 11 additions & 1 deletion Rocket.Chat/Controllers/Auth/ConnectServerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@ final class ConnectServerViewController: BaseViewController {
var shouldAutoConnect = false
var url: URL? {
guard var urlText = textFieldServerURL.text else { return URL(string: defaultURL, scheme: "https") }

if urlText.isEmpty {
urlText = defaultURL
}
return URL(string: urlText, scheme: "https")

// Remove all the whitespaces from the string
urlText = urlText.removingWhitespaces()

// Add .rocket.chat in the end if it's only one string
if !urlText.contains(".") {
urlText += ".rocket.chat"
}

return URL(string: urlText, scheme: "https")
}

var serverPublicSettings: AuthSettings?
Expand Down
2 changes: 2 additions & 0 deletions Rocket.Chat/Controllers/Base/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class BaseViewController: UIViewController, PopPushDelegate, NavigationBarTransp
target: nil,
action: nil
)

popoverPresentationController?.backgroundColor = view.theme?.focusedBackground
}

override func viewWillAppear(_ animated: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extension ChatViewController {
present(alert, animated: true, completion: nil)
}

// swiftlint:disable function_body_length
func actionsForMessage(_ message: Message, view: UIView) -> [UIAlertAction] {
guard
let messageUser = message.user,
Expand Down Expand Up @@ -124,6 +125,8 @@ extension ChatViewController {
return actions
}

// swiftlint:enable function_body_length

func actionsForFailedMessage(_ message: Message) -> [UIAlertAction] {

let resend = UIAlertAction(title: localized("chat.message.actions.resend"), style: .default, handler: { _ in
Expand Down
Loading

0 comments on commit dfe2659

Please sign in to comment.