Skip to content

Commit

Permalink
Invite by email a new user failed (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Loriaux committed Mar 16, 2022
1 parent c14fd63 commit 16b49c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
11 changes: 1 addition & 10 deletions Tchap/Managers/Invite/InviteService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ final class InviteService: InviteServiceType {
private let session: MXSession

private let discussionFinder: DiscussionFinderType
private let identityService: MXIdentityService
private let userService: UserServiceType
private let roomService: RoomServiceType

Expand All @@ -40,14 +39,6 @@ final class InviteService: InviteServiceType {
self.discussionFinder = DiscussionFinder(session: session)
self.userService = UserService(session: session)
self.roomService = RoomService(session: session)

let server = session.matrixRestClient.identityServer ?? session.matrixRestClient.homeserver
// swiftlint:disable force_unwrapping
let identityServerURL = URL(string: server!)!
// swiftlint:enable force_unwrapping
self.identityService = MXIdentityService(identityServer: identityServerURL,
accessToken: nil,
homeserverRestClient: self.session.matrixRestClient)
}

func sendEmailInvite(to email: String, completion: @escaping (MXResponse<InviteServiceResult>) -> Void) {
Expand Down Expand Up @@ -120,7 +111,7 @@ final class InviteService: InviteServiceType {
// Check whether a Tchap account has been created for this email. The closure returns a nil identifier when no account exists.
private func discoverUser(with email: String, completion: @escaping (MXResponse<InviteServiceDiscoverUserResult>) -> Void) {
let pid = MX3PID(medium: .email, address: email)
_ = self.identityService.lookup3PIDs([pid]) { response in
_ = self.session.identityService.lookup3PIDs([pid]) { response in
if let responseValue = response.value?[pid] {
completion(MXResponse.success(.bound(userID: responseValue)))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ final class ThirdPartyIDResolver: NSObject, ThirdPartyIDResolverType {
guard let identityServerURL = URL(string: identityServer) else {
return nil
}

let accessToken = session.credentials.accessToken
let identityService = MXIdentityService(identityServer: identityServerURL,
accessToken: nil,
accessToken: accessToken,
homeserverRestClient: self.session.matrixRestClient)
let pids: [MX3PID]? = threepids.compactMap { tempPid in
return MX3PID.threePidFromArray(tempPid)
Expand Down
1 change: 1 addition & 0 deletions changelog.d/479.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix Invite by email a new user failed

0 comments on commit 16b49c7

Please sign in to comment.