Merge pull request #6101 from chagai95/native-lookup-fixes
Native lookup fixes
This commit is contained in:
commit
6fda2cc7b3
|
@ -0,0 +1 @@
|
||||||
|
Refactor - better naming, return native user id and not sip user id and create a dm with the native user instead of with the sip user.
|
|
@ -22,6 +22,7 @@ import im.vector.app.features.call.vectorCallService
|
||||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||||
import im.vector.app.features.createdirect.DirectRoomHelper
|
import im.vector.app.features.createdirect.DirectRoomHelper
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class DialPadLookup @Inject constructor(
|
class DialPadLookup @Inject constructor(
|
||||||
|
@ -42,18 +43,23 @@ class DialPadLookup @Inject constructor(
|
||||||
val sipUserId = thirdPartyUser.userId
|
val sipUserId = thirdPartyUser.userId
|
||||||
val nativeLookupResults = session.sipNativeLookup(thirdPartyUser.userId)
|
val nativeLookupResults = session.sipNativeLookup(thirdPartyUser.userId)
|
||||||
// If I have a native user I check for an existing native room with him...
|
// If I have a native user I check for an existing native room with him...
|
||||||
val roomId = if (nativeLookupResults.isNotEmpty()) {
|
if (nativeLookupResults.isNotEmpty()) {
|
||||||
val nativeUserId = nativeLookupResults.first().userId
|
val nativeUserId = nativeLookupResults.first().userId
|
||||||
if (nativeUserId == session.myUserId) {
|
if (nativeUserId == session.myUserId) {
|
||||||
throw Failure.NumberIsYours
|
throw Failure.NumberIsYours
|
||||||
}
|
}
|
||||||
session.roomService().getExistingDirectRoomWithUser(nativeUserId)
|
var nativeRoomId = session.roomService().getExistingDirectRoomWithUser(nativeUserId)
|
||||||
// if there is not, just create a DM with the sip user
|
if (nativeRoomId == null) {
|
||||||
?: directRoomHelper.ensureDMExists(sipUserId)
|
// if there is no existing native room with the existing native user,
|
||||||
} else {
|
// just create a DM with the native user
|
||||||
// do the same if there is no corresponding native user.
|
nativeRoomId = directRoomHelper.ensureDMExists(nativeUserId)
|
||||||
directRoomHelper.ensureDMExists(sipUserId)
|
|
||||||
}
|
}
|
||||||
return Result(userId = sipUserId, roomId = roomId)
|
Timber.d("lookupPhoneNumber with nativeUserId: $nativeUserId and nativeRoomId: $nativeRoomId")
|
||||||
|
return Result(userId = nativeUserId, roomId = nativeRoomId)
|
||||||
|
}
|
||||||
|
// If there is no native user then we return sipUserId and sipRoomId - this is usually a PSTN call.
|
||||||
|
val sipRoomId = directRoomHelper.ensureDMExists(sipUserId)
|
||||||
|
Timber.d("lookupPhoneNumber with sipRoomId: $sipRoomId and sipUserId: $sipUserId")
|
||||||
|
return Result(userId = sipUserId, roomId = sipRoomId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue