This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 832
Fix calls on homeservers without the unstable thirdparty endpoints #8931
Merged
t3chguy
merged 3 commits into
matrix-org:develop
from
deepbluev7:fix-calls-on-non-synapse
Jul 1, 2022
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ describe('CallHandler', () => { | |
let pstnLookup: string; | ||
let nativeLookup: string; | ||
|
||
beforeEach(() => { | ||
beforeEach(async () => { | ||
stubClient(); | ||
MatrixClientPeg.get().createCall = roomId => { | ||
if (fakeCall && fakeCall.roomId !== roomId) { | ||
|
@@ -322,3 +322,88 @@ describe('CallHandler', () => { | |
expect(callHandler.getCallForRoom(NATIVE_ROOM_CHARLIE)).toBe(fakeCall); | ||
}); | ||
}); | ||
|
||
describe('CallHandler without third party protocols', () => { | ||
let dmRoomMap; | ||
let callHandler; | ||
let audioElement; | ||
let fakeCall; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could these get types? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a bit hard. I just copied the code from above and that isn't properly typed, so any type annotation makes the linter spit out lots of errors... I added the few that seem to work fine. For the others I don't know enough about TS. Probably the FakeCall should be extending MatrixCall instead. |
||
|
||
beforeEach(() => { | ||
stubClient(); | ||
MatrixClientPeg.get().createCall = roomId => { | ||
if (fakeCall && fakeCall.roomId !== roomId) { | ||
throw new Error("Only one call is supported!"); | ||
} | ||
fakeCall = new FakeCall(roomId); | ||
return fakeCall; | ||
}; | ||
|
||
MatrixClientPeg.get().getThirdpartyProtocols = () => { | ||
throw new Error("Endpoint unsupported."); | ||
}; | ||
|
||
callHandler = new CallHandler(); | ||
callHandler.start(); | ||
|
||
const nativeRoomAlice = mkStubDM(NATIVE_ROOM_ALICE, NATIVE_ALICE); | ||
|
||
MatrixClientPeg.get().getRoom = roomId => { | ||
switch (roomId) { | ||
case NATIVE_ROOM_ALICE: | ||
return nativeRoomAlice; | ||
} | ||
}; | ||
|
||
dmRoomMap = { | ||
getUserIdForRoomId: roomId => { | ||
if (roomId === NATIVE_ROOM_ALICE) { | ||
return NATIVE_ALICE; | ||
} else { | ||
return null; | ||
} | ||
}, | ||
getDMRoomsForUserId: userId => { | ||
if (userId === NATIVE_ALICE) { | ||
return [NATIVE_ROOM_ALICE]; | ||
} else { | ||
return []; | ||
} | ||
}, | ||
}; | ||
DMRoomMap.setShared(dmRoomMap); | ||
|
||
MatrixClientPeg.get().getThirdpartyUser = (proto, params) => { | ||
throw new Error("Endpoint unsupported."); | ||
}; | ||
|
||
audioElement = document.createElement('audio'); | ||
audioElement.id = "remoteAudio"; | ||
document.body.appendChild(audioElement); | ||
}); | ||
|
||
afterEach(() => { | ||
callHandler.stop(); | ||
DMRoomMap.setShared(null); | ||
// @ts-ignore | ||
window.mxCallHandler = null; | ||
fakeCall = null; | ||
MatrixClientPeg.unset(); | ||
|
||
document.body.removeChild(audioElement); | ||
SdkConfig.unset(); | ||
}); | ||
|
||
it('should still start a native call', async () => { | ||
callHandler.placeCall(NATIVE_ROOM_ALICE, CallType.Voice); | ||
|
||
await untilCallHandlerEvent(callHandler, CallHandlerEvent.CallState); | ||
|
||
// Check that a call was started: its room on the protocol level | ||
// should be the virtual room | ||
expect(fakeCall.roomId).toEqual(NATIVE_ROOM_ALICE); | ||
|
||
// but it should appear to the user to be in thw native room for Bob | ||
expect(callHandler.roomIdForCall(fakeCall)).toEqual(NATIVE_ROOM_ALICE); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we log the errors at least?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I log some very basic message now, but not sure what to properly put there :3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be a warning or error rather than just log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it isn't really an error in most cases though. If a homeserver doesn't support that protocol, then it won't be hosting a bridge like that either and those endpoints don't work over federation anyway. I can make it a warning but for most people that is may be nice to know, but it clearly isn't an error, since they are not running a SIP bridge.