// Logger::log("defining user ".$contact["nick"]." as friend");
//}
- // We don't seem to like that person
- if ($contact["blocked"]) {
+ // Contact server is blocked
+ if (Network::isUrlBlocked($contact['url'])) {
+ return false;
+ // We don't seem to like that person
+ } elseif ($contact["blocked"]) {
// Maybe blocked, don't accept.
return false;
// We are following this person?
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
*
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) {
if (!$return_code || (($return_code == 503) && (stristr($postResult->getHeader(), "retry-after")))) {
if (!$no_queue && !empty($contact['contact-type']) && ($contact['contact-type'] != Contact::TYPE_RELAY)) {
- Logger::log("queue message");
- // queue message for redelivery
- Queue::add($contact["id"], Protocol::DIASPORA, $envelope, $public_batch, $guid);
+ Logger::info('defer message', ['log' => $logid, 'guid' => $guid, 'destination' => $dest_url]);
+ // defer message for redelivery
+ Worker::defer();
}
// The message could not be delivered. We mark the contact as "dead"
* @param array $message The message data
* @param bool $public_batch Is it a public post?
* @param string $guid message guid
- * @param bool $spool Should the transmission be spooled or transmitted?
*
* @return int Result of the transmission
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- private static function buildAndTransmit(array $owner, array $contact, $type, $message, $public_batch = false, $guid = "", $spool = false)
+ private static function buildAndTransmit(array $owner, array $contact, $type, $message, $public_batch = false, $guid = "")
{
$msg = self::buildPostXml($type, $message);
$envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $contact['pubkey'], $public_batch);
- if ($spool) {
- Queue::add($contact['id'], Protocol::DIASPORA, $envelope, $public_batch, $guid);
- return true;
- } else {
- $return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid);
- }
+ $return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid);
Logger::log("guid: ".$guid." result ".$return_code, Logger::DEBUG);
foreach ($recips as $recip) {
Logger::log("Send updated profile data for user ".$uid." to contact ".$recip["id"], Logger::DEBUG);
- self::buildAndTransmit($owner, $recip, "profile", $message, false, "", false);
+ self::buildAndTransmit($owner, $recip, "profile", $message, false);
}
}