You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Support MSC3086 asserted identity
This commit is contained in:
@@ -53,6 +53,8 @@ export enum EventType {
|
|||||||
CallSelectAnswer = "m.call.select_answer",
|
CallSelectAnswer = "m.call.select_answer",
|
||||||
CallNegotiate = "m.call.negotiate",
|
CallNegotiate = "m.call.negotiate",
|
||||||
CallReplaces = "m.call.replaces",
|
CallReplaces = "m.call.replaces",
|
||||||
|
CallAssertedIdentity = "m.call.asserted_identity",
|
||||||
|
CallAssertedIdentityPrefix = "org.matrix.call.asserted_identity",
|
||||||
KeyVerificationRequest = "m.key.verification.request",
|
KeyVerificationRequest = "m.key.verification.request",
|
||||||
KeyVerificationStart = "m.key.verification.start",
|
KeyVerificationStart = "m.key.verification.start",
|
||||||
KeyVerificationCancel = "m.key.verification.cancel",
|
KeyVerificationCancel = "m.key.verification.cancel",
|
||||||
|
|||||||
@@ -62,6 +62,11 @@ interface TurnServer {
|
|||||||
ttl?: number,
|
ttl?: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface AssertedIdentity {
|
||||||
|
id: string,
|
||||||
|
displayName: string,
|
||||||
|
}
|
||||||
|
|
||||||
export enum CallState {
|
export enum CallState {
|
||||||
Fledgling = 'fledgling',
|
Fledgling = 'fledgling',
|
||||||
InviteSent = 'invite_sent',
|
InviteSent = 'invite_sent',
|
||||||
@@ -101,6 +106,8 @@ export enum CallEvent {
|
|||||||
RemoteHoldUnhold = 'remote_hold_unhold',
|
RemoteHoldUnhold = 'remote_hold_unhold',
|
||||||
// backwards compat alias for LocalHoldUnhold: remove in a major version bump
|
// backwards compat alias for LocalHoldUnhold: remove in a major version bump
|
||||||
HoldUnhold = 'hold_unhold',
|
HoldUnhold = 'hold_unhold',
|
||||||
|
|
||||||
|
AssertedIdentityChanged = 'asserted_identity_changed',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum CallErrorCode {
|
export enum CallErrorCode {
|
||||||
@@ -292,6 +299,8 @@ export class MatrixCall extends EventEmitter {
|
|||||||
// the call) we buffer them up here so we can then add the ones from the party we pick
|
// the call) we buffer them up here so we can then add the ones from the party we pick
|
||||||
private remoteCandidateBuffer = new Map<string, RTCIceCandidate[]>();
|
private remoteCandidateBuffer = new Map<string, RTCIceCandidate[]>();
|
||||||
|
|
||||||
|
private remoteAssertedIdentity: AssertedIdentity;
|
||||||
|
|
||||||
constructor(opts: CallOpts) {
|
constructor(opts: CallOpts) {
|
||||||
super();
|
super();
|
||||||
this.roomId = opts.roomId;
|
this.roomId = opts.roomId;
|
||||||
@@ -419,6 +428,10 @@ export class MatrixCall extends EventEmitter {
|
|||||||
return Boolean(this.opponentCaps && this.opponentCaps["m.call.transferee"]);
|
return Boolean(this.opponentCaps && this.opponentCaps["m.call.transferee"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getRemoteAssertedIdentity(): AssertedIdentity {
|
||||||
|
return this.remoteAssertedIdentity;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the local <code><video></code> DOM element.
|
* Retrieve the local <code><video></code> DOM element.
|
||||||
* @return {Element} The dom element
|
* @return {Element} The dom element
|
||||||
@@ -1199,6 +1212,16 @@ export class MatrixCall extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onAssertedIdentityReceived(event: MatrixEvent) {
|
||||||
|
if (!event.getContent().asserted_identity) return;
|
||||||
|
|
||||||
|
this.remoteAssertedIdentity = {
|
||||||
|
id: event.getContent().asserted_identity.id,
|
||||||
|
displayName: event.getContent().asserted_identity.displayName,
|
||||||
|
};
|
||||||
|
this.emit(CallEvent.AssertedIdentityChanged);
|
||||||
|
}
|
||||||
|
|
||||||
private callHasEnded(): boolean {
|
private callHasEnded(): boolean {
|
||||||
// This exists as workaround to typescript trying to be clever and erroring
|
// This exists as workaround to typescript trying to be clever and erroring
|
||||||
// when putting if (this.state === CallState.Ended) return; twice in the same
|
// when putting if (this.state === CallState.Ended) return; twice in the same
|
||||||
|
|||||||
@@ -87,7 +87,11 @@ export class CallEventHandler {
|
|||||||
|
|
||||||
private onEvent = (event: MatrixEvent) => {
|
private onEvent = (event: MatrixEvent) => {
|
||||||
// any call events or ones that might be once they're decrypted
|
// any call events or ones that might be once they're decrypted
|
||||||
if (event.getType().indexOf("m.call.") === 0 || event.isBeingDecrypted()) {
|
if (
|
||||||
|
event.getType().indexOf("m.call.") === 0 ||
|
||||||
|
event.getType().indexOf("org.matrix.call.") === 0
|
||||||
|
|| event.isBeingDecrypted()
|
||||||
|
) {
|
||||||
// queue up for processing once all events from this sync have been
|
// queue up for processing once all events from this sync have been
|
||||||
// processed (see above).
|
// processed (see above).
|
||||||
this.callEventBuffer.push(event);
|
this.callEventBuffer.push(event);
|
||||||
@@ -271,6 +275,17 @@ export class CallEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
call.onNegotiateReceived(event);
|
call.onNegotiateReceived(event);
|
||||||
|
} else if (
|
||||||
|
event.getType() === EventType.CallAssertedIdentity || event.getType() === EventType.CallAssertedIdentityPrefix
|
||||||
|
) {
|
||||||
|
if (!call) return;
|
||||||
|
|
||||||
|
if (event.getContent().party_id === call.ourPartyId) {
|
||||||
|
// Ignore remote echo (not that we send asserted identity, but still...)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
call.onAssertedIdentityReceived(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user