That fuck shit the fascists are using
at master 71 lines 2.2 kB view raw
1package org.archiver.device 2 3import android.app.Application 4import com.tm.androidcopysdk.api.IFiler 5import org.archiver.data.TeleMessageTable 6import org.signal.core.util.logging.Log 7import org.signal.ringrtc.CallId 8import org.signal.ringrtc.GroupCall 9import org.signal.ringrtc.Remote 10import org.tm.archive.database.CallTable 11import org.tm.archive.database.SignalDatabase 12import org.tm.archive.service.webrtc.SignalCallManager 13import org.tm.archive.service.webrtc.state.CallInfoState 14import org.tm.archive.service.webrtc.state.WebRtcServiceState 15 16class TeleMessageSignalCallManager( 17 application: Application, 18 19 private val filer: IFiler, 20 21 private val calls: CallTable, 22) : SignalCallManager(application) { 23 24 private var callInfoState: CallInfoState? = null 25 26 override fun postStateUpdate(state: WebRtcServiceState) { 27 val callId = state.callInfoState.getCallId() 28 Log.d(TAG, "postStateUpdate - callId: $callId") 29 if (callId != null) 30 this.callInfoState = state.callInfoState 31 super.postStateUpdate(state) 32 } 33 34 override fun onCallConcluded(remote: Remote?) { 35 super.onCallConcluded(remote) 36 onFinishCall() 37 } 38 39 override fun onEnded(groupCall: GroupCall, groupCallEndReason: GroupCall.GroupCallEndReason) { 40 super.onEnded(groupCall, groupCallEndReason) 41 onFinishCall() 42 } 43 44 private fun onFinishCall() { 45 val callInfoState = callInfoState ?: return 46 this.callInfoState = null 47 val call = callInfoState.call() ?: return 48 val isAdHocCall = callInfoState.callRecipient.isCallLink 49 if (isAdHocCall) { 50 filer.findCallRecording(call.callId.toString())?.apply { if (exists()) delete() } 51 return 52 } 53 (SignalDatabase.messages as TeleMessageTable).onSubmitCall(call, callInfoState) 54 } 55 56 private fun CallInfoState.getCallId(): CallId? { 57 val activePeer = activePeer 58 val callRecipient = callRecipient 59 if (!callRecipient.isGroup) 60 return activePeer?.callId 61 return groupCall?.peekInfo?.eraId?.let(CallId::fromEra) 62 } 63 64 private fun CallInfoState?.call() = this?.let { getCallId()?.let { calls.getCallById(it.longValue(), callRecipient.id) } } 65 66 companion object { 67 68 private const val TAG = "TeleMessageSignalCallManager" 69 70 } 71}