From 9b387a226cca605e809f43eb9a3610faff4e61b2 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Sun, 21 Oct 2018 20:23:08 +0000
Subject: [PATCH] Fix webmentions and microformats ("redir" only for logged in
 users)

---
 include/conversation.php | 3 ++-
 src/Object/Post.php      | 8 +++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/conversation.php b/include/conversation.php
index 31920c2fcb..9e813b5eb0 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -353,7 +353,8 @@ function localize_item(&$item)
 	$author = ['uid' => 0, 'id' => $item['author-id'],
 		'network' => $item['author-network'], 'url' => $item['author-link']];
 
-	if (!empty($item['plink'])) {
+	// Only create a redirection to a magic link when logged in
+	if (!empty($item['plink']) && local_user()) {
 		$item['plink'] = Contact::magicLinkbyContact($author, $item['plink']);
 	}
 }
diff --git a/src/Object/Post.php b/src/Object/Post.php
index 34a5f8138a..1524678638 100644
--- a/src/Object/Post.php
+++ b/src/Object/Post.php
@@ -209,7 +209,13 @@ class Post extends BaseObject
 
 		$author = ['uid' => 0, 'id' => $item['author-id'],
 			'network' => $item['author-network'], 'url' => $item['author-link']];
-		$profile_link = Contact::magicLinkbyContact($author);
+
+		if (local_user()) {
+			$profile_link = Contact::magicLinkbyContact($author);
+		} else {
+			$profile_link = $item['author-link'];
+		}
+
 		if (strpos($profile_link, 'redir/') === 0) {
 			$sparkle = ' sparkle';
 		}
-- 
2.39.5