notification: harden reply + content PendingIntents (explicit action, FLAG_ONE_SHOT) (#753)

This commit is contained in:
M57 authored and GitHub committed 2026-07-31 23:38:37 +03:00
1 parent 422bb9f5e6
commit dc74eb4bc5
1 file changed
+8 -4
@@ -133,6 +133,7 @@ class ChatNotificationService : Service() {
val replyIntent =
Intent(this, NotificationReplyReceiver::class.java).apply {
action = "$packageName.ACTION_NOTIFICATION_REPLY"
putExtra(NotificationReplyReceiver.EXTRA_SESSION_ID, sessionId)
}
@@ -141,7 +142,7 @@ class ChatNotificationService : Service() {
this,
sessionId.hashCode(),
replyIntent,
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT,
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT,
)
val action =
@@ -161,8 +162,11 @@ class ChatNotificationService : Service() {
}
private fun buildContentIntent(sessionId: String?): PendingIntent {
val intent = Intent(this, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
val intent =
Intent(this, MainActivity::class.java).apply {
action = "$packageName.ACTION_OPEN_CHAT_FROM_NOTIFICATION"
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
}
if (!sessionId.isNullOrBlank()) {
intent.putExtra(NotificationReplyReceiver.EXTRA_SESSION_ID, sessionId)
}
@@ -170,7 +174,7 @@ class ChatNotificationService : Service() {
this,
sessionId?.hashCode() ?: 0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT,
)
}