mail-notify: fix NPE when sender is only mail address without name
This commit is contained in:
		
							parent
							
								
									5b0216753e
								
							
						
					
					
						commit
						7b7c3dd36f
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		|  | @ -12,13 +12,13 @@ val icon = "/usr/share/icons/Adwaita/48x48/actions/mail-message-new.png" | ||||||
| val cacheFile = envPath("XDG_CACHE_HOME", os.home/".cache") / "seen-mails" | val cacheFile = envPath("XDG_CACHE_HOME", os.home/".cache") / "seen-mails" | ||||||
| val maildir = envPath("MAILDIR", os.home/"Mail") | val maildir = envPath("MAILDIR", os.home/"Mail") | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| case class MailInfo(from: String, subject: String, mailbox: String) | case class MailInfo(from: String, subject: String, mailbox: String) | ||||||
| object MailInfo { | object MailInfo { | ||||||
|   def fromPath(p: os.Path, maildir: os.Path) = { |   def fromPath(p: os.Path, maildir: os.Path) = { | ||||||
|     val msg = readMessage(p) |     val msg = readMessage(p) | ||||||
|  |     val address = msg.getFrom.head.asInstanceOf[InternetAddress] | ||||||
|     MailInfo( |     MailInfo( | ||||||
|       msg.getFrom.head.asInstanceOf[InternetAddress].getPersonal.replace("&", "&"), |       Option(address.getPersonal).map(_.replace("&", "&")).getOrElse(address.getAddress), | ||||||
|       msg.getSubject.replace("&", "&"), |       msg.getSubject.replace("&", "&"), | ||||||
|       (p/up/up relativeTo maildir).toString |       (p/up/up relativeTo maildir).toString | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alexander Gehrke
						Alexander Gehrke