From 523ae33962beecbfab8db0ab37b7ef31c72001a8 Mon Sep 17 00:00:00 2001 From: cardoso Date: Thu, 26 Apr 2018 22:13:49 -0300 Subject: [PATCH 01/17] Rename Subscription*Request -> Room*Request --- Rocket.Chat.xcodeproj/project.pbxproj | 76 +++++++++---------- .../RoomCreateRequest.swift} | 14 ++-- .../RoomInfoRequest.swift} | 8 +- .../RoomMembersRequest.swift} | 8 +- .../RoomMentionsRequest.swift} | 8 +- .../SubscriptionMessagesRequest.swift | 8 +- .../Chat/MembersListViewController.swift | 2 +- .../Chat/MessagesListViewController.swift | 8 +- .../Subscriptions/NewRoomViewController.swift | 6 +- Rocket.Chat/Managers/AppManager.swift | 2 +- .../RoomCreateRequestSpec.swift} | 10 +-- .../RoomInfoRequestSpec.swift} | 10 +-- .../RoomMembersRequestSpec.swift} | 10 +-- .../RoomMentionsRequestSpec.swift} | 10 +-- 14 files changed, 90 insertions(+), 90 deletions(-) rename Rocket.Chat/API/Requests/{Subscription/SubscriptionCreateRequest.swift => Room/RoomCreateRequest.swift} (79%) rename Rocket.Chat/API/Requests/{Subscription/SubscriptionInfoRequest.swift => Room/RoomInfoRequest.swift} (86%) rename Rocket.Chat/API/Requests/{Subscription/SubscriptionMembersRequest.swift => Room/RoomMembersRequest.swift} (87%) rename Rocket.Chat/API/Requests/{Subscription/SubscriptionMentionsRequest.swift => Room/RoomMentionsRequest.swift} (82%) rename Rocket.Chat/API/Requests/{Subscription => Room}/SubscriptionMessagesRequest.swift (88%) rename Rocket.ChatTests/API/Requests/{Subscription/SubscriptionCreateRequestSpec.swift => Room/RoomCreateRequestSpec.swift} (90%) rename Rocket.ChatTests/API/Requests/{Subscription/SubscriptionInfoRequestSpec.swift => Room/RoomInfoRequestSpec.swift} (87%) rename Rocket.ChatTests/API/Requests/{Subscription/SubscriptionMembersRequestSpec.swift => Room/RoomMembersRequestSpec.swift} (88%) rename Rocket.ChatTests/API/Requests/{Subscription/SubscriptionMentionsRequestSpec.swift => Room/RoomMentionsRequestSpec.swift} (90%) diff --git a/Rocket.Chat.xcodeproj/project.pbxproj b/Rocket.Chat.xcodeproj/project.pbxproj index f2adbeb864..fce694272e 100644 --- a/Rocket.Chat.xcodeproj/project.pbxproj +++ b/Rocket.Chat.xcodeproj/project.pbxproj @@ -353,8 +353,8 @@ 8020CCF51FEAD8C9003424F4 /* EmojiPickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8020CCF41FEAD8C9003424F4 /* EmojiPickerController.swift */; }; 80213C0B1FDFE35C00809E14 /* UploadMessageRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80213C0A1FDFE35C00809E14 /* UploadMessageRequestSpec.swift */; }; 80213C0E1FE0639E00809E14 /* HTTPMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80213C0D1FE0639E00809E14 /* HTTPMethod.swift */; }; - 80235D1B1F74070100A56CA5 /* SubscriptionMembersRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80235D1A1F74070100A56CA5 /* SubscriptionMembersRequest.swift */; }; - 80235D221F7442F700A56CA5 /* SubscriptionMembersRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80235D211F7442F700A56CA5 /* SubscriptionMembersRequestSpec.swift */; }; + 80235D1B1F74070100A56CA5 /* RoomMembersRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80235D1A1F74070100A56CA5 /* RoomMembersRequest.swift */; }; + 80235D221F7442F700A56CA5 /* RoomMembersRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80235D211F7442F700A56CA5 /* RoomMembersRequestSpec.swift */; }; 80235D241F7466FF00A56CA5 /* LoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80235D231F7466FE00A56CA5 /* LoaderTableViewCell.swift */; }; 80235D261F74672D00A56CA5 /* LoaderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 80235D251F74672D00A56CA5 /* LoaderTableViewCell.xib */; }; 80247B3F1FE8582700878833 /* MessageReactionSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80247B3E1FE8582700878833 /* MessageReactionSpec.swift */; }; @@ -498,8 +498,8 @@ 80A2F39020056C5E005D2DCA /* EmojiSearcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A2F38F20056C5E005D2DCA /* EmojiSearcher.swift */; }; 80A2F39220057AD0005D2DCA /* EmojiAutocompleteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A2F39120057AD0005D2DCA /* EmojiAutocompleteCell.swift */; }; 80A2F39420057B48005D2DCA /* EmojiAutocompleteCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 80A2F39320057B48005D2DCA /* EmojiAutocompleteCell.xib */; }; - 80A63C4F1F719F9600FE5AC4 /* SubscriptionInfoRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A63C4E1F719F9600FE5AC4 /* SubscriptionInfoRequest.swift */; }; - 80A63C511F719FB300FE5AC4 /* SubscriptionInfoRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A63C501F719FB300FE5AC4 /* SubscriptionInfoRequestSpec.swift */; }; + 80A63C4F1F719F9600FE5AC4 /* RoomInfoRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A63C4E1F719F9600FE5AC4 /* RoomInfoRequest.swift */; }; + 80A63C511F719FB300FE5AC4 /* RoomInfoRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A63C501F719FB300FE5AC4 /* RoomInfoRequestSpec.swift */; }; 80A63C531F71BD2900FE5AC4 /* UserInfoRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A63C521F71BD2900FE5AC4 /* UserInfoRequest.swift */; }; 80A63C551F71BF3A00FE5AC4 /* UserInfoRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A63C541F71BF3A00FE5AC4 /* UserInfoRequestSpec.swift */; }; 80A63C571F71D2E400FE5AC4 /* APISpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80A63C561F71D2E400FE5AC4 /* APISpec.swift */; }; @@ -553,17 +553,17 @@ 80FA907D2057F4650069038F /* SubmitContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80FA907C2057F4650069038F /* SubmitContent.swift */; }; 80FE8DEE206584EA0099170E /* SEFileDetailView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 80FE8DED206584EA0099170E /* SEFileDetailView.xib */; }; 80FE8DF0206587510099170E /* SEFileDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80FE8DEF206587510099170E /* SEFileDetailView.swift */; }; - 890DA8AE1F942A35007C022B /* SubscriptionCreateRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890DA8AD1F942A35007C022B /* SubscriptionCreateRequestSpec.swift */; }; + 890DA8AE1F942A35007C022B /* RoomCreateRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890DA8AD1F942A35007C022B /* RoomCreateRequestSpec.swift */; }; 897083D31F8CF08100233561 /* CheckTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 897083CE1F8CF08100233561 /* CheckTableViewCell.swift */; }; 897083D41F8CF08100233561 /* CheckTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 897083CF1F8CF08100233561 /* CheckTableViewCell.xib */; }; 897083D51F8CF08100233561 /* TextFieldTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 897083D01F8CF08100233561 /* TextFieldTableViewCell.swift */; }; 897083D61F8CF08100233561 /* TextFieldTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 897083D11F8CF08100233561 /* TextFieldTableViewCell.xib */; }; 897083D71F8CF08100233561 /* FormTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 897083D21F8CF08100233561 /* FormTableViewCell.swift */; }; - 89AEB7F81F7D225D00112A09 /* SubscriptionCreateRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89AEB7F71F7D225D00112A09 /* SubscriptionCreateRequest.swift */; }; + 89AEB7F81F7D225D00112A09 /* RoomCreateRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89AEB7F71F7D225D00112A09 /* RoomCreateRequest.swift */; }; 89AFF3C81F94374D00D07A30 /* NewRoomViewControllerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89AFF3C71F94374D00D07A30 /* NewRoomViewControllerSpec.swift */; }; 990B4B642069DC9900999FE7 /* EditProfileTableViewControllerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 990B4B632069DC9900999FE7 /* EditProfileTableViewControllerSpec.swift */; }; - 990FF6D620740C79007B4A53 /* SubscriptionMentionsRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 990FF6D520740C79007B4A53 /* SubscriptionMentionsRequest.swift */; }; - 990FF6D8207438D4007B4A53 /* SubscriptionMentionsRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 990FF6D7207438D4007B4A53 /* SubscriptionMentionsRequestSpec.swift */; }; + 990FF6D620740C79007B4A53 /* RoomMentionsRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 990FF6D520740C79007B4A53 /* RoomMentionsRequest.swift */; }; + 990FF6D8207438D4007B4A53 /* RoomMentionsRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 990FF6D7207438D4007B4A53 /* RoomMentionsRequestSpec.swift */; }; 9921BFAC2075AF5F00BB027A /* PublicSettingsRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9921BFAB2075AF5F00BB027A /* PublicSettingsRequestSpec.swift */; }; 9928225F204DDC8C005D2067 /* EditProfileViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9928225E204DDC8C005D2067 /* EditProfileViewModel.swift */; }; 993E513A1FB1E18D006403D5 /* DraftMessageManagerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993E51391FB1E18D006403D5 /* DraftMessageManagerSpec.swift */; }; @@ -1021,8 +1021,8 @@ 8020CCF41FEAD8C9003424F4 /* EmojiPickerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPickerController.swift; sourceTree = ""; }; 80213C0A1FDFE35C00809E14 /* UploadMessageRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadMessageRequestSpec.swift; sourceTree = ""; }; 80213C0D1FE0639E00809E14 /* HTTPMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPMethod.swift; sourceTree = ""; }; - 80235D1A1F74070100A56CA5 /* SubscriptionMembersRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionMembersRequest.swift; sourceTree = ""; }; - 80235D211F7442F700A56CA5 /* SubscriptionMembersRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionMembersRequestSpec.swift; sourceTree = ""; }; + 80235D1A1F74070100A56CA5 /* RoomMembersRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembersRequest.swift; sourceTree = ""; }; + 80235D211F7442F700A56CA5 /* RoomMembersRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembersRequestSpec.swift; sourceTree = ""; }; 80235D231F7466FE00A56CA5 /* LoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoaderTableViewCell.swift; sourceTree = ""; }; 80235D251F74672D00A56CA5 /* LoaderTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LoaderTableViewCell.xib; sourceTree = ""; }; 80247B3E1FE8582700878833 /* MessageReactionSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageReactionSpec.swift; sourceTree = ""; }; @@ -1144,8 +1144,8 @@ 80A2F38F20056C5E005D2DCA /* EmojiSearcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiSearcher.swift; sourceTree = ""; }; 80A2F39120057AD0005D2DCA /* EmojiAutocompleteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiAutocompleteCell.swift; sourceTree = ""; }; 80A2F39320057B48005D2DCA /* EmojiAutocompleteCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EmojiAutocompleteCell.xib; sourceTree = ""; }; - 80A63C4E1F719F9600FE5AC4 /* SubscriptionInfoRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionInfoRequest.swift; sourceTree = ""; }; - 80A63C501F719FB300FE5AC4 /* SubscriptionInfoRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionInfoRequestSpec.swift; sourceTree = ""; }; + 80A63C4E1F719F9600FE5AC4 /* RoomInfoRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomInfoRequest.swift; sourceTree = ""; }; + 80A63C501F719FB300FE5AC4 /* RoomInfoRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomInfoRequestSpec.swift; sourceTree = ""; }; 80A63C521F71BD2900FE5AC4 /* UserInfoRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInfoRequest.swift; sourceTree = ""; }; 80A63C541F71BF3A00FE5AC4 /* UserInfoRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInfoRequestSpec.swift; sourceTree = ""; }; 80A63C561F71D2E400FE5AC4 /* APISpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APISpec.swift; sourceTree = ""; }; @@ -1202,17 +1202,17 @@ 848088BA204370E8005022E8 /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/RCEmojiKit.strings; sourceTree = ""; }; 848088BB204370E8005022E8 /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = ""; }; 848088BC204370E9005022E8 /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/VoiceOver.strings; sourceTree = ""; }; - 890DA8AD1F942A35007C022B /* SubscriptionCreateRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionCreateRequestSpec.swift; sourceTree = ""; }; + 890DA8AD1F942A35007C022B /* RoomCreateRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomCreateRequestSpec.swift; sourceTree = ""; }; 897083CE1F8CF08100233561 /* CheckTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckTableViewCell.swift; sourceTree = ""; }; 897083CF1F8CF08100233561 /* CheckTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CheckTableViewCell.xib; sourceTree = ""; }; 897083D01F8CF08100233561 /* TextFieldTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldTableViewCell.swift; sourceTree = ""; }; 897083D11F8CF08100233561 /* TextFieldTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TextFieldTableViewCell.xib; sourceTree = ""; }; 897083D21F8CF08100233561 /* FormTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormTableViewCell.swift; sourceTree = ""; }; - 89AEB7F71F7D225D00112A09 /* SubscriptionCreateRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionCreateRequest.swift; sourceTree = ""; }; + 89AEB7F71F7D225D00112A09 /* RoomCreateRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomCreateRequest.swift; sourceTree = ""; }; 89AFF3C71F94374D00D07A30 /* NewRoomViewControllerSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewRoomViewControllerSpec.swift; sourceTree = ""; }; 990B4B632069DC9900999FE7 /* EditProfileTableViewControllerSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditProfileTableViewControllerSpec.swift; sourceTree = ""; }; - 990FF6D520740C79007B4A53 /* SubscriptionMentionsRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionMentionsRequest.swift; sourceTree = ""; }; - 990FF6D7207438D4007B4A53 /* SubscriptionMentionsRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionMentionsRequestSpec.swift; sourceTree = ""; }; + 990FF6D520740C79007B4A53 /* RoomMentionsRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMentionsRequest.swift; sourceTree = ""; }; + 990FF6D7207438D4007B4A53 /* RoomMentionsRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMentionsRequestSpec.swift; sourceTree = ""; }; 9921BFAB2075AF5F00BB027A /* PublicSettingsRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicSettingsRequestSpec.swift; sourceTree = ""; }; 9928225E204DDC8C005D2067 /* EditProfileViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditProfileViewModel.swift; sourceTree = ""; }; 993E51391FB1E18D006403D5 /* DraftMessageManagerSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DraftMessageManagerSpec.swift; sourceTree = ""; }; @@ -2373,27 +2373,27 @@ path = HTTP; sourceTree = ""; }; - 80235D1C1F740AAC00A56CA5 /* Subscription */ = { + 80235D1C1F740AAC00A56CA5 /* Room */ = { isa = PBXGroup; children = ( - 89AEB7F71F7D225D00112A09 /* SubscriptionCreateRequest.swift */, - 80A63C4E1F719F9600FE5AC4 /* SubscriptionInfoRequest.swift */, - 80235D1A1F74070100A56CA5 /* SubscriptionMembersRequest.swift */, - 990FF6D520740C79007B4A53 /* SubscriptionMentionsRequest.swift */, + 89AEB7F71F7D225D00112A09 /* RoomCreateRequest.swift */, + 80A63C4E1F719F9600FE5AC4 /* RoomInfoRequest.swift */, + 80235D1A1F74070100A56CA5 /* RoomMembersRequest.swift */, + 990FF6D520740C79007B4A53 /* RoomMentionsRequest.swift */, 800E22851F8507E400DA84F1 /* SubscriptionMessagesRequest.swift */, ); - path = Subscription; + path = Room; sourceTree = ""; }; - 80235D201F7442C100A56CA5 /* Subscription */ = { + 80235D201F7442C100A56CA5 /* Room */ = { isa = PBXGroup; children = ( - 890DA8AD1F942A35007C022B /* SubscriptionCreateRequestSpec.swift */, - 80A63C501F719FB300FE5AC4 /* SubscriptionInfoRequestSpec.swift */, - 80235D211F7442F700A56CA5 /* SubscriptionMembersRequestSpec.swift */, - 990FF6D7207438D4007B4A53 /* SubscriptionMentionsRequestSpec.swift */, + 890DA8AD1F942A35007C022B /* RoomCreateRequestSpec.swift */, + 80A63C501F719FB300FE5AC4 /* RoomInfoRequestSpec.swift */, + 80235D211F7442F700A56CA5 /* RoomMembersRequestSpec.swift */, + 990FF6D7207438D4007B4A53 /* RoomMentionsRequestSpec.swift */, ); - path = Subscription; + path = Room; sourceTree = ""; }; 802498EC1F7A82CD005477EC /* Authentication */ = { @@ -2870,7 +2870,7 @@ 9977302820727DA0009AF465 /* Emoji */, 807C7C0A20751F06006B600E /* General */, 806C59A31FBB2F3700C32D0A /* Message */, - 80235D201F7442C100A56CA5 /* Subscription */, + 80235D201F7442C100A56CA5 /* Room */, 998165C8204EBB5E0059D346 /* User */, ); path = Requests; @@ -2902,7 +2902,7 @@ 9977302520725B3A009AF465 /* Emoji */, 80054CFA1FDAFD3A00F5ECF9 /* General */, 806C59A01FBB0BA700C32D0A /* Message */, - 80235D1C1F740AAC00A56CA5 /* Subscription */, + 80235D1C1F740AAC00A56CA5 /* Room */, 99D888F92046239100E51306 /* User */, ); path = Requests; @@ -3582,7 +3582,7 @@ 805DEC351FFC03380033151B /* CustomEmojiManager.swift in Sources */, 0BC0E8632032DD95004BFAAF /* DrawingViewModel.swift in Sources */, 35E892C8201CDD1600B4BE5A /* NewRoomViewController.swift in Sources */, - 990FF6D620740C79007B4A53 /* SubscriptionMentionsRequest.swift in Sources */, + 990FF6D620740C79007B4A53 /* RoomMentionsRequest.swift in Sources */, 416133321D46CA4E00E09DA2 /* ChatMessageCell.swift in Sources */, 806DB94A20695CD0004ED8ED /* AuthViewControllerAuthenticationHandler.swift in Sources */, 8041C0422028C7EF007E21FA /* ReactorListView.swift in Sources */, @@ -3625,7 +3625,7 @@ 4174CB0D1D2D994A0086DAC8 /* ConnectServerViewController.swift in Sources */, 4199A9891DABCC570035F820 /* Emojione.swift in Sources */, 418C74431FA3813F00499577 /* CompoundPickerViewDelegate.swift in Sources */, - 80235D1B1F74070100A56CA5 /* SubscriptionMembersRequest.swift in Sources */, + 80235D1B1F74070100A56CA5 /* RoomMembersRequest.swift in Sources */, 41A1748C1DD9F2F900188E3B /* UIViewControllerExtension.swift in Sources */, 3330329A20738E1500A9514D /* SubscriptionManagerRooms.swift in Sources */, 8020CCF51FEAD8C9003424F4 /* EmojiPickerController.swift in Sources */, @@ -3785,7 +3785,7 @@ 41900C271D9FE35400308EF4 /* Attachment.swift in Sources */, 999483EB20644CC4004F61CA /* WebBrowserViewModel.swift in Sources */, 41499C911F2A1A7200790EA7 /* TimestampCoordinator.swift in Sources */, - 80A63C4F1F719F9600FE5AC4 /* SubscriptionInfoRequest.swift in Sources */, + 80A63C4F1F719F9600FE5AC4 /* RoomInfoRequest.swift in Sources */, D3CFAFBD1E907D8900BADC0A /* ChatMessageTextViewModel.swift in Sources */, D1D535F11F70864C006625D2 /* InfoRequest.swift in Sources */, 411D76E51F39F05A00B0A8DF /* AuthSettingsManager.swift in Sources */, @@ -3832,7 +3832,7 @@ 80DC9A6C206BA95600032BE0 /* Localized.swift in Sources */, 14A6A83120421DF8008C210D /* ColorPickerView.swift in Sources */, 8013F88E1FD6B83C00EE1A4E /* CommandModelMapping.swift in Sources */, - 89AEB7F81F7D225D00112A09 /* SubscriptionCreateRequest.swift in Sources */, + 89AEB7F81F7D225D00112A09 /* RoomCreateRequest.swift in Sources */, 807C7C12207522EF006B600E /* LoginServicesRequest.swift in Sources */, 80B3DC0B202DCE1D004249AD /* SAMLViewController.swift in Sources */, 8067DA9B206BC71A005E3369 /* ReactMessageRequest.swift in Sources */, @@ -3861,8 +3861,8 @@ 41DC7A241D386CA800896FC0 /* DateExtensionsSpec.swift in Sources */, 41552F681D3035D80081438D /* SocketManagerSpec.swift in Sources */, 807A8F6B1F9E4D0C00CC78DB /* OAuthManagerSpec.swift in Sources */, - 890DA8AE1F942A35007C022B /* SubscriptionCreateRequestSpec.swift in Sources */, - 80235D221F7442F700A56CA5 /* SubscriptionMembersRequestSpec.swift in Sources */, + 890DA8AE1F942A35007C022B /* RoomCreateRequestSpec.swift in Sources */, + 80235D221F7442F700A56CA5 /* RoomMembersRequestSpec.swift in Sources */, 8013F8791FD6B63200EE1A4E /* VersionMiddlewareSpec.swift in Sources */, 41F8487E1FA38B0A00C9AE84 /* PreferencesViewModelSpec.swift in Sources */, 41E9BD0F208EA8C40084D4D8 /* SubscriptionQueriesSpec.swift in Sources */, @@ -3923,7 +3923,7 @@ 411119B81F6825C30019854B /* NetworkManagerSpec.swift in Sources */, 99F41BD020658C3400B240FC /* NewPasswordViewModelSpec.swift in Sources */, 416296F91F41B42B00BCCEDD /* UploadHelperSpec.swift in Sources */, - 80A63C511F719FB300FE5AC4 /* SubscriptionInfoRequestSpec.swift in Sources */, + 80A63C511F719FB300FE5AC4 /* RoomInfoRequestSpec.swift in Sources */, 41FE55531F6038D60071E97A /* DatabaseManagerSpec.swift in Sources */, 416296FC1F41D42800BCCEDD /* DownloadManagerSpec.swift in Sources */, 8013F8811FD6B6C600EE1A4E /* CommandsClientSpec.swift in Sources */, @@ -3934,7 +3934,7 @@ 807FB53F2045F36E00E21429 /* EmojioneSpec.swift in Sources */, 140C84ED1FC9DBAF00032A59 /* MentionsTextFieldTableViewCellSpec.swift in Sources */, 33093DC9207C949C00DD81F6 /* NotificationViewControllerSpec.swift in Sources */, - 990FF6D8207438D4007B4A53 /* SubscriptionMentionsRequestSpec.swift in Sources */, + 990FF6D8207438D4007B4A53 /* RoomMentionsRequestSpec.swift in Sources */, 8073719C1F963FA400D53ADF /* APITestCase.swift in Sources */, 416133381D46DB1D00E09DA2 /* BaseModelSpec.swift in Sources */, 89AFF3C81F94374D00D07A30 /* NewRoomViewControllerSpec.swift in Sources */, diff --git a/Rocket.Chat/API/Requests/Subscription/SubscriptionCreateRequest.swift b/Rocket.Chat/API/Requests/Room/RoomCreateRequest.swift similarity index 79% rename from Rocket.Chat/API/Requests/Subscription/SubscriptionCreateRequest.swift rename to Rocket.Chat/API/Requests/Room/RoomCreateRequest.swift index 3242371b5b..c95099ccb9 100644 --- a/Rocket.Chat/API/Requests/Subscription/SubscriptionCreateRequest.swift +++ b/Rocket.Chat/API/Requests/Room/RoomCreateRequest.swift @@ -1,5 +1,5 @@ // -// SubscriptionCreateRequest.swift +// RoomCreateRequest.swift // Rocket.Chat // // Created by Bruno Macabeus Aquino on 28/09/17. @@ -11,7 +11,7 @@ import Foundation -enum SubscriptionCreateType { +enum RoomCreateType { case channel case group @@ -25,8 +25,8 @@ enum SubscriptionCreateType { } } -final class SubscriptionCreateRequest: APIRequest { - typealias APIResourceType = SubscriptionCreateResource +final class RoomCreateRequest: APIRequest { + typealias APIResourceType = RoomCreateResource let method: HTTPMethod = .post var path: String { @@ -34,11 +34,11 @@ final class SubscriptionCreateRequest: APIRequest { } let name: String - let type: SubscriptionCreateType + let type: RoomCreateType let members: [String] let readOnly: Bool - init(name: String, type: SubscriptionCreateType, members: [String] = [], readOnly: Bool = false) { + init(name: String, type: RoomCreateType, members: [String] = [], readOnly: Bool = false) { self.name = name self.type = type self.members = members @@ -56,7 +56,7 @@ final class SubscriptionCreateRequest: APIRequest { } } -class SubscriptionCreateResource: APIResource { +class RoomCreateResource: APIResource { var success: Bool? { return raw?["success"].boolValue } diff --git a/Rocket.Chat/API/Requests/Subscription/SubscriptionInfoRequest.swift b/Rocket.Chat/API/Requests/Room/RoomInfoRequest.swift similarity index 86% rename from Rocket.Chat/API/Requests/Subscription/SubscriptionInfoRequest.swift rename to Rocket.Chat/API/Requests/Room/RoomInfoRequest.swift index 6e91d824f7..9aa7ba6821 100644 --- a/Rocket.Chat/API/Requests/Subscription/SubscriptionInfoRequest.swift +++ b/Rocket.Chat/API/Requests/Room/RoomInfoRequest.swift @@ -1,5 +1,5 @@ // -// SubscriptionInfoRequest.swift +// RoomInfoRequest.swift // Rocket.Chat // // Created by Matheus Cardoso on 9/19/17. @@ -22,8 +22,8 @@ fileprivate extension SubscriptionType { } } -final class SubscriptionInfoRequest: APIRequest { - typealias APIResourceType = SubscriptionInfoResource +final class RoomInfoRequest: APIRequest { + typealias APIResourceType = RoomInfoResource var path: String { return type.path @@ -50,7 +50,7 @@ final class SubscriptionInfoRequest: APIRequest { } } -final class SubscriptionInfoResource: APIResource { +final class RoomInfoResource: APIResource { var channel: JSON? { return raw?["channel"] } diff --git a/Rocket.Chat/API/Requests/Subscription/SubscriptionMembersRequest.swift b/Rocket.Chat/API/Requests/Room/RoomMembersRequest.swift similarity index 87% rename from Rocket.Chat/API/Requests/Subscription/SubscriptionMembersRequest.swift rename to Rocket.Chat/API/Requests/Room/RoomMembersRequest.swift index ac6a242166..8f8e1c944e 100644 --- a/Rocket.Chat/API/Requests/Subscription/SubscriptionMembersRequest.swift +++ b/Rocket.Chat/API/Requests/Room/RoomMembersRequest.swift @@ -1,5 +1,5 @@ // -// SubscriptionMembersRequest.swift +// RoomMembersRequest.swift // Rocket.Chat // // Created by Matheus Cardoso on 9/21/17. @@ -22,8 +22,8 @@ fileprivate extension SubscriptionType { } } -final class SubscriptionMembersRequest: APIRequest { - typealias APIResourceType = SubscriptionMembersResource +final class RoomMembersRequest: APIRequest { + typealias APIResourceType = RoomMembersResource let requiredVersion = Version(0, 59, 0) @@ -52,7 +52,7 @@ final class SubscriptionMembersRequest: APIRequest { } } -class SubscriptionMembersResource: APIResource { +class RoomMembersResource: APIResource { var members: [User?]? { return raw?["members"].arrayValue.map { let user = User() diff --git a/Rocket.Chat/API/Requests/Subscription/SubscriptionMentionsRequest.swift b/Rocket.Chat/API/Requests/Room/RoomMentionsRequest.swift similarity index 82% rename from Rocket.Chat/API/Requests/Subscription/SubscriptionMentionsRequest.swift rename to Rocket.Chat/API/Requests/Room/RoomMentionsRequest.swift index 6e6d748e60..a4931f7042 100644 --- a/Rocket.Chat/API/Requests/Subscription/SubscriptionMentionsRequest.swift +++ b/Rocket.Chat/API/Requests/Room/RoomMentionsRequest.swift @@ -1,5 +1,5 @@ // -// SubscriptionMentionsRequest.swift +// RoomMentionsRequest.swift // Rocket.Chat // // Created by Filipe Alvarenga on 03/04/18. @@ -9,8 +9,8 @@ import SwiftyJSON import Foundation -final class SubscriptionMentionsRequest: APIRequest { - typealias APIResourceType = SubscriptionMentionsResource +final class RoomMentionsRequest: APIRequest { + typealias APIResourceType = RoomMentionsResource let requiredVersion = Version(0, 63, 0) let path = "/api/v1/channels.getAllUserMentionsByChannel" @@ -24,7 +24,7 @@ final class SubscriptionMentionsRequest: APIRequest { } } -final class SubscriptionMentionsResource: APIResource { +final class RoomMentionsResource: APIResource { var messages: [Message]? { return raw?["mentions"].arrayValue.map { let message = Message() diff --git a/Rocket.Chat/API/Requests/Subscription/SubscriptionMessagesRequest.swift b/Rocket.Chat/API/Requests/Room/SubscriptionMessagesRequest.swift similarity index 88% rename from Rocket.Chat/API/Requests/Subscription/SubscriptionMessagesRequest.swift rename to Rocket.Chat/API/Requests/Room/SubscriptionMessagesRequest.swift index 878d32e494..2aea714fe6 100644 --- a/Rocket.Chat/API/Requests/Subscription/SubscriptionMessagesRequest.swift +++ b/Rocket.Chat/API/Requests/Room/SubscriptionMessagesRequest.swift @@ -1,5 +1,5 @@ // -// SubscriptionMessagesRequest.swift +// RoomMessagesRequest.swift // Rocket.Chat // // Created by Matheus Cardoso on 9/21/17. @@ -22,8 +22,8 @@ fileprivate extension SubscriptionType { } } -final class SubscriptionMessagesRequest: APIRequest { - typealias APIResourceType = SubscriptionMessagesResource +final class RoomMessagesRequest: APIRequest { + typealias APIResourceType = RoomMessagesResource var path: String { return type.path @@ -60,7 +60,7 @@ final class SubscriptionMessagesRequest: APIRequest { } } -final class SubscriptionMessagesResource: APIResource { +final class RoomMessagesResource: APIResource { var messages: [Message?]? { return raw?["messages"].arrayValue.map { let message = Message() diff --git a/Rocket.Chat/Controllers/Chat/MembersListViewController.swift b/Rocket.Chat/Controllers/Chat/MembersListViewController.swift index 3f4182e93c..6df56c0225 100644 --- a/Rocket.Chat/Controllers/Chat/MembersListViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MembersListViewController.swift @@ -39,7 +39,7 @@ class MembersListViewData { if let subscription = subscription { isLoadingMoreMembers = true - let request = SubscriptionMembersRequest(roomId: subscription.rid, type: subscription.type) + let request = RoomMembersRequest(roomId: subscription.rid, type: subscription.type) let options = APIRequestOptions.paginated(count: pageSize, offset: currentPage*pageSize) API.current()?.fetch(request, options: options) { [weak self] response in diff --git a/Rocket.Chat/Controllers/Chat/MessagesListViewController.swift b/Rocket.Chat/Controllers/Chat/MessagesListViewController.swift index 4a42ecb8c0..6eea1be70b 100644 --- a/Rocket.Chat/Controllers/Chat/MessagesListViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MessagesListViewController.swift @@ -9,7 +9,7 @@ import UIKit import RealmSwift -extension SubscriptionMessagesResource { +extension RoomMessagesResource { func fetchMessagesFromRealm() -> [Message]? { let realm = Realm.current return raw?["messages"].arrayValue.map { json in @@ -20,7 +20,7 @@ extension SubscriptionMessagesResource { } } -extension SubscriptionMentionsResource { +extension RoomMentionsResource { func fetchMessagesFromRealm() -> [Message]? { let realm = Realm.current return raw?["mentions"].arrayValue.map { json in @@ -110,7 +110,7 @@ class MessagesListViewData { isLoadingMoreMessages = true let options = APIRequestOptions.paginated(count: pageSize, offset: currentPage*pageSize) - let request = SubscriptionMessagesRequest(roomId: subscription.rid, type: subscription.type, query: query) + let request = RoomMessagesRequest(roomId: subscription.rid, type: subscription.type, query: query) API.current()?.fetch(request, options: options) { [weak self] response in switch response { case .resource(let resource): @@ -131,7 +131,7 @@ class MessagesListViewData { isLoadingMoreMessages = true let options = APIRequestOptions.paginated(count: pageSize, offset: currentPage*pageSize) - let request = SubscriptionMentionsRequest(roomId: subscription.rid) + let request = RoomMentionsRequest(roomId: subscription.rid) API.current()?.fetch(request, options: options) { [weak self] response in switch response { case .resource(let resource): diff --git a/Rocket.Chat/Controllers/Subscriptions/NewRoomViewController.swift b/Rocket.Chat/Controllers/Subscriptions/NewRoomViewController.swift index 5a63057d0c..c621f1aa9f 100644 --- a/Rocket.Chat/Controllers/Subscriptions/NewRoomViewController.swift +++ b/Rocket.Chat/Controllers/Subscriptions/NewRoomViewController.swift @@ -139,7 +139,7 @@ class NewRoomViewController: BaseViewController { return } - let roomType: SubscriptionCreateType + let roomType: RoomCreateType if publicRoom { roomType = .channel } else { @@ -158,9 +158,9 @@ class NewRoomViewController: BaseViewController { } } - fileprivate func executeRequestCreateRoom(roomName: String, roomType: SubscriptionCreateType, members: [String], readOnlyRoom: Bool, completion: @escaping (Bool, String?) -> Void) { + fileprivate func executeRequestCreateRoom(roomName: String, roomType: RoomCreateType, members: [String], readOnlyRoom: Bool, completion: @escaping (Bool, String?) -> Void) { - let request = SubscriptionCreateRequest( + let request = RoomCreateRequest( name: roomName, type: roomType, members: members, diff --git a/Rocket.Chat/Managers/AppManager.swift b/Rocket.Chat/Managers/AppManager.swift index bd7e778a7f..09dd46a001 100644 --- a/Rocket.Chat/Managers/AppManager.swift +++ b/Rocket.Chat/Managers/AppManager.swift @@ -170,7 +170,7 @@ extension AppManager { // If not, fetch it let currentRealm = Realm.current - let request = SubscriptionInfoRequest(roomName: name) + let request = RoomInfoRequest(roomName: name) API.current()?.fetch(request) { response in switch response { case .resource(let resource): diff --git a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionCreateRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomCreateRequestSpec.swift similarity index 90% rename from Rocket.ChatTests/API/Requests/Subscription/SubscriptionCreateRequestSpec.swift rename to Rocket.ChatTests/API/Requests/Room/RoomCreateRequestSpec.swift index ea4524b08e..9a25064791 100644 --- a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionCreateRequestSpec.swift +++ b/Rocket.ChatTests/API/Requests/Room/RoomCreateRequestSpec.swift @@ -11,13 +11,13 @@ import SwiftyJSON @testable import Rocket_Chat -class SubscriptionCreateRequestSpec: APITestCase { +class RoomCreateRequestSpec: APITestCase { func testRequest() { let paramRoomName = "foo" let paramReadOnly = false let paramMembers = ["example"] - let preRequest = SubscriptionCreateRequest( + let preRequest = RoomCreateRequest( name: paramRoomName, type: .channel, members: paramMembers, @@ -41,7 +41,7 @@ class SubscriptionCreateRequestSpec: APITestCase { XCTAssertEqual(bodyJson["members"].array?.first?.string, paramMembers.first, "parameter members is correct") XCTAssertEqual(bodyJson["readOnly"].bool, paramReadOnly, "read only was set as false") - let preRequestGroup = SubscriptionCreateRequest( + let preRequestGroup = RoomCreateRequest( name: paramRoomName, type: .group, readOnly: paramReadOnly @@ -81,8 +81,8 @@ class SubscriptionCreateRequestSpec: APITestCase { ] ]) - let result = SubscriptionCreateResource(raw: mockResult) - let resultPrivate = SubscriptionCreateResource(raw: mockResultPrivate) + let result = RoomCreateResource(raw: mockResult) + let resultPrivate = RoomCreateResource(raw: mockResultPrivate) XCTAssertEqual(result.success, true, "success is correct") XCTAssertEqual(result.error, "error-test", "error is correct") diff --git a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionInfoRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomInfoRequestSpec.swift similarity index 87% rename from Rocket.ChatTests/API/Requests/Subscription/SubscriptionInfoRequestSpec.swift rename to Rocket.ChatTests/API/Requests/Room/RoomInfoRequestSpec.swift index 4a18879ba2..1969555fb8 100644 --- a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionInfoRequestSpec.swift +++ b/Rocket.ChatTests/API/Requests/Room/RoomInfoRequestSpec.swift @@ -1,5 +1,5 @@ // -// SubscriptionInfoRequestSpec.swift +// RoomInfoRequestSpec.swift // Rocket.ChatTests // // Created by Matheus Cardoso on 9/19/17. @@ -11,9 +11,9 @@ import SwiftyJSON @testable import Rocket_Chat -class SubscriptionInfoRequestSpec: APITestCase { +class RoomInfoRequestSpec: APITestCase { func testRequestWithRoomId() { - let preRequest = SubscriptionInfoRequest(roomId: "ByehQjC44FwMeiLbX") + let preRequest = RoomInfoRequest(roomId: "ByehQjC44FwMeiLbX") guard let request = preRequest.request(for: api) else { return XCTFail("request is not nil") } @@ -26,7 +26,7 @@ class SubscriptionInfoRequestSpec: APITestCase { } func testRequestWithRoomName() { - let preRequest = SubscriptionInfoRequest(roomName: "testing") + let preRequest = RoomInfoRequest(roomName: "testing") guard let request = preRequest.request(for: api) else { return XCTFail("request is not nil") } @@ -62,7 +62,7 @@ class SubscriptionInfoRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) - let result = SubscriptionInfoResource(raw: json) + let result = RoomInfoResource(raw: json) XCTAssertEqual(result.channel, json["channel"]) XCTAssertEqual(result.usernames ?? [], ["testing", "testing1", "testing2"]) diff --git a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionMembersRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift similarity index 88% rename from Rocket.ChatTests/API/Requests/Subscription/SubscriptionMembersRequestSpec.swift rename to Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift index cfd37d8010..c4dae0b122 100644 --- a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionMembersRequestSpec.swift +++ b/Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift @@ -1,5 +1,5 @@ // -// SubscriptionMembersRequestSpec.swift +// RoomMembersRequestSpec.swift // Rocket.ChatTests // // Created by Matheus Cardoso on 9/21/17. @@ -11,9 +11,9 @@ import SwiftyJSON @testable import Rocket_Chat -class SubscriptionMembersRequestSpec: APITestCase { +class RoomMembersRequestSpec: APITestCase { func testRequestWithRoomId() { - let preRequest = SubscriptionMembersRequest(roomId: "ByehQjC44FwMeiLbX") + let preRequest = RoomMembersRequest(roomId: "ByehQjC44FwMeiLbX") guard let request = preRequest.request(for: api, options: .paginated(count: 20, offset: 100)) else { return XCTFail("request is not nil") } @@ -26,7 +26,7 @@ class SubscriptionMembersRequestSpec: APITestCase { } func testRequestWithRoomName() { - let preRequest = SubscriptionMembersRequest(roomName: "testing") + let preRequest = RoomMembersRequest(roomName: "testing") guard let request = preRequest.request(for: api, options: .paginated(count: 20, offset: 100)) else { return XCTFail("request is not nil") } @@ -66,7 +66,7 @@ class SubscriptionMembersRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) - let result = SubscriptionMembersResource(raw: json) + let result = RoomMembersResource(raw: json) XCTAssertEqual(result.members?.count, json["members"].count, "members is correct") XCTAssertEqual(result.count, 2, "count is correct") diff --git a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionMentionsRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomMentionsRequestSpec.swift similarity index 90% rename from Rocket.ChatTests/API/Requests/Subscription/SubscriptionMentionsRequestSpec.swift rename to Rocket.ChatTests/API/Requests/Room/RoomMentionsRequestSpec.swift index bf0ba3fbf7..1a3823247a 100644 --- a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionMentionsRequestSpec.swift +++ b/Rocket.ChatTests/API/Requests/Room/RoomMentionsRequestSpec.swift @@ -1,5 +1,5 @@ // -// SubscriptionMentionsRequestSpec.swift +// RoomMentionsRequestSpec.swift // Rocket.ChatTests // // Created by Filipe Alvarenga on 03/04/18. @@ -11,10 +11,10 @@ import SwiftyJSON @testable import Rocket_Chat -class SubscriptionMentionsRequestSpec: APISpec { +class RoomMentionsRequestSpec: APISpec { func testRequest() { - let preRequest = SubscriptionMentionsRequest(roomId: "xyz123") + let preRequest = RoomMentionsRequest(roomId: "xyz123") guard let request = preRequest.request(for: api) else { return XCTFail("request is not nil") } @@ -83,14 +83,14 @@ class SubscriptionMentionsRequestSpec: APISpec { let json = JSON(parseJSON: jsonString) - let result = SubscriptionMentionsResource(raw: json) + let result = RoomMentionsResource(raw: json) XCTAssertNotNil(result.messages) XCTAssertEqual(result.count, 2) XCTAssertEqual(result.offset, 10) XCTAssertEqual(result.total, 2) XCTAssertTrue(result.success) - let nilResult = SubscriptionMentionsResource(raw: nil) + let nilResult = RoomMentionsResource(raw: nil) XCTAssertNil(nilResult.messages) } From ddc02768e19ef0ec88564bdf18851ad545b5972d Mon Sep 17 00:00:00 2001 From: cardoso Date: Wed, 16 May 2018 18:53:23 -0300 Subject: [PATCH 02/17] Update tests --- Rocket.Chat.xcodeproj/project.pbxproj | 28 +++++++++---------- .../RoomFilesRequestSpec.swift} | 10 +++---- .../Room/RoomMembersRequestSpec.swift | 10 ------- .../RoomRolesRequestSpec.swift} | 18 ++++++------ 4 files changed, 28 insertions(+), 38 deletions(-) rename Rocket.ChatTests/API/Requests/{Subscription/SubscriptionFilesRequestSpec.swift => Room/RoomFilesRequestSpec.swift} (89%) rename Rocket.ChatTests/API/Requests/{Subscription/SubscriptionRolesRequestSpec.swift => Room/RoomRolesRequestSpec.swift} (91%) diff --git a/Rocket.Chat.xcodeproj/project.pbxproj b/Rocket.Chat.xcodeproj/project.pbxproj index 46a44a083c..6d4c702698 100644 --- a/Rocket.Chat.xcodeproj/project.pbxproj +++ b/Rocket.Chat.xcodeproj/project.pbxproj @@ -263,7 +263,7 @@ 41D4ABAB1F4CD10C00ACDDDD /* ChatCollectionViewFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D4ABAA1F4CD10C00ACDDDD /* ChatCollectionViewFlowLayout.swift */; }; 41D51B0620A62DD60073E8E7 /* Role.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D51B0520A62DD60073E8E7 /* Role.swift */; }; 41D51B0720A62DD60073E8E7 /* Role.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D51B0520A62DD60073E8E7 /* Role.swift */; }; - 41D51B0920A635150073E8E7 /* SubscriptionRolesRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D51B0820A635150073E8E7 /* SubscriptionRolesRequestSpec.swift */; }; + 41D51B0920A635150073E8E7 /* RoomRolesRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D51B0820A635150073E8E7 /* RoomRolesRequestSpec.swift */; }; 41D5BC311DAFBEF4009A493A /* UIViewExtentions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D5BC301DAFBEF4009A493A /* UIViewExtentions.swift */; }; 41D701D61E67111E00FED2EE /* MessageTextFontAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D701D51E67111E00FED2EE /* MessageTextFontAttributes.swift */; }; 41D701D81E6763D100FED2EE /* NSAttributedStringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D701D71E6763D100FED2EE /* NSAttributedStringExtensions.swift */; }; @@ -595,7 +595,7 @@ 9921BFAC2075AF5F00BB027A /* PublicSettingsRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9921BFAB2075AF5F00BB027A /* PublicSettingsRequestSpec.swift */; }; 9928225F204DDC8C005D2067 /* EditProfileViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9928225E204DDC8C005D2067 /* EditProfileViewModel.swift */; }; 992B5AB6209A14B5009C8123 /* AudioFileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 992B5AB5209A14B5009C8123 /* AudioFileViewController.swift */; }; - 992B5AB8209A2890009C8123 /* SubscriptionFilesRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 992B5AB7209A2890009C8123 /* SubscriptionFilesRequestSpec.swift */; }; + 992B5AB8209A2890009C8123 /* RoomFilesRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 992B5AB7209A2890009C8123 /* RoomFilesRequestSpec.swift */; }; 993E513A1FB1E18D006403D5 /* DraftMessageManagerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993E51391FB1E18D006403D5 /* DraftMessageManagerSpec.swift */; }; 994D1EDF205AB945007F29C8 /* UINavigationControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 994D1EDE205AB945007F29C8 /* UINavigationControllerExtension.swift */; }; 994DA2B020653FB600083FB8 /* WebBrowserManagerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 994DA2AF20653FB600083FB8 /* WebBrowserManagerSpec.swift */; }; @@ -953,7 +953,7 @@ 41D3A62F1E0805490011949D /* ChatMessageDaySeparator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatMessageDaySeparator.swift; sourceTree = ""; }; 41D4ABAA1F4CD10C00ACDDDD /* ChatCollectionViewFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatCollectionViewFlowLayout.swift; sourceTree = ""; }; 41D51B0520A62DD60073E8E7 /* Role.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Role.swift; sourceTree = ""; }; - 41D51B0820A635150073E8E7 /* SubscriptionRolesRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionRolesRequestSpec.swift; sourceTree = ""; }; + 41D51B0820A635150073E8E7 /* RoomRolesRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomRolesRequestSpec.swift; sourceTree = ""; }; 41D5BC301DAFBEF4009A493A /* UIViewExtentions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewExtentions.swift; sourceTree = ""; }; 41D701D51E67111E00FED2EE /* MessageTextFontAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageTextFontAttributes.swift; sourceTree = ""; }; 41D701D71E6763D100FED2EE /* NSAttributedStringExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSAttributedStringExtensions.swift; sourceTree = ""; }; @@ -1279,7 +1279,7 @@ 9921BFAB2075AF5F00BB027A /* PublicSettingsRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicSettingsRequestSpec.swift; sourceTree = ""; }; 9928225E204DDC8C005D2067 /* EditProfileViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditProfileViewModel.swift; sourceTree = ""; }; 992B5AB5209A14B5009C8123 /* AudioFileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioFileViewController.swift; sourceTree = ""; }; - 992B5AB7209A2890009C8123 /* SubscriptionFilesRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionFilesRequestSpec.swift; sourceTree = ""; }; + 992B5AB7209A2890009C8123 /* RoomFilesRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomFilesRequestSpec.swift; sourceTree = ""; }; 993E51391FB1E18D006403D5 /* DraftMessageManagerSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DraftMessageManagerSpec.swift; sourceTree = ""; }; 994D1EDE205AB945007F29C8 /* UINavigationControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UINavigationControllerExtension.swift; sourceTree = ""; }; 994DA2AF20653FB600083FB8 /* WebBrowserManagerSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebBrowserManagerSpec.swift; sourceTree = ""; }; @@ -2478,14 +2478,13 @@ 80235D201F7442C100A56CA5 /* Room */ = { isa = PBXGroup; children = ( + 8062E33020A3A2BB0044F407 /* RoomsRequestSpec.swift */, 890DA8AD1F942A35007C022B /* RoomCreateRequestSpec.swift */, 80A63C501F719FB300FE5AC4 /* RoomInfoRequestSpec.swift */, 80235D211F7442F700A56CA5 /* RoomMembersRequestSpec.swift */, 990FF6D7207438D4007B4A53 /* RoomMentionsRequestSpec.swift */, - 992B5AB7209A2890009C8123 /* SubscriptionFilesRequestSpec.swift */, - 80E9DBD7209CB06000A48CA9 /* SubscriptionReadRequestSpec.swift */, - 41D51B0820A635150073E8E7 /* SubscriptionRolesRequestSpec.swift */, - 8062E32D20A366360044F407 /* SubscriptionsRequestSpec.swift */, + 992B5AB7209A2890009C8123 /* RoomFilesRequestSpec.swift */, + 41D51B0820A635150073E8E7 /* RoomRolesRequestSpec.swift */, ); path = Room; sourceTree = ""; @@ -2517,12 +2516,13 @@ path = VoiceOver; sourceTree = ""; }; - 8062E32F20A3A2A30044F407 /* Room */ = { + 8062E32F20A3A2A30044F407 /* Subscription */ = { isa = PBXGroup; children = ( - 8062E33020A3A2BB0044F407 /* RoomsRequestSpec.swift */, + 80E9DBD7209CB06000A48CA9 /* SubscriptionReadRequestSpec.swift */, + 8062E32D20A366360044F407 /* SubscriptionsRequestSpec.swift */, ); - path = Room; + path = Subscription; sourceTree = ""; }; 806C2ACE206BBAF200EE5F67 /* External */ = { @@ -3005,7 +3005,7 @@ 807C7C0A20751F06006B600E /* General */, 806C59A31FBB2F3700C32D0A /* Message */, 80235D201F7442C100A56CA5 /* Room */, - 8062E32F20A3A2A30044F407 /* Room */, + 8062E32F20A3A2A30044F407 /* Subscription */, 998165C8204EBB5E0059D346 /* User */, ); path = Requests; @@ -4007,7 +4007,7 @@ 77C2612E1F97453600724A1F /* TextFieldSpec.swift in Sources */, 4171ABA51E7C056E009FC3F0 /* AvatarViewSpec.swift in Sources */, 994DA2B32065486D00083FB8 /* WebBrowserViewModelSpec.swift in Sources */, - 41D51B0920A635150073E8E7 /* SubscriptionRolesRequestSpec.swift in Sources */, + 41D51B0920A635150073E8E7 /* RoomRolesRequestSpec.swift in Sources */, 805DEC391FFE54820033151B /* CustomEmojiSpec.swift in Sources */, D18675EA1F70A58B00406FB4 /* InfoRequestSpec.swift in Sources */, 808792361FB145B200EFE77F /* PermissionManagerSpec.swift in Sources */, @@ -4054,7 +4054,7 @@ 998165CA204EBBA10059D346 /* UpdateUserRequestSpec.swift in Sources */, 33093DC5207C7EAF00DD81F6 /* ChatNotificationSpec.swift in Sources */, 9977302A20727E17009AF465 /* CustomEmojiRequestSpec.swift in Sources */, - 992B5AB8209A2890009C8123 /* SubscriptionFilesRequestSpec.swift in Sources */, + 992B5AB8209A2890009C8123 /* RoomFilesRequestSpec.swift in Sources */, 807A8F671F9E3D4F00CC78DB /* LoginServiceSpec.swift in Sources */, 4161333A1D46E0A200E09DA2 /* AuthSpec.swift in Sources */, 990B4B642069DC9900999FE7 /* EditProfileTableViewControllerSpec.swift in Sources */, diff --git a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionFilesRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomFilesRequestSpec.swift similarity index 89% rename from Rocket.ChatTests/API/Requests/Subscription/SubscriptionFilesRequestSpec.swift rename to Rocket.ChatTests/API/Requests/Room/RoomFilesRequestSpec.swift index c7a6fb60ea..bf80704cb9 100644 --- a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionFilesRequestSpec.swift +++ b/Rocket.ChatTests/API/Requests/Room/RoomFilesRequestSpec.swift @@ -1,5 +1,5 @@ // -// SubscriptionFilesRequestSpec.swift +// RoomFilesRequestSpec.swift // Rocket.ChatTests // // Created by Filipe Alvarenga on 02/05/18. @@ -11,10 +11,10 @@ import SwiftyJSON @testable import Rocket_Chat -class SubscriptionFilesRequestSpec: APITestCase { +class RoomFilesRequestSpec: APITestCase { func testRequest() { - let preRequest = SubscriptionFilesRequest(roomId: "xyz123", subscriptionType: .channel) + let preRequest = RoomFilesRequest(roomId: "xyz123", subscriptionType: .channel) guard let request = preRequest.request(for: api) else { return XCTFail("request is not nil") } @@ -71,14 +71,14 @@ class SubscriptionFilesRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) - let result = SubscriptionFilesResource(raw: json) + let result = RoomFilesResource(raw: json) XCTAssertNotNil(result.files) XCTAssertEqual(result.count, 1) XCTAssertEqual(result.offset, 0) XCTAssertEqual(result.total, 1) XCTAssertTrue(result.success) - let nilResult = SubscriptionFilesResource(raw: nil) + let nilResult = RoomFilesResource(raw: nil) XCTAssertNil(nilResult.files) } diff --git a/Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift index 152a90fcd4..3148769acc 100644 --- a/Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift +++ b/Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift @@ -13,13 +13,8 @@ import SwiftyJSON class RoomMembersRequestSpec: APITestCase { func testRequestWithRoomId() { -<<<<<<< HEAD:Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift let preRequest = RoomMembersRequest(roomId: "ByehQjC44FwMeiLbX") - guard let request = preRequest.request(for: api, options: .paginated(count: 20, offset: 100)) else { -======= - let preRequest = SubscriptionMembersRequest(roomId: "ByehQjC44FwMeiLbX") guard let request = preRequest.request(for: api, options: [.paginated(count: 20, offset: 100)]) else { ->>>>>>> 64469aa7435e64208ad8f7e9b8c2d5b4c5ac7eaa:Rocket.ChatTests/API/Requests/Subscription/SubscriptionMembersRequestSpec.swift return XCTFail("request is not nil") } let url = api.host.appendingPathComponent(preRequest.path) @@ -31,13 +26,8 @@ class RoomMembersRequestSpec: APITestCase { } func testRequestWithRoomName() { -<<<<<<< HEAD:Rocket.ChatTests/API/Requests/Room/RoomMembersRequestSpec.swift let preRequest = RoomMembersRequest(roomName: "testing") - guard let request = preRequest.request(for: api, options: .paginated(count: 20, offset: 100)) else { -======= - let preRequest = SubscriptionMembersRequest(roomName: "testing") guard let request = preRequest.request(for: api, options: [.paginated(count: 20, offset: 100)]) else { ->>>>>>> 64469aa7435e64208ad8f7e9b8c2d5b4c5ac7eaa:Rocket.ChatTests/API/Requests/Subscription/SubscriptionMembersRequestSpec.swift return XCTFail("request is not nil") } let url = api.host.appendingPathComponent(preRequest.path) diff --git a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionRolesRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomRolesRequestSpec.swift similarity index 91% rename from Rocket.ChatTests/API/Requests/Subscription/SubscriptionRolesRequestSpec.swift rename to Rocket.ChatTests/API/Requests/Room/RoomRolesRequestSpec.swift index 18016afb76..1510b6af51 100644 --- a/Rocket.ChatTests/API/Requests/Subscription/SubscriptionRolesRequestSpec.swift +++ b/Rocket.ChatTests/API/Requests/Room/RoomRolesRequestSpec.swift @@ -1,5 +1,5 @@ // -// SubscriptionRolesRequestSpec.swift +// RoomRolesRequestSpec.swift // Rocket.ChatTests // // Created by Rafael Kellermann Streit on 11/05/18. @@ -11,9 +11,9 @@ import SwiftyJSON @testable import Rocket_Chat -class SubscriptionRolesRequestSpec: APITestCase { +class RoomRolesRequestSpec: APITestCase { func testRequest() { - let reactRequest = SubscriptionRolesRequest(roomName: "general", subscriptionType: .channel) + let reactRequest = RoomRolesRequest(roomName: "general", subscriptionType: .channel) guard let request = reactRequest.request(for: api) else { return XCTFail("request is not nil") @@ -60,7 +60,7 @@ class SubscriptionRolesRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) - let result = SubscriptionRolesResource(raw: json) + let result = RoomRolesResource(raw: json) XCTAssertEqual(result.subscriptionRoles?.count, 2) XCTAssertEqual(result.subscriptionRoles?.first?.user?.username, "john.appleseed") XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 3) @@ -88,7 +88,7 @@ class SubscriptionRolesRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) - let result = SubscriptionRolesResource(raw: json) + let result = RoomRolesResource(raw: json) XCTAssertTrue(result.success) XCTAssertEqual(result.subscriptionRoles?.count, 1) XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 3) @@ -118,7 +118,7 @@ class SubscriptionRolesRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) - let result = SubscriptionRolesResource(raw: json) + let result = RoomRolesResource(raw: json) XCTAssertTrue(result.success) XCTAssertEqual(result.subscriptionRoles?.count, 1) XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 3) @@ -146,7 +146,7 @@ class SubscriptionRolesRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) - let result = SubscriptionRolesResource(raw: json) + let result = RoomRolesResource(raw: json) XCTAssertTrue(result.success) XCTAssertEqual(result.subscriptionRoles?.count, 1) XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 3) @@ -174,7 +174,7 @@ class SubscriptionRolesRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) - let result = SubscriptionRolesResource(raw: json) + let result = RoomRolesResource(raw: json) XCTAssertTrue(result.success) XCTAssertEqual(result.subscriptionRoles?.count, 1) XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 0) @@ -182,7 +182,7 @@ class SubscriptionRolesRequestSpec: APITestCase { } func testEmptyResults() { - let nilResult = SubscriptionRolesResource(raw: nil) + let nilResult = RoomRolesResource(raw: nil) XCTAssertNil(nilResult.subscriptionRoles) } From 3afa3d2202b2d05292cccfa276d35a6123a7a49e Mon Sep 17 00:00:00 2001 From: cardoso Date: Thu, 17 May 2018 13:42:14 -0300 Subject: [PATCH 03/17] Add remove user option to user action sheet --- Rocket.Chat.xcodeproj/project.pbxproj | 8 ++++ .../API/Requests/Room/RoomRolesRequest.swift | 6 +-- .../ChatControllerMessageCellProtocol.swift | 6 +-- .../Chat/ChatControllerRolesController.swift | 2 +- .../ChatControllerUserActionPresenter.swift | 15 ++++++++ .../Chat/MembersListViewController.swift | 2 +- Rocket.Chat/Models/Permission.swift | 2 + .../Models/Subscription/Subscription.swift | 4 +- Rocket.Chat/Models/User/UserPermissions.swift | 38 +++++++++++++++++++ Rocket.Chat/Models/User/UserUtils.swift | 12 ------ .../Resources/cs.lproj/Localizable.strings | 1 + .../Resources/de.lproj/Localizable.strings | 2 + .../Resources/el.lproj/Localizable.strings | 1 + .../Resources/en.lproj/Localizable.strings | 1 + .../Resources/es.lproj/Localizable.strings | 1 + .../Resources/fr.lproj/Localizable.strings | 2 +- .../Resources/pl.lproj/Localizable.strings | 1 + .../Resources/pt-BR.lproj/Localizable.strings | 1 + .../UserActionSheetPresenter.swift | 10 ++++- 19 files changed, 90 insertions(+), 25 deletions(-) create mode 100644 Rocket.Chat/Controllers/Chat/ChatControllerUserActionPresenter.swift create mode 100644 Rocket.Chat/Models/User/UserPermissions.swift diff --git a/Rocket.Chat.xcodeproj/project.pbxproj b/Rocket.Chat.xcodeproj/project.pbxproj index 6d4c702698..97da654fc4 100644 --- a/Rocket.Chat.xcodeproj/project.pbxproj +++ b/Rocket.Chat.xcodeproj/project.pbxproj @@ -527,6 +527,8 @@ 80AE2544203E61CF00DC2867 /* ChatMessageUnreadSeparator.xib in Resources */ = {isa = PBXBuildFile; fileRef = 80AE2543203E61CF00DC2867 /* ChatMessageUnreadSeparator.xib */; }; 80B3DC0B202DCE1D004249AD /* SAMLViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B3DC0A202DCE1D004249AD /* SAMLViewController.swift */; }; 80C110891FB62F7B00205BB1 /* OAuthViewControllerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80C110881FB62F7B00205BB1 /* OAuthViewControllerSpec.swift */; }; + 80CC8A1920ACE320009D64DF /* UserPermissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80CC8A1820ACE320009D64DF /* UserPermissions.swift */; }; + 80CC8A1B20ACEA6A009D64DF /* ChatControllerUserActionPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80CC8A1A20ACEA6A009D64DF /* ChatControllerUserActionPresenter.swift */; }; 80CFB5721F8D697100FC9715 /* ReplyView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 80CFB5711F8D697100FC9715 /* ReplyView.xib */; }; 80CFB5741F8DA55C00FC9715 /* ReplyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80CFB5731F8DA55C00FC9715 /* ReplyView.swift */; }; 80D0CE5C204FFAA50056B17F /* SEServerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 80D0CE5B204FFAA50056B17F /* SEServerCell.xib */; }; @@ -1214,6 +1216,8 @@ 80C7DD631FF46B8700E6647C /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/RCEmojiKit.strings; sourceTree = ""; }; 80C7DD641FF46B8800E6647C /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/RCEmojiKit.strings; sourceTree = ""; }; 80C7DD651FF46B8C00E6647C /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/RCEmojiKit.strings; sourceTree = ""; }; + 80CC8A1820ACE320009D64DF /* UserPermissions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPermissions.swift; sourceTree = ""; }; + 80CC8A1A20ACEA6A009D64DF /* ChatControllerUserActionPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatControllerUserActionPresenter.swift; sourceTree = ""; }; 80CFB5711F8D697100FC9715 /* ReplyView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ReplyView.xib; sourceTree = ""; }; 80CFB5731F8DA55C00FC9715 /* ReplyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReplyView.swift; sourceTree = ""; }; 80D0CE5B204FFAA50056B17F /* SEServerCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SEServerCell.xib; sourceTree = ""; }; @@ -2271,6 +2275,7 @@ 41C45AEE1DFAD42800D9969C /* ChatDataController.swift */, 41E2FA061D41513C00238DFD /* ChatViewController.swift */, 41B9635F207E46F10068F1A6 /* ChatViewControllerTextViewDelegate.swift */, + 80CC8A1A20ACEA6A009D64DF /* ChatControllerUserActionPresenter.swift */, 4112BEEB1E7971A400E734CB /* MainChatViewController.swift */, 800FCD3D1F72893E00D9A692 /* MembersListViewController.swift */, 800E22831F8500A200DA84F1 /* MessagesListViewController.swift */, @@ -2619,6 +2624,7 @@ 41A79C0E1D2F085F00A1968E /* User.swift */, 8076FDD5204864E700114F28 /* UserQueries.swift */, 8076FDD72048654F00114F28 /* UserUtils.swift */, + 80CC8A1820ACE320009D64DF /* UserPermissions.swift */, ); path = User; sourceTree = ""; @@ -3785,6 +3791,7 @@ 411498E31FC7A99C00D66542 /* ChatTitleViewModel.swift in Sources */, 80213C0E1FE0639E00809E14 /* HTTPMethod.swift in Sources */, 0B3A9766202C738E0019CA92 /* ChangeAppIconViewModel.swift in Sources */, + 80CC8A1920ACE320009D64DF /* UserPermissions.swift in Sources */, 41F3C1001DB577ED000E0C76 /* MessageURL.swift in Sources */, 4174CB1C1D2DB2080086DAC8 /* LogManager.swift in Sources */, 41DC7A1D1D38471700896FC0 /* MessageManager.swift in Sources */, @@ -3983,6 +3990,7 @@ 77BA81511F87C4CB00F295F4 /* TextField.swift in Sources */, 41E2FA051D414F0400238DFD /* SubscriptionsViewController.swift in Sources */, 800F38ED2019492D0005CB78 /* DeepLink.swift in Sources */, + 80CC8A1B20ACEA6A009D64DF /* ChatControllerUserActionPresenter.swift in Sources */, 4151B4581E2D1D2E00F8AA1B /* MessageModelMapping.swift in Sources */, 41EE15801E05BF1F00754D45 /* ChatControllerMessageCellProtocol.swift in Sources */, 41865AF21FC8B23400A5E48F /* WebViewControllerEmbedded.swift in Sources */, diff --git a/Rocket.Chat/API/Requests/Room/RoomRolesRequest.swift b/Rocket.Chat/API/Requests/Room/RoomRolesRequest.swift index 52957f8e53..59530ea75f 100644 --- a/Rocket.Chat/API/Requests/Room/RoomRolesRequest.swift +++ b/Rocket.Chat/API/Requests/Room/RoomRolesRequest.swift @@ -1,5 +1,5 @@ // -// SubscriptionRolesRequest.swift +// RoomRolesRequest.swift // Rocket.Chat // // Created by Rafael Kellermann Streit on 11/05/18. @@ -43,10 +43,10 @@ final class RoomRolesRequest: APIRequest { } final class RoomRolesResource: APIResource { - var subscriptionRoles: [SubscriptionRoles]? { + var roomRoles: [RoomRoles]? { guard let realm = Realm.current else { return nil } return raw?["roles"].arrayValue.map { - let object = SubscriptionRoles() + let object = RoomRoles() object.user = User.getOrCreate(realm: realm, values: $0["u"], updates: nil) object.roles.append(contentsOf: $0["roles"].arrayValue.compactMap({ $0.string })) return object diff --git a/Rocket.Chat/Controllers/Chat/ChatControllerMessageCellProtocol.swift b/Rocket.Chat/Controllers/Chat/ChatControllerMessageCellProtocol.swift index 1f4043900d..1afde1984f 100644 --- a/Rocket.Chat/Controllers/Chat/ChatControllerMessageCellProtocol.swift +++ b/Rocket.Chat/Controllers/Chat/ChatControllerMessageCellProtocol.swift @@ -57,12 +57,12 @@ extension ChatViewController: ChatMessageCellProtocol, UserActionSheetPresenter // on select reactor - controller.reactorListView.selectedReactor = { username, rect in + controller.reactorListView.selectedReactor = { [weak self] username, rect in guard let user = User.find(username: username) else { return } - controller.presentActionSheetForUser(user, source: (controller.view, rect)) + controller.presentActionSheetForUser(user, subscription: self?.subscription, source: (controller.view, rect)) } } @@ -74,7 +74,7 @@ extension ChatViewController: ChatMessageCellProtocol, UserActionSheetPresenter func handleUsernameTapMessageCell(_ message: Message, view: UIView, recognizer: UIGestureRecognizer) { guard let user = message.user else { return } - presentActionSheetForUser(user, source: (view, nil)) + presentActionSheetForUser(user, subscription: subscription, source: (view, nil)) } func openURL(url: URL) { diff --git a/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift b/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift index 05564ab98f..58d5a5b01d 100644 --- a/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift +++ b/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift @@ -27,7 +27,7 @@ extension ChatViewController { if let subscription = Subscription.find(rid: rid) { Realm.executeOnMainThread({ (realm) in subscription.usersRoles.removeAll() - resource.subscriptionRoles?.forEach({ (role) in + resource.roomRoles?.forEach({ (role) in subscription.usersRoles.append(role) }) diff --git a/Rocket.Chat/Controllers/Chat/ChatControllerUserActionPresenter.swift b/Rocket.Chat/Controllers/Chat/ChatControllerUserActionPresenter.swift new file mode 100644 index 0000000000..fbb580bba5 --- /dev/null +++ b/Rocket.Chat/Controllers/Chat/ChatControllerUserActionPresenter.swift @@ -0,0 +1,15 @@ +// +// ChatControllerUserActionPresenter.swift +// Rocket.Chat +// +// Created by Matheus Cardoso on 5/16/18. +// Copyright © 2018 Rocket.Chat. All rights reserved. +// + +import Foundation + +extension ChatViewController { + func presentActionSheetForUser(_ user: User, source: (view: UIView?, rect: CGRect?)?) { + presentActionSheetForUser(user, subscription: subscription, source: source) + } +} diff --git a/Rocket.Chat/Controllers/Chat/MembersListViewController.swift b/Rocket.Chat/Controllers/Chat/MembersListViewController.swift index de87ff92ed..3575faf90c 100644 --- a/Rocket.Chat/Controllers/Chat/MembersListViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MembersListViewController.swift @@ -175,7 +175,7 @@ extension MembersListViewController: UITableViewDataSource { extension MembersListViewController: UITableViewDelegate, UserActionSheetPresenter { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) - presentActionSheetForUser(data.member(at: indexPath.row), source: (tableView, tableView.rectForRow(at: indexPath))) + presentActionSheetForUser(data.member(at: indexPath.row), subscription: data.subscription, source: (tableView, tableView.rectForRow(at: indexPath))) } func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { diff --git a/Rocket.Chat/Models/Permission.swift b/Rocket.Chat/Models/Permission.swift index 210db53f2d..26c9950590 100644 --- a/Rocket.Chat/Models/Permission.swift +++ b/Rocket.Chat/Models/Permission.swift @@ -27,6 +27,8 @@ enum PermissionType: String { case pinMessage = "pin-message" case postReadOnly = "post-readonly" + + case removeUser = "remove-user" } class Permission: BaseModel { diff --git a/Rocket.Chat/Models/Subscription/Subscription.swift b/Rocket.Chat/Models/Subscription/Subscription.swift index af039837a6..73f816e84a 100644 --- a/Rocket.Chat/Models/Subscription/Subscription.swift +++ b/Rocket.Chat/Models/Subscription/Subscription.swift @@ -57,10 +57,10 @@ final class Subscription: BaseModel { // User's roles on the subscription, this values // aren't stored in database. - let usersRoles = List() + let usersRoles = List() } -final class SubscriptionRoles: Object { +final class RoomRoles: Object { @objc dynamic var user: User? var roles = List() } diff --git a/Rocket.Chat/Models/User/UserPermissions.swift b/Rocket.Chat/Models/User/UserPermissions.swift new file mode 100644 index 0000000000..929d039608 --- /dev/null +++ b/Rocket.Chat/Models/User/UserPermissions.swift @@ -0,0 +1,38 @@ +// +// UserPermissions.swift +// Rocket.Chat +// +// Created by Matheus Cardoso on 5/16/18. +// Copyright © 2018 Rocket.Chat. All rights reserved. +// + +import RealmSwift + +extension User { + func rolesInSubscription(_ subscription: Subscription) -> [String] { + if let roles = subscription.usersRoles.flatMap({ $0.user }).first(where: { $0 == self })?.roles { + return Array(roles) + } + + return [] + } + + func hasPermission(_ permission: PermissionType, subscription: Subscription? = nil, realm: Realm? = Realm.current) -> Bool { + guard let permissionRoles = PermissionManager.roles(for: permission, realm: realm) else { return false } + + let roles: [String] + if let subscription = subscription { + roles = rolesInSubscription(subscription) + } else { + roles = Array(self.roles) + } + + for userRole in roles { + for permissionRole in permissionRoles where userRole == permissionRole { + return true + } + } + + return false + } +} diff --git a/Rocket.Chat/Models/User/UserUtils.swift b/Rocket.Chat/Models/User/UserUtils.swift index 4ebb7e8402..97523ae5f9 100644 --- a/Rocket.Chat/Models/User/UserUtils.swift +++ b/Rocket.Chat/Models/User/UserUtils.swift @@ -9,18 +9,6 @@ import RealmSwift extension User { - func hasPermission(_ permission: PermissionType, realm: Realm? = Realm.current) -> Bool { - guard let permissionRoles = PermissionManager.roles(for: permission, realm: realm) else { return false } - - for userRole in self.roles { - for permissionRole in permissionRoles where userRole == permissionRole { - return true - } - } - - return false - } - func displayName() -> String { guard let settings = AuthSettingsManager.settings else { return username ?? "" diff --git a/Rocket.Chat/Resources/cs.lproj/Localizable.strings b/Rocket.Chat/Resources/cs.lproj/Localizable.strings index f4e6d7bede..343899266c 100644 --- a/Rocket.Chat/Resources/cs.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/cs.lproj/Localizable.strings @@ -315,3 +315,4 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO +"user_action_sheet.remove" = "Remove from room"; // TODO diff --git a/Rocket.Chat/Resources/de.lproj/Localizable.strings b/Rocket.Chat/Resources/de.lproj/Localizable.strings index 9fb8fb7980..905fe7a264 100644 --- a/Rocket.Chat/Resources/de.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/de.lproj/Localizable.strings @@ -315,3 +315,5 @@ // User Action Sheet "user_action_sheet.conversation" = "Konversation"; +"user_action_sheet.remove" = "Remove from room"; // TODO + diff --git a/Rocket.Chat/Resources/el.lproj/Localizable.strings b/Rocket.Chat/Resources/el.lproj/Localizable.strings index b397717ac5..7595e7b721 100644 --- a/Rocket.Chat/Resources/el.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/el.lproj/Localizable.strings @@ -315,3 +315,4 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO +"user_action_sheet.remove" = "Remove from room"; // TODO diff --git a/Rocket.Chat/Resources/en.lproj/Localizable.strings b/Rocket.Chat/Resources/en.lproj/Localizable.strings index 923e379030..0319a0d6f8 100644 --- a/Rocket.Chat/Resources/en.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/en.lproj/Localizable.strings @@ -315,3 +315,4 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; +"user_action_sheet.remove" = "Remove from room"; diff --git a/Rocket.Chat/Resources/es.lproj/Localizable.strings b/Rocket.Chat/Resources/es.lproj/Localizable.strings index 0c6180215e..6d32dee361 100644 --- a/Rocket.Chat/Resources/es.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/es.lproj/Localizable.strings @@ -314,3 +314,4 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO +"user_action_sheet.remove" = "Remove from room"; // TODO diff --git a/Rocket.Chat/Resources/fr.lproj/Localizable.strings b/Rocket.Chat/Resources/fr.lproj/Localizable.strings index acda0e12c7..33e01b2f7d 100644 --- a/Rocket.Chat/Resources/fr.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/fr.lproj/Localizable.strings @@ -315,4 +315,4 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO - +"user_action_sheet.remove" = "Remove from room"; // TODO diff --git a/Rocket.Chat/Resources/pl.lproj/Localizable.strings b/Rocket.Chat/Resources/pl.lproj/Localizable.strings index 739f025385..40610739ff 100644 --- a/Rocket.Chat/Resources/pl.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/pl.lproj/Localizable.strings @@ -314,3 +314,4 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO +"user_action_sheet.remove" = "Remove from room"; // TODO diff --git a/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings b/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings index 3f2132f29e..29123b933b 100644 --- a/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings @@ -315,3 +315,4 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversa"; +"user_action_sheet.remove" = "Remover do canal"; // TODO diff --git a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift index c9830ae6f6..17a3a54a57 100644 --- a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift +++ b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift @@ -9,11 +9,11 @@ import Foundation protocol UserActionSheetPresenter: Closeable { - func presentActionSheetForUser(_ user: User, source: (view: UIView?, rect: CGRect?)?) + func presentActionSheetForUser(_ user: User, subscription: Subscription?, source: (view: UIView?, rect: CGRect?)?) } extension UserActionSheetPresenter where Self: UIViewController { - func presentActionSheetForUser(_ user: User, source: (view: UIView?, rect: CGRect?)? = nil) { + func presentActionSheetForUser(_ user: User, subscription: Subscription? = nil, source: (view: UIView?, rect: CGRect?)? = nil) { let controller = UIAlertController(title: user.displayName(), message: nil, preferredStyle: .actionSheet) controller.popoverPresentationController?.sourceView = source?.view controller.popoverPresentationController?.sourceRect = source?.rect ?? source?.view?.frame ?? .zero @@ -27,6 +27,12 @@ extension UserActionSheetPresenter where Self: UIViewController { } })) + if let subscription = subscription { + if user.hasPermission(.removeUser, subscription: subscription) { + controller.addAction(UIAlertAction(title: localized("user_action_sheet.remove"), style: .destructive)) + } + } + controller.addAction(UIAlertAction(title: localized("global.cancel"), style: .cancel)) present(controller, animated: true, completion: nil) From f8e015a543d393a475051acec778eaace0e8ef1c Mon Sep 17 00:00:00 2001 From: cardoso Date: Fri, 18 May 2018 10:56:34 -0300 Subject: [PATCH 04/17] Fix not mapping subscription roles correctly --- .../Controllers/Chat/ChatControllerRolesController.swift | 3 ++- Rocket.Chat/Models/Subscription/Subscription.swift | 2 -- Rocket.Chat/Models/User/UserPermissions.swift | 2 +- Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift b/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift index 58d5a5b01d..1d49adfc35 100644 --- a/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift +++ b/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift @@ -36,7 +36,8 @@ extension ChatViewController { } // Fail silently - default: break + case .error(let error): + print(error) } }) } diff --git a/Rocket.Chat/Models/Subscription/Subscription.swift b/Rocket.Chat/Models/Subscription/Subscription.swift index 73f816e84a..001580458f 100644 --- a/Rocket.Chat/Models/Subscription/Subscription.swift +++ b/Rocket.Chat/Models/Subscription/Subscription.swift @@ -55,8 +55,6 @@ final class Subscription: BaseModel { let messages = LinkingObjects(fromType: Message.self, property: "subscription") - // User's roles on the subscription, this values - // aren't stored in database. let usersRoles = List() } diff --git a/Rocket.Chat/Models/User/UserPermissions.swift b/Rocket.Chat/Models/User/UserPermissions.swift index 929d039608..93db4897fc 100644 --- a/Rocket.Chat/Models/User/UserPermissions.swift +++ b/Rocket.Chat/Models/User/UserPermissions.swift @@ -10,7 +10,7 @@ import RealmSwift extension User { func rolesInSubscription(_ subscription: Subscription) -> [String] { - if let roles = subscription.usersRoles.flatMap({ $0.user }).first(where: { $0 == self })?.roles { + if let roles = subscription.usersRoles.first(where: { $0.user?.identifier == self.identifier })?.roles { return Array(roles) } diff --git a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift index 17a3a54a57..67a68cf916 100644 --- a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift +++ b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift @@ -28,7 +28,7 @@ extension UserActionSheetPresenter where Self: UIViewController { })) if let subscription = subscription { - if user.hasPermission(.removeUser, subscription: subscription) { + if AuthManager.currentUser()?.hasPermission(.removeUser, subscription: subscription) == true { controller.addAction(UIAlertAction(title: localized("user_action_sheet.remove"), style: .destructive)) } } From 504d5798fb96ea734a9b064d65ba0f0079a6e3f9 Mon Sep 17 00:00:00 2001 From: cardoso Date: Fri, 18 May 2018 11:07:58 -0300 Subject: [PATCH 05/17] Add RoomRemoveUserRequest --- Rocket.Chat.xcodeproj/project.pbxproj | 4 ++ .../Requests/Room/RoomRemoveUserRequest.swift | 57 +++++++++++++++++++ .../Models/Subscription/Subscription.swift | 2 + 3 files changed, 63 insertions(+) create mode 100644 Rocket.Chat/API/Requests/Room/RoomRemoveUserRequest.swift diff --git a/Rocket.Chat.xcodeproj/project.pbxproj b/Rocket.Chat.xcodeproj/project.pbxproj index 97da654fc4..3d3e2f0d93 100644 --- a/Rocket.Chat.xcodeproj/project.pbxproj +++ b/Rocket.Chat.xcodeproj/project.pbxproj @@ -379,6 +379,7 @@ 80307E411FD75DC0006AD9EF /* VoiceOver.strings in Resources */ = {isa = PBXBuildFile; fileRef = 80307E431FD75DC0006AD9EF /* VoiceOver.strings */; }; 8032E3E820362EF5009D33CE /* UpdateMessageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8032E3E720362EF5009D33CE /* UpdateMessageRequest.swift */; }; 803782B71FB4751D00DED049 /* RealmTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803782B61FB4751D00DED049 /* RealmTestCase.swift */; }; + 8039441120AF1334002F317A /* RoomRemoveUserRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8039441020AF1334002F317A /* RoomRemoveUserRequest.swift */; }; 8041C0402028C7A1007E21FA /* ReactorListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8041C03F2028C7A1007E21FA /* ReactorListViewController.swift */; }; 8041C0422028C7EF007E21FA /* ReactorListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8041C0412028C7EF007E21FA /* ReactorListView.swift */; }; 8041C0442028C828007E21FA /* ReactorListView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8041C0432028C828007E21FA /* ReactorListView.xib */; }; @@ -1090,6 +1091,7 @@ 80307E481FD75DD5006AD9EF /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/VoiceOver.strings; sourceTree = ""; }; 8032E3E720362EF5009D33CE /* UpdateMessageRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateMessageRequest.swift; sourceTree = ""; }; 803782B61FB4751D00DED049 /* RealmTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmTestCase.swift; sourceTree = ""; }; + 8039441020AF1334002F317A /* RoomRemoveUserRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomRemoveUserRequest.swift; sourceTree = ""; }; 8041C03F2028C7A1007E21FA /* ReactorListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactorListViewController.swift; sourceTree = ""; }; 8041C0412028C7EF007E21FA /* ReactorListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactorListView.swift; sourceTree = ""; }; 8041C0432028C828007E21FA /* ReactorListView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ReactorListView.xib; sourceTree = ""; }; @@ -2476,6 +2478,7 @@ 800E22851F8507E400DA84F1 /* RoomMessagesRequest.swift */, 9987B59B2093E60C007D277C /* RoomFilesRequest.swift */, 414E8A8C20A5DD2200615CE6 /* RoomRolesRequest.swift */, + 8039441020AF1334002F317A /* RoomRemoveUserRequest.swift */, ); path = Room; sourceTree = ""; @@ -3689,6 +3692,7 @@ 41B554C51FBF0C71000510B7 /* UIWindowExtensions.swift in Sources */, 8062E33520A5ECF50044F407 /* APIRequestOption.swift in Sources */, 807C7C0620751ED2006B600E /* SpotlightClient.swift in Sources */, + 8039441120AF1334002F317A /* RoomRemoveUserRequest.swift in Sources */, 33383509207926DE006E1D0A /* TransparentToTouchesWindow.swift in Sources */, 4174CB1F1D2DB3350086DAC8 /* StringExtensions.swift in Sources */, 41E9BD0D208EA4040084D4D8 /* AuthInternalExtensions.swift in Sources */, diff --git a/Rocket.Chat/API/Requests/Room/RoomRemoveUserRequest.swift b/Rocket.Chat/API/Requests/Room/RoomRemoveUserRequest.swift new file mode 100644 index 0000000000..c6dc729b39 --- /dev/null +++ b/Rocket.Chat/API/Requests/Room/RoomRemoveUserRequest.swift @@ -0,0 +1,57 @@ +// +// RoomRemoveUserRequest.swift +// Rocket.Chat +// +// Created by Matheus Cardoso on 5/18/18. +// Copyright © 2018 Rocket.Chat. All rights reserved. +// + +import SwiftyJSON + +fileprivate extension RoomType { + var path: String { + switch self { + case .channel: + return "/api/v1/channels.kick" + case .group: + return "/api/v1/groups.kick" + case .directMessage: + return "" + } + } +} + +final class RoomRemoveUserRequest: APIRequest { + typealias APIResourceType = RoomRemoveUserResource + let requiredVersion = Version(0, 48, 0) + + let method: HTTPMethod = .post + var path: String { + return roomType.path + } + + let roomId: String + let roomType: RoomType + let userId: String + + init(roomId: String, roomType: RoomType, userId: String) { + self.roomId = roomId + self.roomType = roomType + self.userId = userId + } + + func body() -> Data? { + let body = JSON([ + "roomId": roomId, + "userId": userId + ]) + + return body.rawString()?.data(using: .utf8) + } +} + +final class RoomRemoveUserResource: APIResource { + var success: Bool? { + return raw?["success"].boolValue + } +} diff --git a/Rocket.Chat/Models/Subscription/Subscription.swift b/Rocket.Chat/Models/Subscription/Subscription.swift index 001580458f..51471024aa 100644 --- a/Rocket.Chat/Models/Subscription/Subscription.swift +++ b/Rocket.Chat/Models/Subscription/Subscription.swift @@ -16,6 +16,8 @@ enum SubscriptionType: String, Equatable { case group = "p" } +typealias RoomType = SubscriptionType + final class Subscription: BaseModel { @objc dynamic var auth: Auth? From 68c4f28d06959fa0d88062f0be5a34820a1cf73a Mon Sep 17 00:00:00 2001 From: cardoso Date: Fri, 18 May 2018 11:34:17 -0300 Subject: [PATCH 06/17] Rename + Add RoomKickRequestSpec --- Rocket.Chat.xcodeproj/project.pbxproj | 12 ++-- ...serRequest.swift => RoomKickRequest.swift} | 8 +-- .../Requests/Room/RoomKickRequestSpec.swift | 64 +++++++++++++++++++ 3 files changed, 76 insertions(+), 8 deletions(-) rename Rocket.Chat/API/Requests/Room/{RoomRemoveUserRequest.swift => RoomKickRequest.swift} (85%) create mode 100644 Rocket.ChatTests/API/Requests/Room/RoomKickRequestSpec.swift diff --git a/Rocket.Chat.xcodeproj/project.pbxproj b/Rocket.Chat.xcodeproj/project.pbxproj index 3d3e2f0d93..3c22d96ff3 100644 --- a/Rocket.Chat.xcodeproj/project.pbxproj +++ b/Rocket.Chat.xcodeproj/project.pbxproj @@ -379,7 +379,8 @@ 80307E411FD75DC0006AD9EF /* VoiceOver.strings in Resources */ = {isa = PBXBuildFile; fileRef = 80307E431FD75DC0006AD9EF /* VoiceOver.strings */; }; 8032E3E820362EF5009D33CE /* UpdateMessageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8032E3E720362EF5009D33CE /* UpdateMessageRequest.swift */; }; 803782B71FB4751D00DED049 /* RealmTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803782B61FB4751D00DED049 /* RealmTestCase.swift */; }; - 8039441120AF1334002F317A /* RoomRemoveUserRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8039441020AF1334002F317A /* RoomRemoveUserRequest.swift */; }; + 8039441120AF1334002F317A /* RoomKickRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8039441020AF1334002F317A /* RoomKickRequest.swift */; }; + 8039441320AF17F1002F317A /* RoomKickRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8039441220AF17F1002F317A /* RoomKickRequestSpec.swift */; }; 8041C0402028C7A1007E21FA /* ReactorListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8041C03F2028C7A1007E21FA /* ReactorListViewController.swift */; }; 8041C0422028C7EF007E21FA /* ReactorListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8041C0412028C7EF007E21FA /* ReactorListView.swift */; }; 8041C0442028C828007E21FA /* ReactorListView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8041C0432028C828007E21FA /* ReactorListView.xib */; }; @@ -1091,7 +1092,8 @@ 80307E481FD75DD5006AD9EF /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/VoiceOver.strings; sourceTree = ""; }; 8032E3E720362EF5009D33CE /* UpdateMessageRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateMessageRequest.swift; sourceTree = ""; }; 803782B61FB4751D00DED049 /* RealmTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmTestCase.swift; sourceTree = ""; }; - 8039441020AF1334002F317A /* RoomRemoveUserRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomRemoveUserRequest.swift; sourceTree = ""; }; + 8039441020AF1334002F317A /* RoomKickRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomKickRequest.swift; sourceTree = ""; }; + 8039441220AF17F1002F317A /* RoomKickRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomKickRequestSpec.swift; sourceTree = ""; }; 8041C03F2028C7A1007E21FA /* ReactorListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactorListViewController.swift; sourceTree = ""; }; 8041C0412028C7EF007E21FA /* ReactorListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactorListView.swift; sourceTree = ""; }; 8041C0432028C828007E21FA /* ReactorListView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ReactorListView.xib; sourceTree = ""; }; @@ -2478,7 +2480,7 @@ 800E22851F8507E400DA84F1 /* RoomMessagesRequest.swift */, 9987B59B2093E60C007D277C /* RoomFilesRequest.swift */, 414E8A8C20A5DD2200615CE6 /* RoomRolesRequest.swift */, - 8039441020AF1334002F317A /* RoomRemoveUserRequest.swift */, + 8039441020AF1334002F317A /* RoomKickRequest.swift */, ); path = Room; sourceTree = ""; @@ -2493,6 +2495,7 @@ 990FF6D7207438D4007B4A53 /* RoomMentionsRequestSpec.swift */, 992B5AB7209A2890009C8123 /* RoomFilesRequestSpec.swift */, 41D51B0820A635150073E8E7 /* RoomRolesRequestSpec.swift */, + 8039441220AF17F1002F317A /* RoomKickRequestSpec.swift */, ); path = Room; sourceTree = ""; @@ -3692,7 +3695,7 @@ 41B554C51FBF0C71000510B7 /* UIWindowExtensions.swift in Sources */, 8062E33520A5ECF50044F407 /* APIRequestOption.swift in Sources */, 807C7C0620751ED2006B600E /* SpotlightClient.swift in Sources */, - 8039441120AF1334002F317A /* RoomRemoveUserRequest.swift in Sources */, + 8039441120AF1334002F317A /* RoomKickRequest.swift in Sources */, 33383509207926DE006E1D0A /* TransparentToTouchesWindow.swift in Sources */, 4174CB1F1D2DB3350086DAC8 /* StringExtensions.swift in Sources */, 41E9BD0D208EA4040084D4D8 /* AuthInternalExtensions.swift in Sources */, @@ -4077,6 +4080,7 @@ D1DA25251F695ABF00DB6ABB /* ChatDataControllerSpec.swift in Sources */, 41BAE3E91D71C15A00C2445A /* URLExtensionSpec.swift in Sources */, 998165CC204EDBA30059D346 /* UploadAvatarRequestSpec.swift in Sources */, + 8039441320AF17F1002F317A /* RoomKickRequestSpec.swift in Sources */, 993E513A1FB1E18D006403D5 /* DraftMessageManagerSpec.swift in Sources */, 416133401D46E6A800E09DA2 /* MessageSpec.swift in Sources */, 41ADDD4B1E9E787E0007A458 /* LoaderViewSpec.swift in Sources */, diff --git a/Rocket.Chat/API/Requests/Room/RoomRemoveUserRequest.swift b/Rocket.Chat/API/Requests/Room/RoomKickRequest.swift similarity index 85% rename from Rocket.Chat/API/Requests/Room/RoomRemoveUserRequest.swift rename to Rocket.Chat/API/Requests/Room/RoomKickRequest.swift index c6dc729b39..510b64645f 100644 --- a/Rocket.Chat/API/Requests/Room/RoomRemoveUserRequest.swift +++ b/Rocket.Chat/API/Requests/Room/RoomKickRequest.swift @@ -1,5 +1,5 @@ // -// RoomRemoveUserRequest.swift +// RoomKickRequest.swift // Rocket.Chat // // Created by Matheus Cardoso on 5/18/18. @@ -21,8 +21,8 @@ fileprivate extension RoomType { } } -final class RoomRemoveUserRequest: APIRequest { - typealias APIResourceType = RoomRemoveUserResource +final class RoomKickRequest: APIRequest { + typealias APIResourceType = RoomKickResource let requiredVersion = Version(0, 48, 0) let method: HTTPMethod = .post @@ -50,7 +50,7 @@ final class RoomRemoveUserRequest: APIRequest { } } -final class RoomRemoveUserResource: APIResource { +final class RoomKickResource: APIResource { var success: Bool? { return raw?["success"].boolValue } diff --git a/Rocket.ChatTests/API/Requests/Room/RoomKickRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomKickRequestSpec.swift new file mode 100644 index 0000000000..eeba98b965 --- /dev/null +++ b/Rocket.ChatTests/API/Requests/Room/RoomKickRequestSpec.swift @@ -0,0 +1,64 @@ +// +// RoomKickRequestSpec.swift +// Rocket.ChatTests +// +// Created by Matheus Cardoso on 5/18/18. +// Copyright © 2018 Rocket.Chat. All rights reserved. +// + +import XCTest +import SwiftyJSON + +@testable import Rocket_Chat + +class RoomKickRequestSpec: APITestCase { + func testRequest() { + let preRequest = RoomKickRequest(roomId: "roomId", roomType: .channel, userId: "userId") + + guard let request = preRequest.request(for: api) else { + return XCTFail("request is not nil") + } + guard let httpBody = request.httpBody else { + return XCTFail("body is not nil") + } + guard let bodyJson = try? JSON(data: httpBody) else { + return XCTFail("body is valid json") + } + + XCTAssertEqual(request.url?.path, "/api/v1/channels.kick", "path is correct") + XCTAssertEqual(request.httpMethod, "POST", "http method is correct") + XCTAssertEqual(request.value(forHTTPHeaderField: "Content-Type"), "application/json", "content type is correct") + XCTAssertEqual(bodyJson["roomId"].string, "roomId", "roomId is correct") + XCTAssertEqual(bodyJson["userId"].string, "userId", "userId is correct") + } + + func testResult() { + let mockResult = JSON([ + "channel": [ + "_id": "ByehQjC44FwMeiLbX", + "name": "invite-me", + "t": "c", + "usernames": [ + "testing1" + ], + "msgs": 0, + "u": [ + "_id": "aobEdbYhXfu5hkeqG", + "username": "testing1" + ], + "ts": "2016-12-09T15:08:58.042Z", + "ro": false, + "sysMes": true, + "_updatedAt": "2016-12-09T15:22:40.656Z" + ], + "success": true + ]) + + let result = RoomKickResource(raw: mockResult) + + XCTAssert(result.success == true) + + let nilResult = RoomKickResource(raw: nil) + XCTAssertNil(nilResult.success, "success is nil if raw is nil") + } +} From c9039e08d2a9fbe82ec8f49959c772003479dea5 Mon Sep 17 00:00:00 2001 From: cardoso Date: Fri, 18 May 2018 13:02:49 -0300 Subject: [PATCH 07/17] Update tests --- .../Requests/Room/RoomRolesRequestSpec.swift | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Rocket.ChatTests/API/Requests/Room/RoomRolesRequestSpec.swift b/Rocket.ChatTests/API/Requests/Room/RoomRolesRequestSpec.swift index 1510b6af51..b307cc5929 100644 --- a/Rocket.ChatTests/API/Requests/Room/RoomRolesRequestSpec.swift +++ b/Rocket.ChatTests/API/Requests/Room/RoomRolesRequestSpec.swift @@ -61,10 +61,10 @@ class RoomRolesRequestSpec: APITestCase { let json = JSON(parseJSON: jsonString) let result = RoomRolesResource(raw: json) - XCTAssertEqual(result.subscriptionRoles?.count, 2) - XCTAssertEqual(result.subscriptionRoles?.first?.user?.username, "john.appleseed") - XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 3) - XCTAssertEqual(result.subscriptionRoles?.first?.roles.first, Role.owner.rawValue) + XCTAssertEqual(result.roomRoles?.count, 2) + XCTAssertEqual(result.roomRoles?.first?.user?.username, "john.appleseed") + XCTAssertEqual(result.roomRoles?.first?.roles.count, 3) + XCTAssertEqual(result.roomRoles?.first?.roles.first, Role.owner.rawValue) XCTAssertTrue(result.success) } @@ -90,10 +90,10 @@ class RoomRolesRequestSpec: APITestCase { let result = RoomRolesResource(raw: json) XCTAssertTrue(result.success) - XCTAssertEqual(result.subscriptionRoles?.count, 1) - XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 3) - XCTAssertNotNil(result.subscriptionRoles?.first?.user) - XCTAssertNil(result.subscriptionRoles?.first?.user?.identifier) + XCTAssertEqual(result.roomRoles?.count, 1) + XCTAssertEqual(result.roomRoles?.first?.roles.count, 3) + XCTAssertNotNil(result.roomRoles?.first?.user) + XCTAssertNil(result.roomRoles?.first?.user?.identifier) } func testInvalidUserObject() { @@ -120,10 +120,10 @@ class RoomRolesRequestSpec: APITestCase { let result = RoomRolesResource(raw: json) XCTAssertTrue(result.success) - XCTAssertEqual(result.subscriptionRoles?.count, 1) - XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 3) - XCTAssertNotNil(result.subscriptionRoles?.first?.user) - XCTAssertNil(result.subscriptionRoles?.first?.user?.identifier) + XCTAssertEqual(result.roomRoles?.count, 1) + XCTAssertEqual(result.roomRoles?.first?.roles.count, 3) + XCTAssertNotNil(result.roomRoles?.first?.user) + XCTAssertNil(result.roomRoles?.first?.user?.identifier) } func testArrayUserObject() { @@ -148,10 +148,10 @@ class RoomRolesRequestSpec: APITestCase { let result = RoomRolesResource(raw: json) XCTAssertTrue(result.success) - XCTAssertEqual(result.subscriptionRoles?.count, 1) - XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 3) - XCTAssertNotNil(result.subscriptionRoles?.first?.user) - XCTAssertNil(result.subscriptionRoles?.first?.user?.identifier) + XCTAssertEqual(result.roomRoles?.count, 1) + XCTAssertEqual(result.roomRoles?.first?.roles.count, 3) + XCTAssertNotNil(result.roomRoles?.first?.user) + XCTAssertNil(result.roomRoles?.first?.user?.identifier) } func testEmtpyRolesObject() { @@ -176,14 +176,14 @@ class RoomRolesRequestSpec: APITestCase { let result = RoomRolesResource(raw: json) XCTAssertTrue(result.success) - XCTAssertEqual(result.subscriptionRoles?.count, 1) - XCTAssertEqual(result.subscriptionRoles?.first?.roles.count, 0) - XCTAssertEqual(result.subscriptionRoles?.first?.user?.username, "john.appleseed") + XCTAssertEqual(result.roomRoles?.count, 1) + XCTAssertEqual(result.roomRoles?.first?.roles.count, 0) + XCTAssertEqual(result.roomRoles?.first?.user?.username, "john.appleseed") } func testEmptyResults() { let nilResult = RoomRolesResource(raw: nil) - XCTAssertNil(nilResult.subscriptionRoles) + XCTAssertNil(nilResult.roomRoles) } } From 4534b4beaedf47bb6715bec44e77ea804d178ed0 Mon Sep 17 00:00:00 2001 From: cardoso Date: Mon, 21 May 2018 09:48:11 -0300 Subject: [PATCH 08/17] Show localized API errors when calling rooms.kick API --- Rocket.Chat.xcodeproj/project.pbxproj | 12 ++++++ Rocket.Chat/API/API.swift | 1 + Rocket.Chat/API/APIRequest.swift | 11 +++--- .../API/Requests/Base/ResourceWithError.swift | 24 ++++++++++++ .../API/Requests/Room/RoomKickRequest.swift | 2 +- .../Language/LanguageViewController.swift | 6 +-- .../Language/LanguageViewModel.swift | 13 +++++-- .../Extensions/API/APIExtensions.swift | 1 + Rocket.Chat/Helpers/Alert.swift | 15 +++++++ Rocket.Chat/Managers/AppManager.swift | 37 ++++++++++++++++++ .../Resources/cs.lproj/Localizable.strings | 3 ++ .../Resources/de.lproj/Localizable.strings | 4 +- .../Resources/el.lproj/Localizable.strings | 3 ++ .../Resources/en.lproj/Localizable.strings | 3 ++ .../Resources/es.lproj/Localizable.strings | 3 ++ .../Resources/fr.lproj/Localizable.strings | 3 ++ .../Resources/pl.lproj/Localizable.strings | 3 ++ .../Resources/pt-BR.lproj/Localizable.strings | 5 ++- .../UserActionSheetPresenter.swift | 39 ++++++++++++++++++- 19 files changed, 172 insertions(+), 16 deletions(-) create mode 100644 Rocket.Chat/API/Requests/Base/ResourceWithError.swift diff --git a/Rocket.Chat.xcodeproj/project.pbxproj b/Rocket.Chat.xcodeproj/project.pbxproj index 3c22d96ff3..dfed6305e5 100644 --- a/Rocket.Chat.xcodeproj/project.pbxproj +++ b/Rocket.Chat.xcodeproj/project.pbxproj @@ -381,6 +381,7 @@ 803782B71FB4751D00DED049 /* RealmTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803782B61FB4751D00DED049 /* RealmTestCase.swift */; }; 8039441120AF1334002F317A /* RoomKickRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8039441020AF1334002F317A /* RoomKickRequest.swift */; }; 8039441320AF17F1002F317A /* RoomKickRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8039441220AF17F1002F317A /* RoomKickRequestSpec.swift */; }; + 8039441820AF620C002F317A /* ResourceWithError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8039441720AF620C002F317A /* ResourceWithError.swift */; }; 8041C0402028C7A1007E21FA /* ReactorListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8041C03F2028C7A1007E21FA /* ReactorListViewController.swift */; }; 8041C0422028C7EF007E21FA /* ReactorListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8041C0412028C7EF007E21FA /* ReactorListView.swift */; }; 8041C0442028C828007E21FA /* ReactorListView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8041C0432028C828007E21FA /* ReactorListView.xib */; }; @@ -1094,6 +1095,7 @@ 803782B61FB4751D00DED049 /* RealmTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmTestCase.swift; sourceTree = ""; }; 8039441020AF1334002F317A /* RoomKickRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomKickRequest.swift; sourceTree = ""; }; 8039441220AF17F1002F317A /* RoomKickRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomKickRequestSpec.swift; sourceTree = ""; }; + 8039441720AF620C002F317A /* ResourceWithError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourceWithError.swift; sourceTree = ""; }; 8041C03F2028C7A1007E21FA /* ReactorListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactorListViewController.swift; sourceTree = ""; }; 8041C0412028C7EF007E21FA /* ReactorListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactorListView.swift; sourceTree = ""; }; 8041C0432028C828007E21FA /* ReactorListView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ReactorListView.xib; sourceTree = ""; }; @@ -2527,6 +2529,14 @@ path = VoiceOver; sourceTree = ""; }; + 8039441620AF61ED002F317A /* Base */ = { + isa = PBXGroup; + children = ( + 8039441720AF620C002F317A /* ResourceWithError.swift */, + ); + path = Base; + sourceTree = ""; + }; 8062E32F20A3A2A30044F407 /* Subscription */ = { isa = PBXGroup; children = ( @@ -3045,6 +3055,7 @@ D1D535EF1F70863C006625D2 /* Requests */ = { isa = PBXGroup; children = ( + 8039441620AF61ED002F317A /* Base */, 802498EC1F7A82CD005477EC /* Authentication */, 8013F8831FD6B74800EE1A4E /* Command */, 9977302520725B3A009AF465 /* Emoji */, @@ -3737,6 +3748,7 @@ 0BC0E8632032DD95004BFAAF /* DrawingViewModel.swift in Sources */, 35E892C8201CDD1600B4BE5A /* NewRoomViewController.swift in Sources */, 990FF6D620740C79007B4A53 /* RoomMentionsRequest.swift in Sources */, + 8039441820AF620C002F317A /* ResourceWithError.swift in Sources */, 416133321D46CA4E00E09DA2 /* ChatMessageCell.swift in Sources */, 806DB94A20695CD0004ED8ED /* AuthViewControllerAuthenticationHandler.swift in Sources */, 8041C0422028C7EF007E21FA /* ReactorListView.swift in Sources */, diff --git a/Rocket.Chat/API/API.swift b/Rocket.Chat/API/API.swift index 1486a480bd..9f8facc033 100644 --- a/Rocket.Chat/API/API.swift +++ b/Rocket.Chat/API/API.swift @@ -47,6 +47,7 @@ final class API: APIFetcher { var authToken: String? var userId: String? + var language: String? static let userAgent: String = { let info = Bundle.main.infoDictionary diff --git a/Rocket.Chat/API/APIRequest.swift b/Rocket.Chat/API/APIRequest.swift index 7046a335af..557260e563 100644 --- a/Rocket.Chat/API/APIRequest.swift +++ b/Rocket.Chat/API/APIRequest.swift @@ -64,13 +64,14 @@ extension APIRequest { request.addValue(contentType, forHTTPHeaderField: "Content-Type") request.addValue(API.userAgent, forHTTPHeaderField: "User-Agent") - if let token = api.authToken { - request.addValue(token, forHTTPHeaderField: "X-Auth-Token") + func addValueIfSome(_ value: String?, forHTTPHeaderField field: String) { + guard let value = value else { return } + request.addValue(value, forHTTPHeaderField: field) } - if let userId = api.userId { - request.addValue(userId, forHTTPHeaderField: "X-User-Id") - } + addValueIfSome(api.authToken, forHTTPHeaderField: "X-Auth-Token") + addValueIfSome(api.userId, forHTTPHeaderField: "X-User-Id") + addValueIfSome(api.language, forHTTPHeaderField: "Accept-Language") return request } diff --git a/Rocket.Chat/API/Requests/Base/ResourceWithError.swift b/Rocket.Chat/API/Requests/Base/ResourceWithError.swift new file mode 100644 index 0000000000..b64109fd71 --- /dev/null +++ b/Rocket.Chat/API/Requests/Base/ResourceWithError.swift @@ -0,0 +1,24 @@ +// +// ResourceWithError.swift +// Rocket.Chat +// +// Created by Matheus Cardoso on 5/18/18. +// Copyright © 2018 Rocket.Chat. All rights reserved. +// + +import Foundation + +protocol ResourceWithError { + var error: String? { get } + var errorType: String? { get } +} + +extension ResourceWithError where Self: APIResource { + var error: String? { + return raw?["error"].string + } + + var errorType: String? { + return raw?["errorType"].string + } +} diff --git a/Rocket.Chat/API/Requests/Room/RoomKickRequest.swift b/Rocket.Chat/API/Requests/Room/RoomKickRequest.swift index 510b64645f..1d96a3f2b4 100644 --- a/Rocket.Chat/API/Requests/Room/RoomKickRequest.swift +++ b/Rocket.Chat/API/Requests/Room/RoomKickRequest.swift @@ -50,7 +50,7 @@ final class RoomKickRequest: APIRequest { } } -final class RoomKickResource: APIResource { +final class RoomKickResource: APIResource, ResourceWithError { var success: Bool? { return raw?["success"].boolValue } diff --git a/Rocket.Chat/Controllers/Preferences/Language/LanguageViewController.swift b/Rocket.Chat/Controllers/Preferences/Language/LanguageViewController.swift index d915b2b0a4..9c6eb2d851 100644 --- a/Rocket.Chat/Controllers/Preferences/Language/LanguageViewController.swift +++ b/Rocket.Chat/Controllers/Preferences/Language/LanguageViewController.swift @@ -10,7 +10,6 @@ import UIKit final class LanguageViewController: UIViewController { private let viewModel = LanguageViewModel() - private let kAppLanguagesKey = "AppleLanguages" override func viewDidLoad() { super.viewDidLoad() @@ -67,10 +66,9 @@ extension LanguageViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if indexPath.section == 0 { let lang = viewModel.languages[indexPath.row] - - UserDefaults.group.set([lang], forKey: kAppLanguagesKey) + AppManager.language = lang } else { - UserDefaults.group.removeObject(forKey: kAppLanguagesKey) + AppManager.resetLanguage() showMessage() } diff --git a/Rocket.Chat/Controllers/Preferences/Language/LanguageViewModel.swift b/Rocket.Chat/Controllers/Preferences/Language/LanguageViewModel.swift index 2244e01b41..585d476d3c 100644 --- a/Rocket.Chat/Controllers/Preferences/Language/LanguageViewModel.swift +++ b/Rocket.Chat/Controllers/Preferences/Language/LanguageViewModel.swift @@ -13,9 +13,16 @@ final class LanguageViewModel { let resetCellIdentifier = "changeLanguageResetCell" internal var languages: [String] { - return Bundle.main.localizations.filter({ code -> Bool in - return code != "Base" - }) + return AppManager.languages + } + + internal var language: String { + get { + return AppManager.language + } + set { + AppManager.language = newValue + } } internal var title: String { diff --git a/Rocket.Chat/Extensions/API/APIExtensions.swift b/Rocket.Chat/Extensions/API/APIExtensions.swift index 036fde0b6f..1ee48c113a 100644 --- a/Rocket.Chat/Extensions/API/APIExtensions.swift +++ b/Rocket.Chat/Extensions/API/APIExtensions.swift @@ -20,6 +20,7 @@ extension API { let api = API(host: host, version: Version(auth.serverVersion) ?? .zero) api.userId = auth.userId api.authToken = auth.token + api.language = AppManager.language return api } diff --git a/Rocket.Chat/Helpers/Alert.swift b/Rocket.Chat/Helpers/Alert.swift index aaeb16b392..5c646dc998 100644 --- a/Rocket.Chat/Helpers/Alert.swift +++ b/Rocket.Chat/Helpers/Alert.swift @@ -11,6 +11,7 @@ import MBProgressHUD protocol Alerter: class { func alert(title: String, message: String, handler: ((UIAlertAction) -> Void)?) func alertSuccess(title: String, completion: (() -> Void)?) + func alertYesNo(title: String, message: String, handler: @escaping (Bool) -> Void) } extension UIViewController: Alerter { @@ -20,6 +21,20 @@ extension UIViewController: Alerter { present(alert, animated: true, completion: nil) } + func alertYesNo(title: String, message: String, handler: @escaping (Bool) -> Void) { + let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) + + alert.addAction(UIAlertAction(title: localized("global.yes"), style: .destructive, handler: { _ in + handler(true) + })) + + alert.addAction(UIAlertAction(title: localized("global.no"), style: .cancel, handler: { _ in + handler(false) + })) + + present(alert, animated: true, completion: nil) + } + func alertSuccess(title: String, completion: (() -> Void)? = nil) { DispatchQueue.main.async { let successHUD = MBProgressHUD.showAdded(to: self.view, animated: true) diff --git a/Rocket.Chat/Managers/AppManager.swift b/Rocket.Chat/Managers/AppManager.swift index 3f5d3fee44..282a726f01 100644 --- a/Rocket.Chat/Managers/AppManager.swift +++ b/Rocket.Chat/Managers/AppManager.swift @@ -56,6 +56,43 @@ struct AppManager { static var currentRoomId: String? { return ChatViewController.shared?.subscription?.rid } + + // MARK: Localization + + private static let kAppLanguagesKey = "AppleLanguages" + + /** + Reset language for localization + */ + static func resetLanguage() { + UserDefaults.standard.removeObject(forKey: kAppLanguagesKey) + } + + /** + Languages available for localization + */ + static var languages: [String] { + return Bundle.main.localizations.filter({ code -> Bool in + return code != "Base" + }) + } + + /** + Current language for localization + */ + static var language: String { + get { + return UserDefaults.standard.array(forKey: kAppLanguagesKey)?.first as? String ?? Locale.preferredLanguages[0] + } + set { + UserDefaults.standard.set([newValue], forKey: kAppLanguagesKey) + } + } + + /** + Default language + */ + static var defaultLanguage = "en" } extension AppManager { diff --git a/Rocket.Chat/Resources/cs.lproj/Localizable.strings b/Rocket.Chat/Resources/cs.lproj/Localizable.strings index 343899266c..0dff78da01 100644 --- a/Rocket.Chat/Resources/cs.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/cs.lproj/Localizable.strings @@ -1,5 +1,6 @@ // Global "global.ok" = "OK"; +"global.yes" = "Yes"; //TODO "global.no" = "Ne"; "global.cancel" = "Zrušit"; @@ -316,3 +317,5 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO "user_action_sheet.remove" = "Remove from room"; // TODO +"user_action_sheet.remove_confirm.title" = "Remove this user?"; // TODO +"user_action_sheet.remove_confirm.message" = "Are you sure you want to remove '%@' from the room?"; // TODO diff --git a/Rocket.Chat/Resources/de.lproj/Localizable.strings b/Rocket.Chat/Resources/de.lproj/Localizable.strings index 905fe7a264..d744d0fd8b 100644 --- a/Rocket.Chat/Resources/de.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/de.lproj/Localizable.strings @@ -1,5 +1,6 @@ // Global "global.ok" = "OK"; +"global.yes" = "Ja"; "global.no" = "Nein"; "global.cancel" = "Abbrechen"; @@ -316,4 +317,5 @@ // User Action Sheet "user_action_sheet.conversation" = "Konversation"; "user_action_sheet.remove" = "Remove from room"; // TODO - +"user_action_sheet.remove_confirm.title" = "Remove this user?"; // TODO +"user_action_sheet.remove_confirm.message" = "Are you sure you want to remove '%@' from the room?"; // TODO diff --git a/Rocket.Chat/Resources/el.lproj/Localizable.strings b/Rocket.Chat/Resources/el.lproj/Localizable.strings index 7595e7b721..b106e75554 100644 --- a/Rocket.Chat/Resources/el.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/el.lproj/Localizable.strings @@ -1,5 +1,6 @@ // Global "global.ok" = "OK"; +"global.yes" = "Ναί"; "global.no" = "Όχι"; "global.cancel" = "Ακύρωση"; @@ -316,3 +317,5 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO "user_action_sheet.remove" = "Remove from room"; // TODO +"user_action_sheet.remove_confirm.title" = "Remove this user?"; // TODO +"user_action_sheet.remove_confirm.message" = "Are you sure you want to remove '%@' from the room?"; // TODO diff --git a/Rocket.Chat/Resources/en.lproj/Localizable.strings b/Rocket.Chat/Resources/en.lproj/Localizable.strings index 0319a0d6f8..2d00754e1c 100644 --- a/Rocket.Chat/Resources/en.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/en.lproj/Localizable.strings @@ -1,5 +1,6 @@ // Global "global.ok" = "OK"; +"global.yes" = "Yes"; "global.no" = "No"; "global.cancel" = "Cancel"; @@ -316,3 +317,5 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; "user_action_sheet.remove" = "Remove from room"; +"user_action_sheet.remove_confirm.title" = "Remove this user?"; +"user_action_sheet.remove_confirm.message" = "Are you sure you want to remove '%@' from the room?"; diff --git a/Rocket.Chat/Resources/es.lproj/Localizable.strings b/Rocket.Chat/Resources/es.lproj/Localizable.strings index 6d32dee361..698fd8bdff 100644 --- a/Rocket.Chat/Resources/es.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/es.lproj/Localizable.strings @@ -1,5 +1,6 @@ // Global "global.ok" = "OK"; +"global.yes" = "Yes"; "global.no" = "No"; "global.cancel" = "Cancelar"; @@ -315,3 +316,5 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO "user_action_sheet.remove" = "Remove from room"; // TODO +"user_action_sheet.remove_confirm.title" = "Remove this user?"; // TODO +"user_action_sheet.remove_confirm.message" = "Are you sure you want to remove '%@' from the room?"; // TODO diff --git a/Rocket.Chat/Resources/fr.lproj/Localizable.strings b/Rocket.Chat/Resources/fr.lproj/Localizable.strings index 33e01b2f7d..f4afa09a7d 100644 --- a/Rocket.Chat/Resources/fr.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/fr.lproj/Localizable.strings @@ -1,5 +1,6 @@ // Global "global.ok" = "OK"; +"global.yes" = "Oui"; "global.no" = "Non"; "global.cancel" = "Annuler"; @@ -316,3 +317,5 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO "user_action_sheet.remove" = "Remove from room"; // TODO +"user_action_sheet.remove_confirm.title" = "Remove this user?"; // TODO +"user_action_sheet.remove_confirm.message" = "Are you sure you want to remove '%@' from the room?"; // TODO diff --git a/Rocket.Chat/Resources/pl.lproj/Localizable.strings b/Rocket.Chat/Resources/pl.lproj/Localizable.strings index 40610739ff..c1b21fa97d 100644 --- a/Rocket.Chat/Resources/pl.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/pl.lproj/Localizable.strings @@ -1,5 +1,6 @@ // Global "global.ok" = "OK"; +"global.yes" = "Tak"; "global.no" = "Nie"; "global.cancel" = "Anuluj"; @@ -315,3 +316,5 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversation"; // TODO "user_action_sheet.remove" = "Remove from room"; // TODO +"user_action_sheet.remove_confirm.title" = "Remove this user?"; // TODO +"user_action_sheet.remove_confirm.message" = "Are you sure you want to remove '%@' from the room?"; // TODO diff --git a/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings b/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings index 29123b933b..f19fb77498 100644 --- a/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings @@ -1,5 +1,6 @@ // Global "global.ok" = "OK"; +"global.yes" = "Sim"; "global.no" = "Não"; "global.cancel" = "Cancelar"; @@ -315,4 +316,6 @@ // User Action Sheet "user_action_sheet.conversation" = "Conversa"; -"user_action_sheet.remove" = "Remover do canal"; // TODO +"user_action_sheet.remove" = "Remover do canal"; +"user_action_sheet.remove_confirm.title" = "Remove esse usuário?"; +"user_action_sheet.remove_confirm.message" = "Você tem certeza que deseja remover '%@' do canal?"; diff --git a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift index 67a68cf916..1a7c8c23de 100644 --- a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift +++ b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift @@ -14,10 +14,17 @@ protocol UserActionSheetPresenter: Closeable { extension UserActionSheetPresenter where Self: UIViewController { func presentActionSheetForUser(_ user: User, subscription: Subscription? = nil, source: (view: UIView?, rect: CGRect?)? = nil) { + guard let userId = user.identifier else { + return + } + + let controller = UIAlertController(title: user.displayName(), message: nil, preferredStyle: .actionSheet) controller.popoverPresentationController?.sourceView = source?.view controller.popoverPresentationController?.sourceRect = source?.rect ?? source?.view?.frame ?? .zero + // Conversation (Open DM) + controller.addAction(UIAlertAction(title: localized("user_action_sheet.conversation"), style: .default, handler: { [weak self] _ in guard let username = user.username else { return } @@ -27,9 +34,39 @@ extension UserActionSheetPresenter where Self: UIViewController { } })) + // Remove User (Kick) + let api = API.current() + if let subscription = subscription { if AuthManager.currentUser()?.hasPermission(.removeUser, subscription: subscription) == true { - controller.addAction(UIAlertAction(title: localized("user_action_sheet.remove"), style: .destructive)) + controller.addAction(UIAlertAction(title: localized("user_action_sheet.remove"), style: .destructive, handler: { [weak self] _ in + self?.alertYesNo( + title: localized("user_action_sheet.remove_confirm.title"), + message: localized("user_action_sheet.remove_confirm.message"), + handler: { yes in + if yes { + api?.fetch( + RoomKickRequest( + roomId: subscription.rid, + roomType: subscription.type, + userId: userId + ) + ) { response in + switch response { + case .resource(let resource): + if let error = resource.error { + return Alert( + title: "Error", + message: error + ).present() + } + case .error(let error): + print(error) + } + } + } + }) + })) } } From e87be0061011579b289b53a1bf30eb7ae9f7f3bc Mon Sep 17 00:00:00 2001 From: cardoso Date: Mon, 21 May 2018 11:47:27 -0300 Subject: [PATCH 09/17] Make roles fetching more testable --- .../API/Clients/SubscriptionsClient.swift | 24 ++++++++++++++++++ .../Chat/ChatControllerRolesController.swift | 25 ++----------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Rocket.Chat/API/Clients/SubscriptionsClient.swift b/Rocket.Chat/API/Clients/SubscriptionsClient.swift index fdac326999..9aa1f7911f 100644 --- a/Rocket.Chat/API/Clients/SubscriptionsClient.swift +++ b/Rocket.Chat/API/Clients/SubscriptionsClient.swift @@ -119,6 +119,30 @@ struct SubscriptionsClient: APIClient { } } + func fetchRoles(subscription: Subscription, realm: Realm? = Realm.current) { + let rid = subscription.rid + let rolesRequest = RoomRolesRequest(roomName: subscription.name, subscriptionType: subscription.type) + API.current()?.fetch(rolesRequest, completion: { result in + switch result { + case .resource(let resource): + if let subscription = Subscription.find(rid: rid) { + Realm.executeOnMainThread({ (realm) in + subscription.usersRoles.removeAll() + resource.roomRoles?.forEach({ (role) in + subscription.usersRoles.append(role) + }) + + realm.add(subscription, update: true) + }) + } + + // Fail silently + case .error(let error): + print(error) + } + }) + } + // fallback for servers < 0.60.0 func fetchSubscriptionsFallback(updatedSince: Date?, realm: Realm? = Realm.current, completion: (() -> Void)?) { var params: [[String: Any]] = [] diff --git a/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift b/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift index 1d49adfc35..45e17fc346 100644 --- a/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift +++ b/Rocket.Chat/Controllers/Chat/ChatControllerRolesController.swift @@ -10,36 +10,15 @@ import Foundation import RealmSwift extension ChatViewController { - func updateSubscriptionRoles() { guard + let client = API.current()?.client(SubscriptionsClient.self), let subscription = subscription, subscription.type != .directMessage else { return } - let rid = subscription.rid - let rolesRequest = RoomRolesRequest(roomName: subscription.name, subscriptionType: subscription.type) - API.current()?.fetch(rolesRequest, completion: { result in - switch result { - case .resource(let resource): - if let subscription = Subscription.find(rid: rid) { - Realm.executeOnMainThread({ (realm) in - subscription.usersRoles.removeAll() - resource.roomRoles?.forEach({ (role) in - subscription.usersRoles.append(role) - }) - - realm.add(subscription, update: true) - }) - } - - // Fail silently - case .error(let error): - print(error) - } - }) + client.fetchRoles(subscription: subscription) } - } From 12195f2271031d5126144e14a8edfcaf5120b5f8 Mon Sep 17 00:00:00 2001 From: cardoso Date: Mon, 21 May 2018 12:59:57 -0300 Subject: [PATCH 10/17] Add test for role fetching --- .../API/Clients/SubscriptionsClient.swift | 31 ++++++---- .../API/Clients/SubscriptionsClientSpec.swift | 57 +++++++++++++++++++ Rocket.ChatTests/Models/UserSpec.swift | 5 +- 3 files changed, 79 insertions(+), 14 deletions(-) diff --git a/Rocket.Chat/API/Clients/SubscriptionsClient.swift b/Rocket.Chat/API/Clients/SubscriptionsClient.swift index 9aa1f7911f..ebd324a997 100644 --- a/Rocket.Chat/API/Clients/SubscriptionsClient.swift +++ b/Rocket.Chat/API/Clients/SubscriptionsClient.swift @@ -119,28 +119,35 @@ struct SubscriptionsClient: APIClient { } } - func fetchRoles(subscription: Subscription, realm: Realm? = Realm.current) { + func fetchRoles(subscription: Subscription, realm: Realm? = Realm.current, completion: (() -> Void)? = nil) { let rid = subscription.rid let rolesRequest = RoomRolesRequest(roomName: subscription.name, subscriptionType: subscription.type) - API.current()?.fetch(rolesRequest, completion: { result in + + let currentRealm = realm + + api.fetch(rolesRequest) { result in switch result { case .resource(let resource): - if let subscription = Subscription.find(rid: rid) { - Realm.executeOnMainThread({ (realm) in - subscription.usersRoles.removeAll() - resource.roomRoles?.forEach({ (role) in - subscription.usersRoles.append(role) - }) - - realm.add(subscription, update: true) - }) + if let subscription = Subscription.find(rid: rid, realm: currentRealm) { + try? currentRealm?.write { + let subscriptionCopy = Subscription(value: subscription) + + subscriptionCopy.usersRoles.removeAll() + resource.roomRoles?.forEach { role in + subscriptionCopy.usersRoles.append(role) + } + + currentRealm?.add(subscriptionCopy, update: true) + } + + completion?() } // Fail silently case .error(let error): print(error) } - }) + } } // fallback for servers < 0.60.0 diff --git a/Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift b/Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift index 10e812abd4..90a43e3286 100644 --- a/Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift +++ b/Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift @@ -204,4 +204,61 @@ class SubscriptionsClientSpec: XCTestCase, RealmTestCase { wait(for: [expectation], timeout: 3) } + + func testFetchRoles() { + let realm = testRealm() + let api = MockAPI() + let client = SubscriptionsClient(api: api) + let subscription = Subscription.testInstance("test-roles") + let user = User.testInstance("test-user") + let user2 = User.testInstance("test-user2") + + try? realm.write { + realm.add(user, update: true) + realm.add(user2, update: true) + realm.add(subscription, update: true) + } + + api.nextResult = JSON([ + "roles": [ + [ + "u": [ + "username": "test-user-username", + "_id": "test-user-identifier" + ], + "_id": "LG62dmF5XySq63GWk", + "rid": "test-roles-rid", + "roles": ["fixer", "moderator"] + ], + [ + "u": [ + "username": "test-user2-username", + "_id": "test-user2-identifier" + ], + "_id": "qa62dasdSq63Gak", + "rid": "test-roles-rid", + "roles": ["owner"] + ] + ], + "success": true + ]) + + client.fetchRoles(subscription: subscription, realm: realm) + + let expectation = XCTestExpectation(description: "subscription has correct roles for user") + DispatchQueue.main.asyncAfter(deadline: .now() + 0.4, execute: { + guard + let subscription = realm.objects(Subscription.self).first, + let user = User.find(username: "test-user-username", realm: realm), + let user2 = User.find(username: "test-user2-username", realm: realm) + else { + return + } + + if user.rolesInSubscription(subscription).count == 2, user2.rolesInSubscription(subscription).count == 1 { + expectation.fulfill() + } + }) + wait(for: [expectation], timeout: 3) + } } diff --git a/Rocket.ChatTests/Models/UserSpec.swift b/Rocket.ChatTests/Models/UserSpec.swift index 2fbd4dff1d..f87020f053 100644 --- a/Rocket.ChatTests/Models/UserSpec.swift +++ b/Rocket.ChatTests/Models/UserSpec.swift @@ -15,9 +15,10 @@ import SwiftyJSON // MARK: Test Instance extension User { - static func testInstance() -> User { + static func testInstance(_ name: String = "user") -> User { let user = User() - user.username = "user-username" + user.identifier = "\(name)-identifier" + user.username = "\(name)-username" return user } } From d207fb8af2420f14164dbcfbb0089ac283e44e54 Mon Sep 17 00:00:00 2001 From: cardoso Date: Mon, 21 May 2018 13:15:01 -0300 Subject: [PATCH 11/17] Localize error alert title --- Rocket.Chat/Resources/cs.lproj/Localizable.strings | 3 ++- Rocket.Chat/Resources/de.lproj/Localizable.strings | 1 + Rocket.Chat/Resources/el.lproj/Localizable.strings | 1 + Rocket.Chat/Resources/en.lproj/Localizable.strings | 1 + Rocket.Chat/Resources/es.lproj/Localizable.strings | 1 + Rocket.Chat/Resources/fr.lproj/Localizable.strings | 1 + Rocket.Chat/Resources/pl.lproj/Localizable.strings | 1 + Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings | 1 + Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift | 3 +-- 9 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Rocket.Chat/Resources/cs.lproj/Localizable.strings b/Rocket.Chat/Resources/cs.lproj/Localizable.strings index 0dff78da01..fdd27809ea 100644 --- a/Rocket.Chat/Resources/cs.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/cs.lproj/Localizable.strings @@ -1,8 +1,9 @@ // Global "global.ok" = "OK"; -"global.yes" = "Yes"; //TODO +"global.yes" = "Ano"; "global.no" = "Ne"; "global.cancel" = "Zrušit"; +"global.error" = "Chyba"; // Errors "error.socket.default_error.title" = "Jejky!"; diff --git a/Rocket.Chat/Resources/de.lproj/Localizable.strings b/Rocket.Chat/Resources/de.lproj/Localizable.strings index d744d0fd8b..fb56a391d4 100644 --- a/Rocket.Chat/Resources/de.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/de.lproj/Localizable.strings @@ -3,6 +3,7 @@ "global.yes" = "Ja"; "global.no" = "Nein"; "global.cancel" = "Abbrechen"; +"global.error" = "Fehler"; // Errors "error.socket.default_error.title" = "Oops!"; diff --git a/Rocket.Chat/Resources/el.lproj/Localizable.strings b/Rocket.Chat/Resources/el.lproj/Localizable.strings index b106e75554..b45ab36644 100644 --- a/Rocket.Chat/Resources/el.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/el.lproj/Localizable.strings @@ -3,6 +3,7 @@ "global.yes" = "Ναί"; "global.no" = "Όχι"; "global.cancel" = "Ακύρωση"; +"global.error" = "λάθος"; // Errors "error.socket.default_error.title" = "Ωπ!"; diff --git a/Rocket.Chat/Resources/en.lproj/Localizable.strings b/Rocket.Chat/Resources/en.lproj/Localizable.strings index 2d00754e1c..95d6e738e1 100644 --- a/Rocket.Chat/Resources/en.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/en.lproj/Localizable.strings @@ -3,6 +3,7 @@ "global.yes" = "Yes"; "global.no" = "No"; "global.cancel" = "Cancel"; +"global.error" = "Error"; // Errors "error.socket.default_error.title" = "Oops!"; diff --git a/Rocket.Chat/Resources/es.lproj/Localizable.strings b/Rocket.Chat/Resources/es.lproj/Localizable.strings index 698fd8bdff..4d11bc11ea 100644 --- a/Rocket.Chat/Resources/es.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/es.lproj/Localizable.strings @@ -3,6 +3,7 @@ "global.yes" = "Yes"; "global.no" = "No"; "global.cancel" = "Cancelar"; +"global.error" = "Error"; // Errors "error.socket.default_error.title" = "Uy!"; diff --git a/Rocket.Chat/Resources/fr.lproj/Localizable.strings b/Rocket.Chat/Resources/fr.lproj/Localizable.strings index f4afa09a7d..19af066ad4 100644 --- a/Rocket.Chat/Resources/fr.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/fr.lproj/Localizable.strings @@ -3,6 +3,7 @@ "global.yes" = "Oui"; "global.no" = "Non"; "global.cancel" = "Annuler"; +"global.error" = "Erreur"; // Errors "error.socket.default_error.title" = "Oups!"; diff --git a/Rocket.Chat/Resources/pl.lproj/Localizable.strings b/Rocket.Chat/Resources/pl.lproj/Localizable.strings index c1b21fa97d..21910c5575 100644 --- a/Rocket.Chat/Resources/pl.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/pl.lproj/Localizable.strings @@ -3,6 +3,7 @@ "global.yes" = "Tak"; "global.no" = "Nie"; "global.cancel" = "Anuluj"; +"global.error" = "Błąd"; // Errors "error.socket.default_error.title" = "Ups!"; diff --git a/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings b/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings index f19fb77498..39a847eb91 100644 --- a/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings +++ b/Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings @@ -3,6 +3,7 @@ "global.yes" = "Sim"; "global.no" = "Não"; "global.cancel" = "Cancelar"; +"global.error" = "Error"; // Errors "error.socket.default_error.title" = "Oops!"; diff --git a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift index 1a7c8c23de..face92c3e8 100644 --- a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift +++ b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift @@ -18,7 +18,6 @@ extension UserActionSheetPresenter where Self: UIViewController { return } - let controller = UIAlertController(title: user.displayName(), message: nil, preferredStyle: .actionSheet) controller.popoverPresentationController?.sourceView = source?.view controller.popoverPresentationController?.sourceRect = source?.rect ?? source?.view?.frame ?? .zero @@ -56,7 +55,7 @@ extension UserActionSheetPresenter where Self: UIViewController { case .resource(let resource): if let error = resource.error { return Alert( - title: "Error", + title: localized("global.error"), message: error ).present() } From 25378ca7e2ee48d0c966c1d87cba67e52bd9f4c0 Mon Sep 17 00:00:00 2001 From: cardoso Date: Mon, 21 May 2018 13:18:36 -0300 Subject: [PATCH 12/17] Fix code style --- Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift b/Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift index 90a43e3286..aa27c28c59 100644 --- a/Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift +++ b/Rocket.ChatTests/API/Clients/SubscriptionsClientSpec.swift @@ -255,7 +255,7 @@ class SubscriptionsClientSpec: XCTestCase, RealmTestCase { return } - if user.rolesInSubscription(subscription).count == 2, user2.rolesInSubscription(subscription).count == 1 { + if user.rolesInSubscription(subscription).count == 2, user2.rolesInSubscription(subscription).count == 1 { expectation.fulfill() } }) From a7670903ca2391b131ca795491a6d972d17336dd Mon Sep 17 00:00:00 2001 From: cardoso Date: Tue, 22 May 2018 19:16:39 -0300 Subject: [PATCH 13/17] Fix not refreshing screen after removing user --- .../Chat/MembersListViewController.swift | 14 ++++- .../UserActionSheetPresenter.swift | 51 +++++++++---------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/Rocket.Chat/Controllers/Chat/MembersListViewController.swift b/Rocket.Chat/Controllers/Chat/MembersListViewController.swift index 3575faf90c..ff71f45593 100644 --- a/Rocket.Chat/Controllers/Chat/MembersListViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MembersListViewController.swift @@ -72,6 +72,10 @@ class MembersListViewController: BaseViewController { var data = MembersListViewData() @objc func refreshControlDidPull(_ sender: UIRefreshControl) { + refreshMembers() + } + + func refreshMembers() { let data = MembersListViewData() data.subscription = self.data.subscription data.loadMoreMembers { [weak self] in @@ -175,7 +179,15 @@ extension MembersListViewController: UITableViewDataSource { extension MembersListViewController: UITableViewDelegate, UserActionSheetPresenter { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) - presentActionSheetForUser(data.member(at: indexPath.row), subscription: data.subscription, source: (tableView, tableView.rectForRow(at: indexPath))) + + let user = data.member(at: indexPath.row) + let subscription = data.subscription + let rect = tableView.rectForRow(at: indexPath) + presentActionSheetForUser(user, subscription: subscription, source: (tableView, rect)) { [weak self] action in + if case .remove = action { + self?.refreshMembers() + } + } } func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { diff --git a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift index face92c3e8..a741b6088d 100644 --- a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift +++ b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift @@ -8,12 +8,18 @@ import Foundation +enum UserAction { + case remove + case conversation + case none +} + protocol UserActionSheetPresenter: Closeable { - func presentActionSheetForUser(_ user: User, subscription: Subscription?, source: (view: UIView?, rect: CGRect?)?) + func presentActionSheetForUser(_ user: User, subscription: Subscription?, source: (view: UIView?, rect: CGRect?)?, completion: ((UserAction) -> Void)?) } extension UserActionSheetPresenter where Self: UIViewController { - func presentActionSheetForUser(_ user: User, subscription: Subscription? = nil, source: (view: UIView?, rect: CGRect?)? = nil) { + func presentActionSheetForUser(_ user: User, subscription: Subscription? = nil, source: (view: UIView?, rect: CGRect?)? = nil, completion: ((UserAction) -> Void)? = nil) { guard let userId = user.identifier else { return } @@ -28,6 +34,7 @@ extension UserActionSheetPresenter where Self: UIViewController { guard let username = user.username else { return } AppManager.openDirectMessage(username: username) { + completion?(.conversation) controller.dismiss(animated: true, completion: nil) self?.close(animated: true) } @@ -39,32 +46,24 @@ extension UserActionSheetPresenter where Self: UIViewController { if let subscription = subscription { if AuthManager.currentUser()?.hasPermission(.removeUser, subscription: subscription) == true { controller.addAction(UIAlertAction(title: localized("user_action_sheet.remove"), style: .destructive, handler: { [weak self] _ in - self?.alertYesNo( - title: localized("user_action_sheet.remove_confirm.title"), - message: localized("user_action_sheet.remove_confirm.message"), - handler: { yes in - if yes { - api?.fetch( - RoomKickRequest( - roomId: subscription.rid, - roomType: subscription.type, - userId: userId - ) - ) { response in - switch response { - case .resource(let resource): - if let error = resource.error { - return Alert( - title: localized("global.error"), - message: error - ).present() - } - case .error(let error): - print(error) - } + let message = String(format: localized("user_action_sheet.remove_confirm.message"), user.username ?? "") + self?.alertYesNo(title: localized("user_action_sheet.remove_confirm.title"), message: message) { yes in + guard yes else { completion?(.none); return } + + api?.fetch(RoomKickRequest(roomId: subscription.rid, roomType: subscription.type, userId: userId)) { response in + switch response { + case .resource(let resource): + if let error = resource.error { + completion?(.none) + return Alert(title: localized("global.error"), message: error).present() + } else { + completion?(.remove) } + case .error: + completion?(.none) } - }) + } + } })) } } From 81df91948d282644d717bbcf2cd73aa009c485ed Mon Sep 17 00:00:00 2001 From: cardoso Date: Tue, 22 May 2018 19:22:56 -0300 Subject: [PATCH 14/17] Fix not refreshing members list title after removing --- .../Chat/MembersListViewController.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Rocket.Chat/Controllers/Chat/MembersListViewController.swift b/Rocket.Chat/Controllers/Chat/MembersListViewController.swift index ff71f45593..f73d452b7b 100644 --- a/Rocket.Chat/Controllers/Chat/MembersListViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MembersListViewController.swift @@ -69,7 +69,15 @@ class MembersListViewController: BaseViewController { @IBOutlet weak var membersTableView: UITableView! var loaderCell: LoaderTableViewCell! - var data = MembersListViewData() + var data = MembersListViewData() { + didSet { + UIView.performWithoutAnimation { + membersTableView?.reloadData() + } + + title = data.title + } + } @objc func refreshControlDidPull(_ sender: UIRefreshControl) { refreshMembers() @@ -84,10 +92,6 @@ class MembersListViewController: BaseViewController { if self?.membersTableView?.refreshControl?.isRefreshing ?? false { self?.membersTableView?.refreshControl?.endRefreshing() } - - UIView.performWithoutAnimation { - self?.membersTableView?.reloadData() - } } } From 19c1e80c0b11a60d58b14d27b5c036c0cb75f7b2 Mon Sep 17 00:00:00 2001 From: cardoso Date: Fri, 25 May 2018 10:21:24 -0300 Subject: [PATCH 15/17] Don't allow user to open action sheet on himself --- Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift index a741b6088d..816697e97a 100644 --- a/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift +++ b/Rocket.Chat/Views/ActionSheets/UserActionSheetPresenter.swift @@ -20,7 +20,7 @@ protocol UserActionSheetPresenter: Closeable { extension UserActionSheetPresenter where Self: UIViewController { func presentActionSheetForUser(_ user: User, subscription: Subscription? = nil, source: (view: UIView?, rect: CGRect?)? = nil, completion: ((UserAction) -> Void)? = nil) { - guard let userId = user.identifier else { + guard let userId = user.identifier, AuthManager.currentUser()?.identifier != userId else { return } From 44f8862a6781a5fcce4c6b571cc56a5050566ae0 Mon Sep 17 00:00:00 2001 From: Rafael Kellermann Streit Date: Fri, 25 May 2018 14:57:37 -0300 Subject: [PATCH 16/17] Fixed a mistake on conflicts solution --- Rocket.Chat.xcodeproj/project.pbxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Rocket.Chat.xcodeproj/project.pbxproj b/Rocket.Chat.xcodeproj/project.pbxproj index fae8dc89b1..1433efdc43 100644 --- a/Rocket.Chat.xcodeproj/project.pbxproj +++ b/Rocket.Chat.xcodeproj/project.pbxproj @@ -3841,7 +3841,6 @@ 4199A9891DABCC570035F820 /* Emojione.swift in Sources */, 4116CBE720B599E6007E7163 /* StatusViewModel.swift in Sources */, 418C74431FA3813F00499577 /* CompoundPickerViewDelegate.swift in Sources */, - 80235D1B1F74070100A56CA5 /* RoomMembersRequest.swift in Sources */, 41A1748C1DD9F2F900188E3B /* UIViewControllerExtension.swift in Sources */, 80235D1B1F74070100A56CA5 /* SubscriptionMembersRequest.swift in Sources */, 3330329A20738E1500A9514D /* SubscriptionManagerRooms.swift in Sources */, From d3a7ff3a45de78013d7cc559fc8a8ee7dca32953 Mon Sep 17 00:00:00 2001 From: Rafael Kellermann Streit Date: Fri, 25 May 2018 15:15:35 -0300 Subject: [PATCH 17/17] Fixed testing --- Rocket.Chat.xcodeproj/project.pbxproj | 38 +++++++++------------------ 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/Rocket.Chat.xcodeproj/project.pbxproj b/Rocket.Chat.xcodeproj/project.pbxproj index 1433efdc43..211d5014e2 100644 --- a/Rocket.Chat.xcodeproj/project.pbxproj +++ b/Rocket.Chat.xcodeproj/project.pbxproj @@ -266,14 +266,6 @@ 41D0DA5820991BAE008649E7 /* UploadMessageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80054CF61FD9AA1B00F5ECF9 /* UploadMessageRequest.swift */; }; 41D51B0620A62DD60073E8E7 /* Role.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D51B0520A62DD60073E8E7 /* Role.swift */; }; 41D51B0720A62DD60073E8E7 /* Role.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D51B0520A62DD60073E8E7 /* Role.swift */; }; - 41D51B0920A635150073E8E7 /* RoomRolesRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D51B0820A635150073E8E7 /* RoomRolesRequestSpec.swift */; }; - 41D5BC311DAFBEF4009A493A /* UIViewExtentions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D5BC301DAFBEF4009A493A /* UIViewExtentions.swift */; }; - 41D701D61E67111E00FED2EE /* MessageTextFontAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D701D51E67111E00FED2EE /* MessageTextFontAttributes.swift */; }; - 41D701D81E6763D100FED2EE /* NSAttributedStringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D701D71E6763D100FED2EE /* NSAttributedStringExtensions.swift */; }; - 41D7CA871E644E47000F38EA /* MessageExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D7CA861E644E47000F38EA /* MessageExtensions.swift */; }; - 41D894021F4EF64200E284D2 /* ChatDirectMessageHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D894011F4EF64200E284D2 /* ChatDirectMessageHeaderCell.swift */; }; - 41D894041F4EF65700E284D2 /* ChatDirectMessageHeaderCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 41D894031F4EF65700E284D2 /* ChatDirectMessageHeaderCell.xib */; }; - 41D51B0920A635150073E8E7 /* SubscriptionRolesRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D51B0820A635150073E8E7 /* SubscriptionRolesRequestSpec.swift */; }; 41D8EC8E1F780C3800764B36 /* ChatControllerTitleViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D8EC8D1F780C3800764B36 /* ChatControllerTitleViewProtocol.swift */; }; 41D8EC941F78151A00764B36 /* ChannelActionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D8EC931F78151A00764B36 /* ChannelActionsViewController.swift */; }; 41DAE93C1D318E280098E068 /* SubscriptionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41DAE93B1D318E280098E068 /* SubscriptionManager.swift */; }; @@ -296,6 +288,7 @@ 41E2FA071D41513C00238DFD /* ChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E2FA061D41513C00238DFD /* ChatViewController.swift */; }; 41E423002044216000543877 /* UIColorExtensionSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E422FF2044216000543877 /* UIColorExtensionSpec.swift */; }; 41E53A171E546F5500C3FBB3 /* UINibExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E53A161E546F5500C3FBB3 /* UINibExtensions.swift */; }; + 41E96C3120B88A0000ACBA92 /* RoomRolesRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E96C3020B88A0000ACBA92 /* RoomRolesRequestSpec.swift */; }; 41E991D41D343A9F00BDDCA8 /* DateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E991D31D343A9F00BDDCA8 /* DateExtension.swift */; }; 41E9BD0D208EA4040084D4D8 /* AuthInternalExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E9BD0C208EA4040084D4D8 /* AuthInternalExtensions.swift */; }; 41E9BD0F208EA8C40084D4D8 /* SubscriptionQueriesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E9BD0E208EA8C40084D4D8 /* SubscriptionQueriesSpec.swift */; }; @@ -980,12 +973,6 @@ 41D3A62F1E0805490011949D /* ChatMessageDaySeparator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatMessageDaySeparator.swift; sourceTree = ""; }; 41D4ABAA1F4CD10C00ACDDDD /* ChatCollectionViewFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatCollectionViewFlowLayout.swift; sourceTree = ""; }; 41D51B0520A62DD60073E8E7 /* Role.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Role.swift; sourceTree = ""; }; - 41D51B0820A635150073E8E7 /* RoomRolesRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomRolesRequestSpec.swift; sourceTree = ""; }; - 41D5BC301DAFBEF4009A493A /* UIViewExtentions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewExtentions.swift; sourceTree = ""; }; - 41D701D51E67111E00FED2EE /* MessageTextFontAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageTextFontAttributes.swift; sourceTree = ""; }; - 41D701D71E6763D100FED2EE /* NSAttributedStringExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSAttributedStringExtensions.swift; sourceTree = ""; }; - 41D7CA861E644E47000F38EA /* MessageExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageExtensions.swift; sourceTree = ""; }; - 41D51B0820A635150073E8E7 /* SubscriptionRolesRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionRolesRequestSpec.swift; sourceTree = ""; }; 41D894011F4EF64200E284D2 /* ChatDirectMessageHeaderCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatDirectMessageHeaderCell.swift; sourceTree = ""; }; 41D894031F4EF65700E284D2 /* ChatDirectMessageHeaderCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ChatDirectMessageHeaderCell.xib; sourceTree = ""; }; 41D8EC8D1F780C3800764B36 /* ChatControllerTitleViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatControllerTitleViewProtocol.swift; sourceTree = ""; }; @@ -1016,6 +1003,7 @@ 41E2FA061D41513C00238DFD /* ChatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatViewController.swift; sourceTree = ""; }; 41E422FF2044216000543877 /* UIColorExtensionSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtensionSpec.swift; sourceTree = ""; }; 41E53A161E546F5500C3FBB3 /* UINibExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UINibExtensions.swift; sourceTree = ""; }; + 41E96C3020B88A0000ACBA92 /* RoomRolesRequestSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoomRolesRequestSpec.swift; sourceTree = ""; }; 41E991D31D343A9F00BDDCA8 /* DateExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = ""; }; 41E9BD0C208EA4040084D4D8 /* AuthInternalExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthInternalExtensions.swift; sourceTree = ""; }; 41E9BD0E208EA8C40084D4D8 /* SubscriptionQueriesSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionQueriesSpec.swift; sourceTree = ""; }; @@ -2317,7 +2305,6 @@ 41E2FA061D41513C00238DFD /* ChatViewController.swift */, 41B9635F207E46F10068F1A6 /* ChatViewControllerTextViewDelegate.swift */, 80CC8A1A20ACEA6A009D64DF /* ChatControllerUserActionPresenter.swift */, - 4112BEEB1E7971A400E734CB /* MainChatViewController.swift */, 800FCD3D1F72893E00D9A692 /* MembersListViewController.swift */, 99DBB8732090360600382DB2 /* MessagesListControllerSearch.swift */, 800E22831F8500A200DA84F1 /* MessagesListViewController.swift */, @@ -2534,7 +2521,7 @@ 80235D211F7442F700A56CA5 /* RoomMembersRequestSpec.swift */, 990FF6D7207438D4007B4A53 /* RoomMentionsRequestSpec.swift */, 992B5AB7209A2890009C8123 /* RoomFilesRequestSpec.swift */, - 41D51B0820A635150073E8E7 /* RoomRolesRequestSpec.swift */, + 41E96C3020B88A0000ACBA92 /* RoomRolesRequestSpec.swift */, 8039441220AF17F1002F317A /* RoomKickRequestSpec.swift */, ); path = Room; @@ -2567,21 +2554,21 @@ path = VoiceOver; sourceTree = ""; }; - 8052F75A20B7522900B3B0CF /* UIAlertAction */ = { + 8039441620AF61ED002F317A /* Base */ = { isa = PBXGroup; children = ( - 8052F75820B7522100B3B0CF /* UIAlertActionImage.swift */, - 8052F75B20B7529800B3B0CF /* UIAlertActionTitleTextAlignment.swift */, + 8039441720AF620C002F317A /* ResourceWithError.swift */, ); - path = UIAlertAction; + path = Base; sourceTree = ""; }; - 8039441620AF61ED002F317A /* Base */ = { + 8052F75A20B7522900B3B0CF /* UIAlertAction */ = { isa = PBXGroup; children = ( - 8039441720AF620C002F317A /* ResourceWithError.swift */, + 8052F75820B7522100B3B0CF /* UIAlertActionImage.swift */, + 8052F75B20B7529800B3B0CF /* UIAlertActionTitleTextAlignment.swift */, ); - path = Base; + path = UIAlertAction; sourceTree = ""; }; 8062E32F20A3A2A30044F407 /* Subscription */ = { @@ -3841,8 +3828,7 @@ 4199A9891DABCC570035F820 /* Emojione.swift in Sources */, 4116CBE720B599E6007E7163 /* StatusViewModel.swift in Sources */, 418C74431FA3813F00499577 /* CompoundPickerViewDelegate.swift in Sources */, - 41A1748C1DD9F2F900188E3B /* UIViewControllerExtension.swift in Sources */, - 80235D1B1F74070100A56CA5 /* SubscriptionMembersRequest.swift in Sources */, + 80235D1B1F74070100A56CA5 /* RoomMembersRequest.swift in Sources */, 3330329A20738E1500A9514D /* SubscriptionManagerRooms.swift in Sources */, 8020CCF51FEAD8C9003424F4 /* EmojiPickerController.swift in Sources */, D1D535EE1F708628006625D2 /* APIRequest.swift in Sources */, @@ -4090,7 +4076,6 @@ 77C2612E1F97453600724A1F /* TextFieldSpec.swift in Sources */, 4171ABA51E7C056E009FC3F0 /* AvatarViewSpec.swift in Sources */, 994DA2B32065486D00083FB8 /* WebBrowserViewModelSpec.swift in Sources */, - 41D51B0920A635150073E8E7 /* RoomRolesRequestSpec.swift in Sources */, 805DEC391FFE54820033151B /* CustomEmojiSpec.swift in Sources */, D18675EA1F70A58B00406FB4 /* InfoRequestSpec.swift in Sources */, 808792361FB145B200EFE77F /* PermissionManagerSpec.swift in Sources */, @@ -4178,6 +4163,7 @@ 80D41E01209248F800034D1F /* StarMessageRequestSpec.swift in Sources */, 8062E32E20A366360044F407 /* SubscriptionsRequestSpec.swift in Sources */, 99F41BD020658C3400B240FC /* NewPasswordViewModelSpec.swift in Sources */, + 41E96C3120B88A0000ACBA92 /* RoomRolesRequestSpec.swift in Sources */, 416296F91F41B42B00BCCEDD /* UploadHelperSpec.swift in Sources */, 80A63C511F719FB300FE5AC4 /* RoomInfoRequestSpec.swift in Sources */, 41FE55531F6038D60071E97A /* DatabaseManagerSpec.swift in Sources */,