Fixes duplicated transmissions and not working undo of like/dislike

This commit is contained in:
Michael 2018-10-27 11:09:23 +00:00
parent f2ddcbe632
commit 73f596cc46
7 changed files with 30 additions and 43 deletions

View file

@ -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);

View file

@ -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;
}
/**