Merge pull request #6960 from annando/add-announce-diaspora

Add "announce" activity for incoming Diaspora reshares
2022.09-rc
Hypolite Petovan 2019-04-01 21:24:00 -04:00 zatwierdzone przez GitHub
commit b73caa83fc
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 53 dodań i 0 usunięć

Wyświetl plik

@ -2628,6 +2628,54 @@ class Diaspora
return false;
}
/**
* @brief Stores a reshare activity
*
* @param array $item Array of reshare post
* @param integer $parent_message_id Id of the parent post
* @param string $guid GUID string of reshare action
* @param string $author Author handle
*/
private static function addReshareActivity($item, $parent_message_id, $guid, $author)
{
$parent = Item::selectFirst(['uri', 'guid'], ['id' => $parent_message_id]);
$datarray = [];
$datarray['uid'] = $item['uid'];
$datarray['contact-id'] = $item['contact-id'];
$datarray['network'] = $item['network'];
$datarray['author-link'] = $item['author-link'];
$datarray['author-id'] = $item['author-id'];
$datarray['owner-link'] = $datarray['author-link'];
$datarray['owner-id'] = $datarray['author-id'];
$datarray['guid'] = $parent['guid'] . '-' . $guid;
$datarray['uri'] = self::getUriFromGuid($author, $datarray['guid']);
$datarray['parent-uri'] = $parent['uri'];
$datarray['verb'] = $datarray['body'] = ACTIVITY2_ANNOUNCE;
$datarray['gravity'] = GRAVITY_ACTIVITY;
$datarray['object-type'] = ACTIVITY_OBJ_NOTE;
$datarray['protocol'] = $item['protocol'];
$datarray['plink'] = self::plink($author, $datarray['guid']);
$datarray['private'] = $item['private'];
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = $item['created'];
$message_id = Item::insert($datarray);
if ($message_id) {
Logger::info('Stored reshare activity.', ['guid' => $guid, 'id' => $message_id]);
if ($datarray['uid'] == 0) {
Item::distribute($message_id);
}
}
}
/**
* @brief Processes a reshare message
*
@ -2711,6 +2759,11 @@ class Diaspora
self::sendParticipation($contact, $datarray);
$root_message_id = self::messageExists($importer["uid"], $root_guid);
if ($root_message_id) {
self::addReshareActivity($datarray, $root_message_id, $guid, $author);
}
if ($message_id) {
Logger::log("Stored reshare ".$datarray["guid"]." with message id ".$message_id, Logger::DEBUG);
if ($datarray['uid'] == 0) {