From 9e7c59481f8b08ba6acda89904299da9e700c8f8 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Sun, 20 Jan 2019 22:19:53 +0000
Subject: [PATCH] Improved ID detection

---
 src/Protocol/ActivityPub/Transmitter.php | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php
index cab0030577..671f4279a2 100644
--- a/src/Protocol/ActivityPub/Transmitter.php
+++ b/src/Protocol/ActivityPub/Transmitter.php
@@ -1029,8 +1029,17 @@ class Transmitter
 			return self::createNote($item);
 		}
 
-		/// @todo Better fetch the real object url.
-		return $announce['plink'];
+		// Fetch the original id of the object
+		$activity = ActivityPub::fetchContent($announce['plink'], $item['uid']);
+		if (!empty($activity)) {
+			$ldactivity = JsonLD::compact($activity);
+			$id = JsonLD::fetchElement($ldactivity, '@id');
+			if (!empty($id)) {
+				return $id;
+			}
+		}
+
+		return self::createNote($item);
 	}
 
 	/**
-- 
2.39.5