|
|
@ -15,12 +15,14 @@ import indexOfAndSplice from "../../helpers/array/indexOfAndSplice"; |
|
|
|
import insertInDescendSortedArray from "../../helpers/array/insertInDescendSortedArray"; |
|
|
|
import insertInDescendSortedArray from "../../helpers/array/insertInDescendSortedArray"; |
|
|
|
import AudioAssetPlayer from "../../helpers/audioAssetPlayer"; |
|
|
|
import AudioAssetPlayer from "../../helpers/audioAssetPlayer"; |
|
|
|
import bytesCmp from "../../helpers/bytes/bytesCmp"; |
|
|
|
import bytesCmp from "../../helpers/bytes/bytesCmp"; |
|
|
|
|
|
|
|
import compareVersion from "../../helpers/compareVersion"; |
|
|
|
import safeReplaceObject from "../../helpers/object/safeReplaceObject"; |
|
|
|
import safeReplaceObject from "../../helpers/object/safeReplaceObject"; |
|
|
|
import { nextRandomUint } from "../../helpers/random"; |
|
|
|
import { nextRandomUint } from "../../helpers/random"; |
|
|
|
import tsNow from "../../helpers/tsNow"; |
|
|
|
import tsNow from "../../helpers/tsNow"; |
|
|
|
import { InputPhoneCall, MessagesDhConfig, PhoneCall, PhoneCallDiscardReason, PhoneCallProtocol, PhonePhoneCall } from "../../layer"; |
|
|
|
import { InputPhoneCall, MessagesDhConfig, PhoneCall, PhoneCallDiscardReason, PhoneCallProtocol, PhonePhoneCall } from "../../layer"; |
|
|
|
import CallInstance from "../calls/callInstance"; |
|
|
|
import CallInstance from "../calls/callInstance"; |
|
|
|
import CALL_STATE from "../calls/callState"; |
|
|
|
import CALL_STATE from "../calls/callState"; |
|
|
|
|
|
|
|
import getCallProtocol from "../calls/p2P/getCallProtocol"; |
|
|
|
import { logger } from "../logger"; |
|
|
|
import { logger } from "../logger"; |
|
|
|
import apiManager from "../mtproto/mtprotoworker"; |
|
|
|
import apiManager from "../mtproto/mtprotoworker"; |
|
|
|
import { NULL_PEER_ID } from "../mtproto/mtproto_config"; |
|
|
|
import { NULL_PEER_ID } from "../mtproto/mtproto_config"; |
|
|
@ -74,6 +76,12 @@ export class AppCallsManager { |
|
|
|
|
|
|
|
|
|
|
|
case 'phoneCallAccepted': { |
|
|
|
case 'phoneCallAccepted': { |
|
|
|
if(instance) { |
|
|
|
if(instance) { |
|
|
|
|
|
|
|
if(!this.verifyProtocolCompatibility(call.protocol)) { |
|
|
|
|
|
|
|
instance.hangUp('phoneCallDiscardReasonDisconnect'); |
|
|
|
|
|
|
|
rootScope.dispatchEvent('call_incompatible', instance.interlocutorUserId); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
instance.confirmCall(); |
|
|
|
instance.confirmCall(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -82,6 +90,11 @@ export class AppCallsManager { |
|
|
|
|
|
|
|
|
|
|
|
case 'phoneCallRequested': { |
|
|
|
case 'phoneCallRequested': { |
|
|
|
if(!instance) { |
|
|
|
if(!instance) { |
|
|
|
|
|
|
|
if(!this.verifyProtocolCompatibility(call.protocol)) { |
|
|
|
|
|
|
|
rootScope.dispatchEvent('call_incompatible', call.admin_id); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
instance = this.createCallInstance({ |
|
|
|
instance = this.createCallInstance({ |
|
|
|
isOutgoing: false, |
|
|
|
isOutgoing: false, |
|
|
|
interlocutorUserId: call.admin_id |
|
|
|
interlocutorUserId: call.admin_id |
|
|
@ -324,6 +337,14 @@ export class AppCallsManager { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private verifyProtocolCompatibility(protocol: PhoneCallProtocol) { |
|
|
|
|
|
|
|
const my = getCallProtocol(); |
|
|
|
|
|
|
|
const myVersion = my.library_versions[0]; |
|
|
|
|
|
|
|
return !protocol.library_versions.find(version => { |
|
|
|
|
|
|
|
return compareVersion(myVersion, version) > 0; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async discardCall(callId: CallId, duration: number, reason: PhoneCallDiscardReason['_'], video?: boolean) { |
|
|
|
public async discardCall(callId: CallId, duration: number, reason: PhoneCallDiscardReason['_'], video?: boolean) { |
|
|
|
if(!this.getCall(callId)) { |
|
|
|
if(!this.getCall(callId)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|