-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
obfuscate item names in Amazon order emails
- Loading branch information
1 parent
8f39da0
commit 9286095
Showing
3 changed files
with
10 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.commons.lang3.time.DateUtils; | ||
import org.apache.commons.mail.util.MimeMessageParser; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
import javax.activation.DataSource; | ||
import javax.mail.Flags; | ||
|
@@ -27,6 +28,10 @@ | |
@Log4j2 | ||
public class Message { | ||
|
||
@JsonIgnore | ||
@Value("${obfuscateAmazonOrderSubject:false}") | ||
private boolean obfuscateAmazonOrderSubject; | ||
|
||
private long id; | ||
private long uid; | ||
/** | ||
|
@@ -87,6 +92,9 @@ public Message(javax.mail.Message message, long uid, boolean alreadyExists, Stri | |
this.fromAddress = sender.getAddress(); | ||
this.fromPersonal = sender.getPersonal(); | ||
} | ||
if (obfuscateAmazonOrderSubject && this.fromAddress.equalsIgnoreCase("[email protected]")) { | ||
this.subject = subject.replaceAll("\"(.*?)\"", "*****"); | ||
} | ||
javax.mail.Address[] recipients = message.getRecipients(javax.mail.Message.RecipientType.TO); | ||
if (ArrayUtils.isNotEmpty(recipients)) { | ||
this.recipients = Arrays.stream(recipients).map(javax.mail.Address::toString).collect(Collectors.toList()); | ||
|