Fix unencrypted call events
This commit is contained in:
parent
215563ab92
commit
50d97ebeb2
|
@ -981,14 +981,17 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
onEvent.add(update);
|
onEvent.add(update);
|
||||||
|
|
||||||
if (event['type'] == EventTypes.CallInvite) {
|
final rawUnencryptedEvent = update.content;
|
||||||
onCallInvite.add(Event.fromJson(event, room, sortOrder));
|
|
||||||
} else if (event['type'] == EventTypes.CallHangup) {
|
if (rawUnencryptedEvent['type'] == EventTypes.CallInvite) {
|
||||||
onCallHangup.add(Event.fromJson(event, room, sortOrder));
|
onCallInvite.add(Event.fromJson(rawUnencryptedEvent, room, sortOrder));
|
||||||
} else if (event['type'] == EventTypes.CallAnswer) {
|
} else if (rawUnencryptedEvent['type'] == EventTypes.CallHangup) {
|
||||||
onCallAnswer.add(Event.fromJson(event, room, sortOrder));
|
onCallHangup.add(Event.fromJson(rawUnencryptedEvent, room, sortOrder));
|
||||||
} else if (event['type'] == EventTypes.CallCandidates) {
|
} else if (rawUnencryptedEvent['type'] == EventTypes.CallAnswer) {
|
||||||
onCallCandidates.add(Event.fromJson(event, room, sortOrder));
|
onCallAnswer.add(Event.fromJson(rawUnencryptedEvent, room, sortOrder));
|
||||||
|
} else if (rawUnencryptedEvent['type'] == EventTypes.CallCandidates) {
|
||||||
|
onCallCandidates
|
||||||
|
.add(Event.fromJson(rawUnencryptedEvent, room, sortOrder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1349,16 +1349,22 @@ class Room {
|
||||||
{String type = 'offer', int version = 0, String txid}) async {
|
{String type = 'offer', int version = 0, String txid}) async {
|
||||||
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
|
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
|
||||||
|
|
||||||
|
final content = {
|
||||||
|
'call_id': callId,
|
||||||
|
'lifetime': lifetime,
|
||||||
|
'offer': {'sdp': sdp, 'type': type},
|
||||||
|
'version': version,
|
||||||
|
};
|
||||||
|
|
||||||
|
final sendMessageContent = encrypted && client.encryptionEnabled
|
||||||
|
? await client.encryption.encryptGroupMessagePayload(id, content,
|
||||||
|
type: EventTypes.CallInvite)
|
||||||
|
: content;
|
||||||
return await client.sendMessage(
|
return await client.sendMessage(
|
||||||
id,
|
id,
|
||||||
EventTypes.CallInvite,
|
EventTypes.CallInvite,
|
||||||
txid,
|
txid,
|
||||||
{
|
sendMessageContent,
|
||||||
'call_id': callId,
|
|
||||||
'lifetime': lifetime,
|
|
||||||
'offer': {'sdp': sdp, 'type': type},
|
|
||||||
'version': version,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1387,15 +1393,21 @@ class Room {
|
||||||
String txid,
|
String txid,
|
||||||
}) async {
|
}) async {
|
||||||
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
|
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
|
||||||
|
final content = {
|
||||||
|
'call_id': callId,
|
||||||
|
'candidates': candidates,
|
||||||
|
'version': version,
|
||||||
|
};
|
||||||
|
|
||||||
|
final sendMessageContent = encrypted && client.encryptionEnabled
|
||||||
|
? await client.encryption.encryptGroupMessagePayload(id, content,
|
||||||
|
type: EventTypes.CallCandidates)
|
||||||
|
: content;
|
||||||
return await client.sendMessage(
|
return await client.sendMessage(
|
||||||
id,
|
id,
|
||||||
EventTypes.CallCandidates,
|
EventTypes.CallCandidates,
|
||||||
txid,
|
txid,
|
||||||
{
|
sendMessageContent,
|
||||||
'call_id': callId,
|
|
||||||
'candidates': candidates,
|
|
||||||
'version': version,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1407,15 +1419,21 @@ class Room {
|
||||||
Future<String> answerCall(String callId, String sdp,
|
Future<String> answerCall(String callId, String sdp,
|
||||||
{String type = 'answer', int version = 0, String txid}) async {
|
{String type = 'answer', int version = 0, String txid}) async {
|
||||||
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
|
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
|
||||||
|
final content = {
|
||||||
|
'call_id': callId,
|
||||||
|
'answer': {'sdp': sdp, 'type': type},
|
||||||
|
'version': version,
|
||||||
|
};
|
||||||
|
|
||||||
|
final sendMessageContent = encrypted && client.encryptionEnabled
|
||||||
|
? await client.encryption.encryptGroupMessagePayload(id, content,
|
||||||
|
type: EventTypes.CallAnswer)
|
||||||
|
: content;
|
||||||
return await client.sendMessage(
|
return await client.sendMessage(
|
||||||
id,
|
id,
|
||||||
EventTypes.CallAnswer,
|
EventTypes.CallAnswer,
|
||||||
txid,
|
txid,
|
||||||
{
|
sendMessageContent,
|
||||||
'call_id': callId,
|
|
||||||
'answer': {'sdp': sdp, 'type': type},
|
|
||||||
'version': version,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1425,14 +1443,21 @@ class Room {
|
||||||
Future<String> hangupCall(String callId,
|
Future<String> hangupCall(String callId,
|
||||||
{int version = 0, String txid}) async {
|
{int version = 0, String txid}) async {
|
||||||
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
|
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
|
||||||
|
|
||||||
|
final content = {
|
||||||
|
'call_id': callId,
|
||||||
|
'version': version,
|
||||||
|
};
|
||||||
|
|
||||||
|
final sendMessageContent = encrypted && client.encryptionEnabled
|
||||||
|
? await client.encryption.encryptGroupMessagePayload(id, content,
|
||||||
|
type: EventTypes.CallHangup)
|
||||||
|
: content;
|
||||||
return await client.sendMessage(
|
return await client.sendMessage(
|
||||||
id,
|
id,
|
||||||
EventTypes.CallHangup,
|
EventTypes.CallHangup,
|
||||||
txid,
|
txid,
|
||||||
{
|
sendMessageContent,
|
||||||
'call_id': callId,
|
|
||||||
'version': version,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue