mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
LAst clean up before PR
This commit is contained in:
parent
6c86618505
commit
3ea254c7ae
@ -50,6 +50,7 @@ class EmailMessage {
|
||||
private List<String> references = null;
|
||||
private String simplifiedSubject = "";
|
||||
private boolean isReplySubject = false;
|
||||
private String messageThreadID = "";
|
||||
|
||||
boolean hasAttachment() {
|
||||
return hasAttachment;
|
||||
@ -267,6 +268,24 @@ class EmailMessage {
|
||||
this.references = references;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ThreadID of this message.
|
||||
*
|
||||
* @param threadID - the thread ID to set
|
||||
*/
|
||||
void setMessageThreadID(String threadID) {
|
||||
this.messageThreadID = threadID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ThreadID for this message.
|
||||
*
|
||||
* @return - the message thread ID or "" is non is available
|
||||
*/
|
||||
String getMessageThreadID() {
|
||||
return this.messageThreadID;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Record to hold generic information about attachments.
|
||||
*
|
||||
|
@ -39,7 +39,7 @@ final class EmailMessageThreader {
|
||||
|
||||
private int bogus_id_count = 0;
|
||||
|
||||
public Set<Container> threadMessages(List<EmailMessage> emailMessages) {
|
||||
public void threadMessages(List<EmailMessage> emailMessages, String threadIDPrefix) {
|
||||
HashMap<String, Container> id_table = createIDTable(emailMessages);
|
||||
Set<Container> rootSet = getRootSet(id_table);
|
||||
|
||||
@ -47,9 +47,7 @@ final class EmailMessageThreader {
|
||||
|
||||
Set<Container> finalSet = groupBySubject(rootSet);
|
||||
|
||||
printContainerSet(finalSet, "");
|
||||
|
||||
return finalSet;
|
||||
assignThreadIDs(finalSet, threadIDPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,7 +57,7 @@ final class EmailMessageThreader {
|
||||
*
|
||||
* @param emailMessages
|
||||
*
|
||||
* @return
|
||||
* @return - HashMap of all message where the key is the message-ID of the message
|
||||
*/
|
||||
private HashMap<String, Container> createIDTable(List<EmailMessage> emailMessages) {
|
||||
HashMap<String, Container> id_table = new HashMap<>();
|
||||
@ -197,7 +195,6 @@ final class EmailMessageThreader {
|
||||
Set<Container> containersToRemove = new HashSet<>();
|
||||
containerSet.forEach((container) -> {
|
||||
if (!container.hasMessage() && !container.hasChildren()) {
|
||||
// containerSet.remove(container);
|
||||
containersToRemove.add(container);
|
||||
} else {
|
||||
pruneChildren(container);
|
||||
@ -229,8 +226,6 @@ final class EmailMessageThreader {
|
||||
Set<Container> add = new HashSet<>();
|
||||
for (Container child : parent.getChildren()) {
|
||||
if (pruneChildren(child)) {
|
||||
// parent.addChildren(child.getChildren());
|
||||
// parent.removeChild(child);
|
||||
remove.add(child);
|
||||
add.addAll(child.getChildren());
|
||||
child.setParent(null);
|
||||
@ -243,9 +238,9 @@ final class EmailMessageThreader {
|
||||
parent.removeChildren(remove);
|
||||
|
||||
if (!parent.hasMessage() && grandParent != null) {
|
||||
for (Container child : children) {
|
||||
children.forEach((child) -> {
|
||||
child.setParent(grandParent);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -393,6 +388,32 @@ final class EmailMessageThreader {
|
||||
return subject_table;
|
||||
}
|
||||
|
||||
private void assignThreadIDs(Set<Container> containerSet, String IDPrefix) {
|
||||
int threadCounter = 0;
|
||||
|
||||
for(Container container: containerSet) {
|
||||
String threadID = String.format("%s-%d", IDPrefix, threadCounter++);
|
||||
addThreadID(container, threadID);
|
||||
}
|
||||
}
|
||||
|
||||
private void addThreadID(Container container, String threadID) {
|
||||
if(container == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EmailMessage message = container.getMessage();
|
||||
if(message != null) {
|
||||
message.setMessageThreadID(threadID);
|
||||
}
|
||||
|
||||
if(container.hasChildren()) {
|
||||
for(Container child: container.getChildren()) {
|
||||
addThreadID(child, threadID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a set of containers and their children.
|
||||
*
|
||||
|
@ -411,7 +411,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
|
||||
List<AbstractFile> derivedFiles = new ArrayList<>();
|
||||
|
||||
EmailMessageThreader threader = new EmailMessageThreader();
|
||||
threader.threadMessages(emails);
|
||||
threader.threadMessages(emails, String.format("%d", abstractFile.getId()));
|
||||
|
||||
for (EmailMessage email : emails) {
|
||||
BlackboardArtifact msgArtifact = addEmailArtifact(email, abstractFile);
|
||||
@ -511,6 +511,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
|
||||
String subject = email.getSubject();
|
||||
long id = email.getId();
|
||||
String localPath = email.getLocalPath();
|
||||
String threadID = email.getMessageThreadID();
|
||||
|
||||
List<String> senderAddressList = new ArrayList<>();
|
||||
String senderAddress;
|
||||
@ -568,6 +569,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
|
||||
addArtifactAttribute(cc, ATTRIBUTE_TYPE.TSK_EMAIL_CC, bbattributes);
|
||||
addArtifactAttribute(bodyHTML, ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_HTML, bbattributes);
|
||||
addArtifactAttribute(rtf, ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_RTF, bbattributes);
|
||||
addArtifactAttribute(threadID, ATTRIBUTE_TYPE.TSK_THREAD_ID, bbattributes);
|
||||
|
||||
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user