Skip to content

Commit

Permalink
移除驗證碼長度限制
Browse files Browse the repository at this point in the history
  • Loading branch information
qwe7002 committed Nov 30, 2024
1 parent 944d51b commit da5870c
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions app/src/main/java/com/qwe7002/telegram_rc/SMSReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import java.util.Objects
@Suppress("DEPRECATION")
class SMSReceiver : BroadcastReceiver() {
private lateinit var preferences: io.paperdb.Book

@SuppressLint("UnsafeProtectedBroadcastReceiver")
override fun onReceive(context: Context, intent: Intent) {
Paper.init(context)
Expand Down Expand Up @@ -116,19 +117,15 @@ class SMSReceiver : BroadcastReceiver() {
var rawRequestBodyText: String = messageHead + messageBody
var isVerificationCode = false
if (preferences.read("verification_code", false)!! && !isTrustedPhone) {
if (messageBody.length <= 140) {
val verification = CodeauxLibPortable.find(context, messageBody)
if (verification != null) {
requestBody.parseMode = "html"
messageBodyHtml = messageBody
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace("&", "&amp;")
.replace(verification, "<code>$verification</code>")
isVerificationCode = true
}
} else {
writeLog(context, "SMS exceeds 140 characters, no verification code is recognized.")
val verification = CodeauxLibPortable.find(context, messageBody)
if (verification != null) {
requestBody.parseMode = "html"
messageBodyHtml = messageBody
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace("&", "&amp;")
.replace(verification, "<code>$verification</code>")
isVerificationCode = true
}
}
requestBody.text = messageHead + messageBodyHtml
Expand Down Expand Up @@ -266,7 +263,7 @@ class SMSReceiver : BroadcastReceiver() {
writeLog(context, errorHead + e.message)
SMS.sendFallbackSMS(context, finalRawRequestBodyText, subId)
addResendLoop(requestBody.text)
commandHandle( messageBody, dataEnable)
commandHandle(messageBody, dataEnable)
}

@Throws(IOException::class)
Expand Down

0 comments on commit da5870c

Please sign in to comment.