// 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) {
$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);
- }
}
}
}
// 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
$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);
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;
'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
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;
}
* 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);
}
/**
- * @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)) {
$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;
}
$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;
}
/**
}
// 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);