-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added showing thread messages count + correct labels + all recipients…
… in a thread.| #74
- Loading branch information
Showing
7 changed files
with
148 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...main/java/com/flowcrypt/email/extensions/com/google/api/services/gmail/model/ThreadExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: denbond7 | ||
*/ | ||
|
||
package com.flowcrypt.email.extensions.com.google.api.services.gmail.model | ||
|
||
import com.flowcrypt.email.extensions.kotlin.asInternetAddresses | ||
import com.google.api.services.gmail.model.Thread | ||
import jakarta.mail.internet.InternetAddress | ||
|
||
/** | ||
* @author Denys Bondarenko | ||
*/ | ||
fun Thread.getUniqueRecipients(): List<InternetAddress> { | ||
return mutableListOf<InternetAddress>().apply { | ||
val filteredHeaders = messages?.flatMap { message -> | ||
message?.payload?.headers?.filter { header -> | ||
//need to check this line and test | ||
header.name in listOf( | ||
"From", | ||
"To" | ||
)//maybe need to add Cc. need to check | ||
} ?: emptyList() | ||
} | ||
|
||
val mapOfUniqueRecipients = mutableMapOf<String, String>() | ||
filteredHeaders?.forEach { header -> | ||
header.value.asInternetAddresses().forEach { internetAddress -> | ||
val address = internetAddress.address.lowercase() | ||
|
||
if (!mapOfUniqueRecipients.contains(address) | ||
|| mapOfUniqueRecipients[address].isNullOrEmpty() | ||
) { | ||
add(internetAddress) | ||
mapOfUniqueRecipients[address] = internetAddress.personal | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters