Skip to content

Commit

Permalink
sepinf-inc#2286: lookup location in jumptargets if IsLocationSharing …
Browse files Browse the repository at this point in the history
…== true
  • Loading branch information
aberenguel committed Oct 24, 2024
1 parent b4113a8 commit 1bfcb6e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Message implements Comparable<Message> {

private List<MessageChatActivity> activityLog = new ArrayList<>();
private List<MessageAttachment> attachments = new ArrayList<>();
private ReferencedLocalization referencedLocalization;
private ReferencedLocation referencedLocation;
private List<MessageContact> sharedContacts = new ArrayList<>();

private boolean systemMessage;
Expand Down Expand Up @@ -95,6 +95,10 @@ public String getLongitude() {
return readUfedMetadata(item, "Longitude");
}

public boolean isLocationSharing() {
return Boolean.parseBoolean(readUfedMetadata(item, "IsLocationSharing"));
}

public String getFrom() {
String from = item.getMetadata().get(ExtraProperties.COMMUNICATION_FROM);
if (from == null && isFromMe()) {
Expand Down Expand Up @@ -203,13 +207,13 @@ public MessageAttachment addAttachment(IItemReader attachItem) {
return attach;
}

public ReferencedLocalization getReferencedLocalization() {
return referencedLocalization;
public ReferencedLocation getReferencedLocation() {
return referencedLocation;
}

public ReferencedLocalization setReferencedLocalization(IItemReader localizationItem) {
referencedLocalization = new ReferencedLocalization(localizationItem);
return referencedLocalization;
public ReferencedLocation setReferencedLocation(IItemReader localizationItem) {
referencedLocation = new ReferencedLocation(localizationItem);
return referencedLocation;
}

public List<MessageContact> getSharedContacts() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import iped.data.IItemReader;
import iped.properties.ExtraProperties;

public class ReferencedLocalization extends AbstractReferencedItem {
public class ReferencedLocation extends AbstractReferencedItem {

public ReferencedLocalization(IItemReader item) {
public ReferencedLocation(IItemReader item) {
super(item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private String formatLocation(Message message) {

String lat = message.getLatitude();
String lon = message.getLongitude();
ReferencedLocalization localization = message.getReferencedLocalization();
ReferencedLocation localization = message.getReferencedLocation();

if (lat == null && lon == null && localization == null) {
return StringUtils.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ private Chat createChat(IItemReader chatItem, IItemSearcher searcher) {
private Message createMessage(IItemReader messageItem, Chat chat, IItemSearcher searcher) {

Message message = new Message(messageItem, chat);
handleMessagePosition(message, searcher);
handleMessageLocation(message, searcher);

List<IItemReader> msgChildren = messageItem.getChildren();
if (msgChildren != null) {
Expand Down Expand Up @@ -628,20 +628,36 @@ private void handleMessageSharedContact(Message message, IItemReader sharedConta
}
}

private void handleMessagePosition(Message message, IItemSearcher searcher) {
private void handleMessageLocation(Message message, IItemSearcher searcher) {

if (StringUtils.isBlank(message.getCoordinateId())) {
return;
if (!StringUtils.isBlank(message.getCoordinateId())) {

// the message and location shares the same "ufed:coordinate_id" that was added when merging in UfedXmlReader
String query = searcher.escapeQuery(ExtraProperties.UFED_COORDINATE_ID) + ":\"" + message.getCoordinateId() + "\"";
List<IItemReader> locationItems = searcher.search(query);
if (!locationItems.isEmpty()) {
if (locationItems.size() > 1) {
logger.warn("Found more than 1 location for coordinate: {}", locationItems);
}
message.setReferencedLocation(locationItems.get(0));
}
}

// the message and localizations shares the same "ufed:coordinate_id" that was added when merging in UfedXmlReader
String query = searcher.escapeQuery(ExtraProperties.UFED_COORDINATE_ID) + ":\"" + message.getCoordinateId() + "\"";
List<IItemReader> locatizationItems = searcher.search(query);
if (!locatizationItems.isEmpty()) {
if (locatizationItems.size() > 1) {
logger.warn("Found more than 1 localization for coordinate: {}", locatizationItems);
if (message.isLocationSharing() && message.getReferencedLocation() == null) {

// the location item is reference by jumptargets
String[] jumpTargets = message.getItem().getMetadata().getValues(ExtraProperties.UFED_JUMP_TARGETS);
if (jumpTargets.length > 0) {
String query = BasicProps.CONTENTTYPE + ":\"application/x-ufed-location\" && " //
+ searcher.escapeQuery(ExtraProperties.UFED_ID) + ":(\"" + StringUtils.join(jumpTargets, "\" \"") + "\")";
List<IItemReader> locationItems = searcher.search(query);
if (!locationItems.isEmpty()) {
if (locationItems.size() > 1) {
logger.warn("Found more than 1 location for jumptargets: {}", locationItems);
}
message.setReferencedLocation(locationItems.get(0));
}
}
message.setReferencedLocalization(locatizationItems.get(0));
}
}

Expand Down

0 comments on commit 1bfcb6e

Please sign in to comment.