Merge pull request #6035 from annando/delivery-chaos
Fixes duplicated transmissions and not working undo of like/dislike
This commit is contained in:
commit
ea7a08ace2
|
@ -830,9 +830,6 @@ function item_post(App $a) {
|
|||
// We don't fork a new process since this is done anyway with the following command
|
||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "CreateShadowEntry", $post_id);
|
||||
|
||||
// Call the background process that is delivering the item to the receivers
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", $notify_type, $post_id);
|
||||
|
||||
logger('post_complete');
|
||||
|
||||
if ($api_source) {
|
||||
|
|
|
@ -691,9 +691,6 @@ function photos_post(App $a)
|
|||
$arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . System::baseUrl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
|
||||
|
||||
$item_id = Item::insert($arr);
|
||||
if ($item_id) {
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", "tag", $item_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -919,10 +916,6 @@ function photos_post(App $a)
|
|||
// Update the photo albums cache
|
||||
Photo::clearAlbumCache($page_owner_uid);
|
||||
|
||||
if ($visible) {
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", 'wall-new', $item_id);
|
||||
}
|
||||
|
||||
Addon::callHooks('photo_post_end', $item_id);
|
||||
|
||||
// addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
|
||||
|
|
|
@ -128,9 +128,6 @@ function poke_init(App $a)
|
|||
$arr['object'] .= '</link></object>' . "\n";
|
||||
|
||||
$item_id = Item::insert($arr);
|
||||
if ($item_id) {
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", "tag", $item_id);
|
||||
}
|
||||
|
||||
Addon::callHooks('post_local_end', $arr);
|
||||
|
||||
|
|
|
@ -1827,9 +1827,17 @@ class Item extends BaseObject
|
|||
check_user_notification($current_post);
|
||||
|
||||
if ($notify) {
|
||||
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", $notify_type, $current_post);
|
||||
} elseif (!empty($parent) && $parent['origin']) {
|
||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", "comment-import", $current_post);
|
||||
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post);
|
||||
} elseif ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin'])) {
|
||||
if ($item['gravity'] == GRAVITY_ACTIVITY) {
|
||||
$cmd = $item['origin'] ? 'activity-new' : 'activity-import';
|
||||
} elseif ($item['gravity'] == GRAVITY_COMMENT) {
|
||||
$cmd = $item['origin'] ? 'comment-new' : 'comment-import';
|
||||
} else {
|
||||
$cmd = 'wall-new';
|
||||
}
|
||||
|
||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', $cmd, $current_post);
|
||||
}
|
||||
|
||||
return $current_post;
|
||||
|
@ -3103,6 +3111,11 @@ class Item extends BaseObject
|
|||
'unseen' => 1,
|
||||
];
|
||||
|
||||
$signed = Diaspora::createLikeSignature($item_contact, $new_item);
|
||||
if (!empty($signed)) {
|
||||
$new_item['diaspora_signed_text'] = $signed;
|
||||
}
|
||||
|
||||
$new_item_id = self::insert($new_item);
|
||||
|
||||
// If the parent item isn't visible then set it to visible
|
||||
|
@ -3110,15 +3123,10 @@ class Item extends BaseObject
|
|||
self::update(['visible' => true], ['id' => $item['id']]);
|
||||
}
|
||||
|
||||
// Save the author information for the like in case we need to relay to Diaspora
|
||||
Diaspora::storeLikeSignature($item_contact, $new_item_id);
|
||||
|
||||
$new_item['id'] = $new_item_id;
|
||||
|
||||
Addon::callHooks('post_local_end', $new_item);
|
||||
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", "like", $new_item_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -549,15 +549,19 @@ class Transmitter
|
|||
* Creates the activity or fetches it from the cache
|
||||
*
|
||||
* @param integer $item_id
|
||||
* @param boolean $force Force new cache entry
|
||||
*
|
||||
* @return array with the activity
|
||||
*/
|
||||
public static function createCachedActivityFromItem($item_id)
|
||||
public static function createCachedActivityFromItem($item_id, $force = false)
|
||||
{
|
||||
$cachekey = 'APDelivery:createActivity:' . $item_id;
|
||||
$data = Cache::get($cachekey);
|
||||
if (!is_null($data)) {
|
||||
return $data;
|
||||
|
||||
if (!$force) {
|
||||
$data = Cache::get($cachekey);
|
||||
if (!is_null($data)) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
$data = ActivityPub\Transmitter::createActivityFromItem($item_id);
|
||||
|
|
|
@ -4113,14 +4113,14 @@ class Diaspora
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Stores the signature for likes that are created on our system
|
||||
* @brief Creates the signature for likes that are created on our system
|
||||
*
|
||||
* @param array $contact The contact array of the "like"
|
||||
* @param int $post_id The post id of the "like"
|
||||
* @param array $item Item array
|
||||
*
|
||||
* @return bool Success
|
||||
* @return array Signed content
|
||||
*/
|
||||
public static function storeLikeSignature(array $contact, $post_id)
|
||||
public static function createLikeSignature(array $contact, array $item)
|
||||
{
|
||||
// Is the contact the owner? Then fetch the private key
|
||||
if (!$contact['self'] || ($contact['uid'] == 0)) {
|
||||
|
@ -4135,11 +4135,6 @@ class Diaspora
|
|||
|
||||
$contact["uprvkey"] = $user['prvkey'];
|
||||
|
||||
$item = Item::selectFirst([], ['id' => $post_id]);
|
||||
if (!DBA::isResult($item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
|
||||
return false;
|
||||
}
|
||||
|
@ -4151,14 +4146,7 @@ class Diaspora
|
|||
|
||||
$message["author_signature"] = self::signature($contact, $message);
|
||||
|
||||
/*
|
||||
* Now store the signature more flexible to dynamically support new fields.
|
||||
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
|
||||
*/
|
||||
DBA::insert('sign', ['iid' => $post_id, 'signed_text' => json_encode($message)]);
|
||||
|
||||
logger('Stored diaspora like signature');
|
||||
return true;
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -539,7 +539,7 @@ class Notifier
|
|||
}
|
||||
|
||||
// Fill the item cache
|
||||
ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
|
||||
ActivityPub\Transmitter::createCachedActivityFromItem($item_id, true);
|
||||
|
||||
foreach ($inboxes as $inbox) {
|
||||
logger('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
|
||||
|
|
Loading…
Reference in a new issue