Browse Source

handle mailto urls without mail address but subject and/or body. Let the user decide which contact or chat to choose.

cyberta 4 years ago
parent
commit
313e2cff6d
1 changed files with 6 additions and 5 deletions
  1. 6 5
      deltachat-ios/Helper/RelayHelper.swift

+ 6 - 5
deltachat-ios/Helper/RelayHelper.swift

@@ -61,8 +61,7 @@ class RelayHelper {
             returns true if parsing was successful
      */
     func parseMailtoUrl(_ url: URL) -> Bool {
-        if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false),
-           !urlComponents.path.isEmpty {
+        if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
             var subject: String = ""
             var body: String = ""
             let queryItems = urlComponents.queryItems ?? []
@@ -83,14 +82,16 @@ class RelayHelper {
             if !subject.isEmpty {
                 mailtoDraft = subject
                 if !body.isEmpty {
-                    mailtoDraft += "\n\n \(body)"
+                    mailtoDraft += "\n\n\(body)"
                 }
             } else if !body.isEmpty {
                 mailtoDraft = body
             }
 
-            mailtoAddress = splitString(urlComponents.path)[0] // we currently only allow 1 receipient
-            return true
+            if !urlComponents.path.isEmpty {
+                mailtoAddress = splitString(urlComponents.path)[0] // we currently only allow 1 receipient
+            }
+            return mailtoAddress != nil || !mailtoDraft.isEmpty
         }
         return false
     }