updated notification subject parsing to support newline separators for sender and message, while maintaining a fallback for legacy colon-delimited formats.
This commit is contained in:
@@ -150,8 +150,20 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
// delivered notifications).
|
||||
}
|
||||
|
||||
/// Splits `"Sender: message"` into its parts; falls back to a generic sender.
|
||||
/// Splits a Talk subject into header and message. nextcloud/spreed's
|
||||
/// Notifier separates them with a NEWLINE — `"{user}\n{message}"` for 1:1
|
||||
/// chats, `"{user} in {call}\n{message}"` for groups (verified against
|
||||
/// spreed; mirrors parseTalkSubject in lib/push/push_subject.dart). The
|
||||
/// legacy `": "` form is kept as fallback for older payloads.
|
||||
private func splitSender(_ subject: String) -> (String, String) {
|
||||
if let range = subject.range(of: "\n") {
|
||||
let sender = String(subject[..<range.lowerBound])
|
||||
.trimmingCharacters(in: .whitespaces)
|
||||
let message = String(subject[range.upperBound...])
|
||||
if !sender.isEmpty && !message.isEmpty {
|
||||
return (sender, message)
|
||||
}
|
||||
}
|
||||
if let range = subject.range(of: ": ") {
|
||||
let sender = String(subject[..<range.lowerBound])
|
||||
let message = String(subject[range.upperBound...])
|
||||
|
||||
Reference in New Issue
Block a user