mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-22 13:46:13 +08:00
Fix StackOverflowError
on calling bot.client
in tests with TestSsoProcessor
, fix #1332
This commit is contained in:
parent
794315e169
commit
750ab0db37
@ -9,6 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.internal.network.context
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.internal.BotAccount
|
||||
import net.mamoe.mirai.internal.QQAndroidBot
|
||||
import net.mamoe.mirai.internal.network.component.ComponentKey
|
||||
@ -44,7 +45,7 @@ internal class SsoProcessorContextImpl(
|
||||
override val bot: QQAndroidBot
|
||||
) : SsoProcessorContext {
|
||||
override val account: BotAccount get() = bot.account
|
||||
override val device: DeviceInfo = configuration.deviceInfo?.invoke(bot) ?: DeviceInfo.random()
|
||||
override val device: DeviceInfo = configuration.createDeviceInfo(bot)
|
||||
override val protocol: BotConfiguration.MiraiProtocol get() = configuration.protocol
|
||||
override val accountSecretsManager: AccountSecretsManager
|
||||
get() = configuration.createAccountsSecretsManager(
|
||||
@ -52,3 +53,5 @@ internal class SsoProcessorContextImpl(
|
||||
)
|
||||
override val configuration: BotConfiguration get() = bot.configuration
|
||||
}
|
||||
|
||||
internal fun BotConfiguration.createDeviceInfo(bot: Bot): DeviceInfo = deviceInfo?.invoke(bot) ?: DeviceInfo.random()
|
@ -12,16 +12,22 @@ package net.mamoe.mirai.internal.network.framework.components
|
||||
import net.mamoe.mirai.internal.QQAndroidBot
|
||||
import net.mamoe.mirai.internal.network.QQAndroidClient
|
||||
import net.mamoe.mirai.internal.network.components.SsoProcessor
|
||||
import net.mamoe.mirai.internal.network.context.AccountSecretsImpl
|
||||
import net.mamoe.mirai.internal.network.context.SsoSession
|
||||
import net.mamoe.mirai.internal.network.context.createDeviceInfo
|
||||
import net.mamoe.mirai.internal.network.handler.NetworkHandler
|
||||
import net.mamoe.mirai.internal.network.handler.logger
|
||||
import net.mamoe.mirai.internal.network.handler.state.StateObserver
|
||||
import net.mamoe.mirai.internal.network.protocol.data.jce.SvcRespRegister
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.login.StatSvc
|
||||
import net.mamoe.mirai.utils.debug
|
||||
import net.mamoe.mirai.utils.lateinitMutableProperty
|
||||
|
||||
internal open class TestSsoProcessor(private val bot: QQAndroidBot) : SsoProcessor {
|
||||
override val client: QQAndroidClient get() = bot.client
|
||||
val deviceInfo = bot.configuration.createDeviceInfo(bot)
|
||||
override var client: QQAndroidClient by lateinitMutableProperty {
|
||||
QQAndroidClient(bot.account, device = deviceInfo, accountSecrets = AccountSecretsImpl(deviceInfo, bot.account))
|
||||
}
|
||||
override val ssoSession: SsoSession get() = bot.client
|
||||
override var firstLoginSucceed: Boolean = false
|
||||
override var registerResp: StatSvc.Register.Response? = null
|
||||
|
Loading…
Reference in New Issue
Block a user