Add "announce" activity for incoming Diaspora reshares
This commit is contained in:
parent
2f20ba4aa7
commit
455616b52c
1 changed files with 53 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue