package com.adealink.weparty.im.stat

import com.adealink.frame.router.Router
import com.adealink.frame.statistics.CommonEventValue
import com.adealink.frame.statistics.IEventValue
import com.adealink.frame.util.AppUtil
import com.adealink.weparty.module.profile.Profile
import com.adealink.weparty.stat.HttpEvent

/**
 * 陪玩师主动聊天
 */
class PlaymateInitiateChatEvent : HttpEvent("playmate_proactive_chat") {

    override val action: IEventValue = CommonEventValue.Action.EMPTY
    override fun toString(): String {
        return "PlaymateInitiateChatEvent(targetUid:${targetUid.value}, scene${scene.value})"
    }

    companion object {
        @JvmStatic
        fun checkInitiateChat(targetUid: String?) {
            if (targetUid.isNullOrEmpty()) {
                return
            }
            val visitActivity = Router.getClazz(Profile.Visitor.PATH) ?: return
            val fromVisit = AppUtil.runningActivities.find {
                it.contains(visitActivity.name)
            } != null
            if (!fromVisit) {
                return
            }
            PlaymateInitiateChatEvent().apply {
                this.scene to "playmate_proactive_chat_report"
                this.targetUid to targetUid
            }.send()
        }
    }
}