package ru.forbion.f7cloud.core.push

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent

/** Handles Decline and ring-timeout on incoming Talk call notifications. */
class F7CallActionReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        val roomToken = intent.getStringExtra(EXTRA_ROOM_TOKEN)
        when (intent.action) {
            ACTION_DECLINE -> F7IncomingCallQueue.dismissAndShowNext(context, roomToken)
            ACTION_CALL_TIMEOUT -> F7IncomingCallQueue.timeoutActive(context, roomToken)
        }
    }

    companion object {
        const val ACTION_DECLINE = "ru.forbion.f7cloud.action.DECLINE_CALL"
        const val ACTION_CALL_TIMEOUT = "ru.forbion.f7cloud.action.CALL_TIMEOUT"
        const val EXTRA_NOTIFICATION_ID = "notificationId"
        const val EXTRA_ROOM_TOKEN = "roomToken"
    }
}
