Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions .skills/compose-ui/strings-index.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,37 @@ import org.jetbrains.compose.resources.StringResource
import org.meshtastic.core.resources.Res
import org.meshtastic.core.resources.error
import org.meshtastic.core.resources.message_delivery_status
import org.meshtastic.core.resources.message_routing_error_admin_bad_session_key
import org.meshtastic.core.resources.message_routing_error_admin_bad_session_key_detail
import org.meshtastic.core.resources.message_routing_error_admin_public_key_unauthorized
import org.meshtastic.core.resources.message_routing_error_admin_public_key_unauthorized_detail
import org.meshtastic.core.resources.message_routing_error_bad_request
import org.meshtastic.core.resources.message_routing_error_bad_request_detail
import org.meshtastic.core.resources.message_routing_error_duty_cycle_limit
import org.meshtastic.core.resources.message_routing_error_duty_cycle_limit_detail
import org.meshtastic.core.resources.message_routing_error_got_nak_detail
import org.meshtastic.core.resources.message_routing_error_max_retransmit
import org.meshtastic.core.resources.message_routing_error_max_retransmit_detail
import org.meshtastic.core.resources.message_routing_error_no_channel
import org.meshtastic.core.resources.message_routing_error_no_channel_detail
import org.meshtastic.core.resources.message_routing_error_no_interface
import org.meshtastic.core.resources.message_routing_error_no_interface_detail
import org.meshtastic.core.resources.message_routing_error_no_response
import org.meshtastic.core.resources.message_routing_error_no_response_detail
import org.meshtastic.core.resources.message_routing_error_no_route_detail
import org.meshtastic.core.resources.message_routing_error_not_authorized
import org.meshtastic.core.resources.message_routing_error_not_authorized_detail
import org.meshtastic.core.resources.message_routing_error_pki_failed
import org.meshtastic.core.resources.message_routing_error_pki_failed_detail
import org.meshtastic.core.resources.message_routing_error_pki_send_fail_public_key
import org.meshtastic.core.resources.message_routing_error_pki_send_fail_public_key_detail
import org.meshtastic.core.resources.message_routing_error_pki_unknown_pubkey
import org.meshtastic.core.resources.message_routing_error_pki_unknown_pubkey_detail
import org.meshtastic.core.resources.message_routing_error_rate_limit_exceeded
import org.meshtastic.core.resources.message_routing_error_rate_limit_exceeded_detail
import org.meshtastic.core.resources.message_routing_error_timeout_detail
import org.meshtastic.core.resources.message_routing_error_too_large
import org.meshtastic.core.resources.message_routing_error_too_large_detail
import org.meshtastic.core.resources.message_status_delivered
import org.meshtastic.core.resources.message_status_enroute
import org.meshtastic.core.resources.message_status_recipient_delivered
Expand Down Expand Up @@ -78,26 +103,86 @@ fun getStringResFrom(routingError: Int): StringResource = when (routingError) {
else -> Res.string.unrecognized
}

@Suppress("CyclomaticComplexMethod")
fun getMessageRoutingErrorStringResFrom(routingError: Int): StringResource = when (routingError) {
Routing.Error.GOT_NAK.value,
Routing.Error.TIMEOUT.value,
Routing.Error.MAX_RETRANSMIT.value,
Routing.Error.NO_RESPONSE.value,
-> Res.string.message_routing_error_max_retransmit

Routing.Error.NO_CHANNEL.value -> Res.string.message_routing_error_no_channel

Routing.Error.NO_INTERFACE.value -> Res.string.message_routing_error_no_interface

Routing.Error.DUTY_CYCLE_LIMIT.value -> Res.string.message_routing_error_duty_cycle_limit

Routing.Error.RATE_LIMIT_EXCEEDED.value -> Res.string.message_routing_error_rate_limit_exceeded

Routing.Error.TOO_LARGE.value -> Res.string.message_routing_error_too_large

Routing.Error.NO_RESPONSE.value -> Res.string.message_routing_error_no_response

Routing.Error.BAD_REQUEST.value -> Res.string.message_routing_error_bad_request

Routing.Error.NOT_AUTHORIZED.value -> Res.string.message_routing_error_not_authorized

Routing.Error.PKI_FAILED.value -> Res.string.message_routing_error_pki_failed

Routing.Error.PKI_UNKNOWN_PUBKEY.value -> Res.string.message_routing_error_pki_unknown_pubkey

Routing.Error.PKI_SEND_FAIL_PUBLIC_KEY.value -> Res.string.message_routing_error_pki_send_fail_public_key

Routing.Error.ADMIN_BAD_SESSION_KEY.value -> Res.string.message_routing_error_admin_bad_session_key

Routing.Error.ADMIN_PUBLIC_KEY_UNAUTHORIZED.value ->
Res.string.message_routing_error_admin_public_key_unauthorized

else -> getStringResFrom(routingError)
}

@Suppress("CyclomaticComplexMethod")
fun getMessageRoutingErrorDetailResFrom(routingError: Int): StringResource? = when (routingError) {
Routing.Error.NO_ROUTE.value -> Res.string.message_routing_error_no_route_detail

Routing.Error.GOT_NAK.value -> Res.string.message_routing_error_got_nak_detail

Routing.Error.TIMEOUT.value -> Res.string.message_routing_error_timeout_detail

Routing.Error.MAX_RETRANSMIT.value -> Res.string.message_routing_error_max_retransmit_detail

Routing.Error.NO_CHANNEL.value -> Res.string.message_routing_error_no_channel_detail

Routing.Error.NO_INTERFACE.value -> Res.string.message_routing_error_no_interface_detail

Routing.Error.DUTY_CYCLE_LIMIT.value -> Res.string.message_routing_error_duty_cycle_limit_detail

Routing.Error.RATE_LIMIT_EXCEEDED.value -> Res.string.message_routing_error_rate_limit_exceeded_detail

Routing.Error.TOO_LARGE.value -> Res.string.message_routing_error_too_large_detail

Routing.Error.NO_RESPONSE.value -> Res.string.message_routing_error_no_response_detail

Routing.Error.BAD_REQUEST.value -> Res.string.message_routing_error_bad_request_detail

Routing.Error.NOT_AUTHORIZED.value -> Res.string.message_routing_error_not_authorized_detail

Routing.Error.PKI_FAILED.value -> Res.string.message_routing_error_pki_failed_detail

Routing.Error.PKI_UNKNOWN_PUBKEY.value -> Res.string.message_routing_error_pki_unknown_pubkey_detail

Routing.Error.PKI_SEND_FAIL_PUBLIC_KEY.value -> Res.string.message_routing_error_pki_send_fail_public_key_detail

Routing.Error.ADMIN_BAD_SESSION_KEY.value -> Res.string.message_routing_error_admin_bad_session_key_detail

Routing.Error.ADMIN_PUBLIC_KEY_UNAUTHORIZED.value ->
Res.string.message_routing_error_admin_public_key_unauthorized_detail

else -> null
}

fun getMessageStatusDetailRes(status: MessageStatus?, routingError: Int): StringResource? =
if (status == MessageStatus.ERROR) getMessageRoutingErrorDetailResFrom(routingError) else null

fun getMessageStatusStringRes(
status: MessageStatus?,
routingError: Int,
Expand Down Expand Up @@ -198,6 +283,8 @@ data class Message(
fun getStatusStringRes(isDirectMessage: Boolean = false): Pair<StringResource, StringResource> =
getMessageStatusStringRes(status, routingError, isDirectMessage)

fun getStatusDetailRes(): StringResource? = getMessageStatusDetailRes(status, routingError)

fun isStatusRetryable(isDirectMessage: Boolean = false): Boolean =
isMessageStatusRetryable(status, routingError, isDirectMessage)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,57 @@ import okio.ByteString.Companion.encodeUtf8
import org.meshtastic.core.resources.Res
import org.meshtastic.core.resources.error
import org.meshtastic.core.resources.message_delivery_status
import org.meshtastic.core.resources.message_routing_error_admin_bad_session_key
import org.meshtastic.core.resources.message_routing_error_admin_bad_session_key_detail
import org.meshtastic.core.resources.message_routing_error_admin_public_key_unauthorized
import org.meshtastic.core.resources.message_routing_error_admin_public_key_unauthorized_detail
import org.meshtastic.core.resources.message_routing_error_bad_request
import org.meshtastic.core.resources.message_routing_error_bad_request_detail
import org.meshtastic.core.resources.message_routing_error_duty_cycle_limit
import org.meshtastic.core.resources.message_routing_error_duty_cycle_limit_detail
import org.meshtastic.core.resources.message_routing_error_got_nak_detail
import org.meshtastic.core.resources.message_routing_error_max_retransmit
import org.meshtastic.core.resources.message_routing_error_max_retransmit_detail
import org.meshtastic.core.resources.message_routing_error_no_channel
import org.meshtastic.core.resources.message_routing_error_no_channel_detail
import org.meshtastic.core.resources.message_routing_error_no_interface
import org.meshtastic.core.resources.message_routing_error_no_interface_detail
import org.meshtastic.core.resources.message_routing_error_no_response
import org.meshtastic.core.resources.message_routing_error_no_response_detail
import org.meshtastic.core.resources.message_routing_error_no_route_detail
import org.meshtastic.core.resources.message_routing_error_not_authorized
import org.meshtastic.core.resources.message_routing_error_not_authorized_detail
import org.meshtastic.core.resources.message_routing_error_pki_failed
import org.meshtastic.core.resources.message_routing_error_pki_failed_detail
import org.meshtastic.core.resources.message_routing_error_pki_send_fail_public_key
import org.meshtastic.core.resources.message_routing_error_pki_send_fail_public_key_detail
import org.meshtastic.core.resources.message_routing_error_pki_unknown_pubkey
import org.meshtastic.core.resources.message_routing_error_pki_unknown_pubkey_detail
import org.meshtastic.core.resources.message_routing_error_rate_limit_exceeded
import org.meshtastic.core.resources.message_routing_error_rate_limit_exceeded_detail
import org.meshtastic.core.resources.message_routing_error_timeout_detail
import org.meshtastic.core.resources.message_routing_error_too_large
import org.meshtastic.core.resources.message_routing_error_too_large_detail
import org.meshtastic.core.resources.message_status_delivered
import org.meshtastic.core.resources.message_status_enroute
import org.meshtastic.core.resources.message_status_recipient_delivered
import org.meshtastic.core.resources.message_status_relayed_not_confirmed
import org.meshtastic.core.resources.message_status_unknown
import org.meshtastic.core.resources.routing_error_admin_bad_session_key
import org.meshtastic.core.resources.routing_error_admin_public_key_unauthorized
import org.meshtastic.core.resources.routing_error_bad_request
import org.meshtastic.core.resources.routing_error_duty_cycle_limit
import org.meshtastic.core.resources.routing_error_max_retransmit
import org.meshtastic.core.resources.routing_error_no_channel
import org.meshtastic.core.resources.routing_error_no_interface
import org.meshtastic.core.resources.routing_error_no_response
import org.meshtastic.core.resources.routing_error_no_route
import org.meshtastic.core.resources.routing_error_none
import org.meshtastic.core.resources.routing_error_not_authorized
import org.meshtastic.core.resources.routing_error_pki_failed
import org.meshtastic.core.resources.routing_error_pki_send_fail_public_key
import org.meshtastic.core.resources.routing_error_pki_unknown_pubkey
import org.meshtastic.core.resources.routing_error_rate_limit_exceeded
import org.meshtastic.core.resources.routing_error_too_large
import org.meshtastic.core.resources.unrecognized
import org.meshtastic.proto.PortNum
Expand Down Expand Up @@ -309,13 +342,21 @@ class MessageTest {
Routing.Error.MAX_RETRANSMIT.value to Res.string.message_routing_error_max_retransmit,
Routing.Error.GOT_NAK.value to Res.string.message_routing_error_max_retransmit,
Routing.Error.TIMEOUT.value to Res.string.message_routing_error_max_retransmit,
Routing.Error.NO_RESPONSE.value to Res.string.message_routing_error_max_retransmit,
Routing.Error.NO_CHANNEL.value to Res.string.message_routing_error_no_channel,
Routing.Error.NO_INTERFACE.value to Res.string.message_routing_error_no_interface,
Routing.Error.DUTY_CYCLE_LIMIT.value to Res.string.message_routing_error_duty_cycle_limit,
Routing.Error.RATE_LIMIT_EXCEEDED.value to Res.string.message_routing_error_rate_limit_exceeded,
Routing.Error.NO_RESPONSE.value to Res.string.message_routing_error_no_response,
Routing.Error.BAD_REQUEST.value to Res.string.message_routing_error_bad_request,
Routing.Error.NOT_AUTHORIZED.value to Res.string.message_routing_error_not_authorized,
Routing.Error.PKI_FAILED.value to Res.string.message_routing_error_pki_failed,
Routing.Error.PKI_SEND_FAIL_PUBLIC_KEY.value to
Res.string.message_routing_error_pki_send_fail_public_key,
Routing.Error.PKI_UNKNOWN_PUBKEY.value to Res.string.message_routing_error_pki_unknown_pubkey,
Routing.Error.TOO_LARGE.value to Res.string.message_routing_error_too_large,
Routing.Error.ADMIN_BAD_SESSION_KEY.value to Res.string.message_routing_error_admin_bad_session_key,
Routing.Error.ADMIN_PUBLIC_KEY_UNAUTHORIZED.value to
Res.string.message_routing_error_admin_public_key_unauthorized,
)

for ((routingError, expectedText) in mappings) {
Expand All @@ -327,6 +368,40 @@ class MessageTest {
}
}

@Test
fun getMessageStatusDetailRes_returnsActionableRoutingFailureDetails() {
val mappings =
listOf(
Routing.Error.NO_ROUTE.value to Res.string.message_routing_error_no_route_detail,
Routing.Error.GOT_NAK.value to Res.string.message_routing_error_got_nak_detail,
Routing.Error.TIMEOUT.value to Res.string.message_routing_error_timeout_detail,
Routing.Error.MAX_RETRANSMIT.value to Res.string.message_routing_error_max_retransmit_detail,
Routing.Error.NO_CHANNEL.value to Res.string.message_routing_error_no_channel_detail,
Routing.Error.NO_INTERFACE.value to Res.string.message_routing_error_no_interface_detail,
Routing.Error.DUTY_CYCLE_LIMIT.value to Res.string.message_routing_error_duty_cycle_limit_detail,
Routing.Error.RATE_LIMIT_EXCEEDED.value to Res.string.message_routing_error_rate_limit_exceeded_detail,
Routing.Error.TOO_LARGE.value to Res.string.message_routing_error_too_large_detail,
Routing.Error.NO_RESPONSE.value to Res.string.message_routing_error_no_response_detail,
Routing.Error.BAD_REQUEST.value to Res.string.message_routing_error_bad_request_detail,
Routing.Error.NOT_AUTHORIZED.value to Res.string.message_routing_error_not_authorized_detail,
Routing.Error.PKI_FAILED.value to Res.string.message_routing_error_pki_failed_detail,
Routing.Error.PKI_UNKNOWN_PUBKEY.value to Res.string.message_routing_error_pki_unknown_pubkey_detail,
Routing.Error.PKI_SEND_FAIL_PUBLIC_KEY.value to
Res.string.message_routing_error_pki_send_fail_public_key_detail,
Routing.Error.ADMIN_BAD_SESSION_KEY.value to
Res.string.message_routing_error_admin_bad_session_key_detail,
Routing.Error.ADMIN_PUBLIC_KEY_UNAUTHORIZED.value to
Res.string.message_routing_error_admin_public_key_unauthorized_detail,
)

for ((routingError, expectedDetail) in mappings) {
assertEquals(expectedDetail, getMessageStatusDetailRes(MessageStatus.ERROR, routingError))
}

assertNull(getMessageStatusDetailRes(MessageStatus.DELIVERED, Routing.Error.MAX_RETRANSMIT.value))
assertNull(getMessageStatusDetailRes(MessageStatus.ERROR, Int.MAX_VALUE))
}

@Test
fun getStatusStringRes_returnsUnknownForMissingStatus() {
val message =
Expand Down Expand Up @@ -366,10 +441,19 @@ class MessageTest {
listOf(
Routing.Error.MAX_RETRANSMIT.value to Res.string.routing_error_max_retransmit,
Routing.Error.NO_CHANNEL.value to Res.string.routing_error_no_channel,
Routing.Error.NO_INTERFACE.value to Res.string.routing_error_no_interface,
Routing.Error.DUTY_CYCLE_LIMIT.value to Res.string.routing_error_duty_cycle_limit,
Routing.Error.RATE_LIMIT_EXCEEDED.value to Res.string.routing_error_rate_limit_exceeded,
Routing.Error.NO_RESPONSE.value to Res.string.routing_error_no_response,
Routing.Error.BAD_REQUEST.value to Res.string.routing_error_bad_request,
Routing.Error.NOT_AUTHORIZED.value to Res.string.routing_error_not_authorized,
Routing.Error.PKI_FAILED.value to Res.string.routing_error_pki_failed,
Routing.Error.PKI_SEND_FAIL_PUBLIC_KEY.value to Res.string.routing_error_pki_send_fail_public_key,
Routing.Error.PKI_UNKNOWN_PUBKEY.value to Res.string.routing_error_pki_unknown_pubkey,
Routing.Error.TOO_LARGE.value to Res.string.routing_error_too_large,
Routing.Error.ADMIN_BAD_SESSION_KEY.value to Res.string.routing_error_admin_bad_session_key,
Routing.Error.ADMIN_PUBLIC_KEY_UNAUTHORIZED.value to
Res.string.routing_error_admin_public_key_unauthorized,
)

for ((routingError, expectedText) in mappings) {
Expand All @@ -385,9 +469,17 @@ class MessageTest {
)
val retryableRoutingErrors =
listOf(
Routing.Error.NO_INTERFACE.value,
Routing.Error.NO_RESPONSE.value,
Routing.Error.BAD_REQUEST.value,
Routing.Error.NOT_AUTHORIZED.value,
Routing.Error.DUTY_CYCLE_LIMIT.value,
Routing.Error.PKI_FAILED.value,
Routing.Error.PKI_SEND_FAIL_PUBLIC_KEY.value,
Routing.Error.PKI_UNKNOWN_PUBKEY.value,
Routing.Error.ADMIN_BAD_SESSION_KEY.value,
Routing.Error.ADMIN_PUBLIC_KEY_UNAUTHORIZED.value,
Routing.Error.RATE_LIMIT_EXCEEDED.value,
)

for (routingError in retryableRoutingErrors) {
Expand Down
Loading
Loading