From b470ee6401f01bf31cf157fbcd603019072d59b5 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 21 Jul 2024 18:13:32 -0700 Subject: [PATCH] Fix status/mention push notifications not showing CW and fix sensitive attachments being included in push notifications Closes #512 --- NotificationExtension/NotificationService.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/NotificationExtension/NotificationService.swift b/NotificationExtension/NotificationService.swift index 965c1f92..c33f7256 100644 --- a/NotificationExtension/NotificationService.swift +++ b/NotificationExtension/NotificationService.swift @@ -122,7 +122,12 @@ class NotificationService: UNNotificationServiceExtension { let notificationContent: String? if let status = notification.status { - notificationContent = NotificationService.textConverter.convert(html: status.content) + if notification.kind == .mention || notification.kind == .status, + !status.spoilerText.isEmpty { + notificationContent = "⚠️ \(status.spoilerText)" + } else { + notificationContent = NotificationService.textConverter.convert(html: status.content) + } } else if notification.kind == .follow || notification.kind == .followRequest { notificationContent = nil } else { @@ -135,7 +140,9 @@ class NotificationService: UNNotificationServiceExtension { // We deliberately don't include attachments for other types of notifications that have statuses (favs, etc.) // because we risk just fetching the same thing a bunch of times for many senders. if notification.kind == .mention || notification.kind == .status || notification.kind == .update, - let attachment = notification.status?.attachments.first { + let status = notification.status, + !status.sensitive, + let attachment = status.attachments.first { let url = attachment.previewURL ?? attachment.url attachmentDataTask = Task { do {