Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
elm
element-web
matrix-js-sdk
Commits
b01f3541
Unverified
Commit
b01f3541
authored
2 years ago
by
Robin
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Handle group call redaction (#3231)
Redacted group call events should be interpreted as terminated calls.
parent
254f043a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
5 deletions
+43
-5
spec/test-utils/webrtc.ts
spec/test-utils/webrtc.ts
+2
-0
spec/unit/webrtc/groupCallEventHandler.spec.ts
spec/unit/webrtc/groupCallEventHandler.spec.ts
+38
-2
src/webrtc/groupCallEventHandler.ts
src/webrtc/groupCallEventHandler.ts
+3
-3
No files found.
spec/test-utils/webrtc.ts
View file @
b01f3541
...
...
@@ -585,6 +585,7 @@ export function makeMockGroupCallStateEvent(
"
m.type
"
:
GroupCallType
.
Video
,
"
m.intent
"
:
GroupCallIntent
.
Prompt
,
},
redacted
?:
boolean
,
):
MatrixEvent
{
return
{
getType
:
jest
.
fn
().
mockReturnValue
(
EventType
.
GroupCallPrefix
),
...
...
@@ -592,6 +593,7 @@ export function makeMockGroupCallStateEvent(
getTs
:
jest
.
fn
().
mockReturnValue
(
0
),
getContent
:
jest
.
fn
().
mockReturnValue
(
content
),
getStateKey
:
jest
.
fn
().
mockReturnValue
(
groupCallId
),
isRedacted
:
jest
.
fn
().
mockReturnValue
(
redacted
??
false
),
}
as
unknown
as
MatrixEvent
;
}
...
...
This diff is collapsed.
Click to expand it.
spec/unit/webrtc/groupCallEventHandler.spec.ts
View file @
b01f3541
...
...
@@ -98,6 +98,23 @@ describe("Group Call Event Handler", function () {
expect
(
groupCall
.
state
).
toBe
(
GroupCallState
.
Ended
);
});
it
(
"
terminates call when redacted
"
,
async
()
=>
{
await
groupCallEventHandler
.
start
();
mockClient
.
emitRoomState
(
makeMockGroupCallStateEvent
(
FAKE_ROOM_ID
,
FAKE_GROUP_CALL_ID
),
{
roomId
:
FAKE_ROOM_ID
,
}
as
unknown
as
RoomState
);
const
groupCall
=
groupCallEventHandler
.
groupCalls
.
get
(
FAKE_ROOM_ID
)
!
;
expect
(
groupCall
.
state
).
toBe
(
GroupCallState
.
LocalCallFeedUninitialized
);
mockClient
.
emitRoomState
(
makeMockGroupCallStateEvent
(
FAKE_ROOM_ID
,
FAKE_GROUP_CALL_ID
,
undefined
,
true
),
{
roomId
:
FAKE_ROOM_ID
,
}
as
unknown
as
RoomState
);
expect
(
groupCall
.
state
).
toBe
(
GroupCallState
.
Ended
);
});
});
it
(
"
waits until client starts syncing
"
,
async
()
=>
{
...
...
@@ -222,9 +239,9 @@ describe("Group Call Event Handler", function () {
jest
.
clearAllMocks
();
});
const
setupCallAndStart
=
async
(
content
?:
IContent
)
=>
{
const
setupCallAndStart
=
async
(
content
?:
IContent
,
redacted
?:
boolean
)
=>
{
mocked
(
mockRoom
.
currentState
.
getStateEvents
).
mockReturnValue
([
makeMockGroupCallStateEvent
(
FAKE_ROOM_ID
,
FAKE_GROUP_CALL_ID
,
content
),
makeMockGroupCallStateEvent
(
FAKE_ROOM_ID
,
FAKE_GROUP_CALL_ID
,
content
,
redacted
),
]
as
unknown
as
MatrixEvent
);
mockClient
.
getRooms
.
mockReturnValue
([
mockRoom
]);
await
groupCallEventHandler
.
start
();
...
...
@@ -285,5 +302,24 @@ describe("Group Call Event Handler", function () {
}),
);
});
it
(
"
ignores redacted calls
"
,
async
()
=>
{
await
setupCallAndStart
(
{
// Real event contents to make sure that it's specifically the
// event being redacted that causes it to be ignored
"
m.type
"
:
GroupCallType
.
Video
,
"
m.intent
"
:
GroupCallIntent
.
Prompt
,
},
true
,
);
expect
(
mockClientEmit
).
not
.
toHaveBeenCalledWith
(
GroupCallEventHandlerEvent
.
Incoming
,
expect
.
objectContaining
({
groupCallId
:
FAKE_GROUP_CALL_ID
,
}),
);
});
});
});
This diff is collapsed.
Click to expand it.
src/webrtc/groupCallEventHandler.ts
View file @
b01f3541
...
...
@@ -118,7 +118,7 @@ export class GroupCallEventHandler {
for
(
const
callEvent
of
sortedCallEvents
)
{
const
content
=
callEvent
.
getContent
();
if
(
content
[
"
m.terminated
"
])
{
if
(
content
[
"
m.terminated
"
]
||
callEvent
.
isRedacted
()
)
{
continue
;
}
...
...
@@ -210,10 +210,10 @@ export class GroupCallEventHandler {
const
currentGroupCall
=
this
.
groupCalls
.
get
(
state
.
roomId
);
if
(
!
currentGroupCall
&&
!
content
[
"
m.terminated
"
])
{
if
(
!
currentGroupCall
&&
!
content
[
"
m.terminated
"
]
&&
!
event
.
isRedacted
()
)
{
this
.
createGroupCallFromRoomStateEvent
(
event
);
}
else
if
(
currentGroupCall
&&
currentGroupCall
.
groupCallId
===
groupCallId
)
{
if
(
content
[
"
m.terminated
"
])
{
if
(
content
[
"
m.terminated
"
]
||
event
.
isRedacted
()
)
{
currentGroupCall
.
terminate
(
false
);
}
else
if
(
content
[
"
m.type
"
]
!==
currentGroupCall
.
type
)
{
// TODO: Handle the callType changing when the room state changes
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment