mirror of
https://github.com/nextcloud/talk-android
synced 2025-01-31 11:32:00 +00:00
Mark as read - reduce scope of try/catch
NumberFormatException is expected only inside parseMessageId. To avoid masking other errors accidentally, seems better to have try/catch only around parseMessageId call. Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
parent
f5fce7c9c9
commit
dafa1bfb2e
@ -446,26 +446,28 @@ public class NotificationWorker extends Worker {
|
||||
|
||||
private void addMarkAsReadAction(NotificationCompat.Builder notificationBuilder, int systemNotificationId) {
|
||||
if (decryptedPushMessage.getObjectId() != null) {
|
||||
int messageId = 0;
|
||||
try {
|
||||
int messageId = parseMessageId(decryptedPushMessage.getObjectId());
|
||||
|
||||
// Build a PendingIntent for the mark as read action
|
||||
PendingIntent pendingIntent = buildIntentForAction(MarkAsReadReceiver.class,
|
||||
systemNotificationId,
|
||||
messageId);
|
||||
|
||||
NotificationCompat.Action action =
|
||||
new NotificationCompat.Action.Builder(R.drawable.ic_eye,
|
||||
context.getResources().getString(R.string.nc_mark_as_read),
|
||||
pendingIntent)
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
|
||||
.setShowsUserInterface(false)
|
||||
.build();
|
||||
|
||||
notificationBuilder.addAction(action);
|
||||
messageId = parseMessageId(decryptedPushMessage.getObjectId());
|
||||
} catch (NumberFormatException nfe) {
|
||||
Log.e(TAG, "Failed to parse messageId from objectId, skip adding mark-as-read action.", nfe);
|
||||
return;
|
||||
}
|
||||
|
||||
// Build a PendingIntent for the mark as read action
|
||||
PendingIntent pendingIntent = buildIntentForAction(MarkAsReadReceiver.class,
|
||||
systemNotificationId,
|
||||
messageId);
|
||||
|
||||
NotificationCompat.Action action =
|
||||
new NotificationCompat.Action.Builder(R.drawable.ic_eye,
|
||||
context.getResources().getString(R.string.nc_mark_as_read),
|
||||
pendingIntent)
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
|
||||
.setShowsUserInterface(false)
|
||||
.build();
|
||||
|
||||
notificationBuilder.addAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user