Browse Source

Merge pull request #6476 from annando/ap-reshare

AP: Only reshare stuff that is AP content
pull/7053/head
Hypolite Petovan 2 years ago
committed by GitHub
parent
commit
aba617ae25
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 3 deletions
  1. +22
    -3
      src/Protocol/ActivityPub/Transmitter.php

+ 22
- 3
src/Protocol/ActivityPub/Transmitter.php View File

@ -548,7 +548,15 @@ class Transmitter
*/
private static function getTypeOfItem($item)
{
if (!empty(Diaspora::isReshare($item['body'], false))) {
$reshared = false;
// Only check for a reshare, if it is a real reshare and no quoted reshare
if (strpos($item['body'], "[share") === 0) {
$announce = api_share_as_retweet($item);
$reshared = !empty($announce['plink']);
}
if ($reshared) {
$type = 'Announce';
} elseif ($item['verb'] == ACTIVITY_POST) {
if ($item['created'] == $item['edited']) {
@ -747,7 +755,8 @@ class Transmitter
$terms = Term::tagArrayFromItemId($item['id']);
foreach ($terms as $term) {
if ($term['type'] == TERM_HASHTAG) {
$tags[] = ['type' => 'Hashtag', 'href' => $term['url'], 'name' => '#' . $term['term']];
$url = System::baseUrl() . '/search?tag=' . urlencode($term['term']);
$tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['term']];
} elseif ($term['type'] == TERM_MENTION) {
$contact = Contact::getDetailsByURL($term['url']);
if (!empty($contact['addr'])) {
@ -1018,7 +1027,17 @@ class Transmitter
return self::createNote($item);
}
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);
}
/**


Loading…
Cancel
Save