Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import org.json.JSONObject
import java.net.URL
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.concurrent.TimeUnit

/**
Expand Down Expand Up @@ -166,7 +169,7 @@ class ForwardAction(pluginContext: Context, phoneContext: Context, smsMsg: SmsMs
if (!mSmsMsg.company.isNullOrBlank()) {
append('\n').append("Company: ").append(mSmsMsg.company)
}
append('\n').append("Time: ").append(mSmsMsg.date)
append('\n').append("Time: ").append(formatDate(mSmsMsg.date))
}
if (!isCodeSms) {
append(mSmsMsg.body.orEmpty())
Expand Down Expand Up @@ -229,6 +232,10 @@ class ForwardAction(pluginContext: Context, phoneContext: Context, smsMsg: SmsMs
}.getOrDefault(false)
}

private fun formatDate(timestamp: Long): String {
return SimpleDateFormat("yyyy.MM.dd HH:mm:ss", Locale.getDefault()).format(Date(timestamp))
}

private fun forwardToTelegram(
botToken: String,
chatId: String,
Expand All @@ -244,7 +251,7 @@ class ForwardAction(pluginContext: Context, phoneContext: Context, smsMsg: SmsMs
if (!mSmsMsg.company.isNullOrBlank()) {
append('\n').append("Company: ").append(mSmsMsg.company)
}
append('\n').append("Time: ").append(mSmsMsg.date)
append('\n').append("Time: ").append(formatDate(mSmsMsg.date))
}
if (!isCodeSms) {
append(mSmsMsg.body.orEmpty())
Expand Down