mirror of
https://github.com/friendica/friendica
synced 2025-05-05 21:44:11 +02:00
First posting tests
This commit is contained in:
parent
629cca1963
commit
e4d28629e4
4 changed files with 107 additions and 18 deletions
|
@ -15,6 +15,7 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\Queue;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\Email;
|
||||
|
||||
|
@ -165,6 +166,10 @@ class Delivery extends BaseObject
|
|||
|
||||
switch ($contact['network']) {
|
||||
|
||||
case Protocol::ACTIVITYPUB:
|
||||
self::deliverActivityPub($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
|
||||
break;
|
||||
|
||||
case Protocol::DFRN:
|
||||
self::deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
|
||||
break;
|
||||
|
@ -383,6 +388,83 @@ class Delivery extends BaseObject
|
|||
logger('Unknown mode ' . $cmd . ' for ' . $loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deliver content via ActivityPub
|
||||
q *
|
||||
* @param string $cmd Command
|
||||
* @param array $contact Contact record of the receiver
|
||||
* @param array $owner Owner record of the sender
|
||||
* @param array $items Item record of the content and the parent
|
||||
* @param array $target_item Item record of the content
|
||||
* @param boolean $public_message Is the content public?
|
||||
* @param boolean $top_level Is it a thread starter?
|
||||
* @param boolean $followup Is it an answer to a remote post?
|
||||
*/
|
||||
private static function deliverActivityPub($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
|
||||
{
|
||||
// We don't treat Forum posts as "wall-to-wall" to be able to post them via ActivityPub
|
||||
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY);
|
||||
|
||||
if ($public_message) {
|
||||
$loc = 'public batch ' . $contact['batch'];
|
||||
} else {
|
||||
$loc = $contact['addr'];
|
||||
}
|
||||
|
||||
logger('Deliver ' . $target_item["guid"] . ' via ActivityPub to ' . $loc);
|
||||
|
||||
// if (Config::get('system', 'dfrn_only') || !Config::get('system', 'diaspora_enabled')) {
|
||||
// return;
|
||||
// }
|
||||
if ($cmd == self::MAIL) {
|
||||
// ActivityPub::sendMail($target_item, $owner, $contact);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($cmd == self::SUGGESTION) {
|
||||
return;
|
||||
}
|
||||
// if (!$contact['pubkey'] && !$public_message) {
|
||||
// logger('No public key, no delivery.');
|
||||
// return;
|
||||
// }
|
||||
if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
|
||||
// top-level retraction
|
||||
logger('ActivityPub retract: ' . $loc);
|
||||
// ActivityPub::sendRetraction($target_item, $owner, $contact, $public_message);
|
||||
return;
|
||||
} elseif ($cmd == self::RELOCATION) {
|
||||
// ActivityPub::sendAccountMigration($owner, $contact, $owner['uid']);
|
||||
return;
|
||||
} elseif ($followup) {
|
||||
// send comments and likes to owner to relay
|
||||
logger('ActivityPub followup: ' . $loc);
|
||||
$data = ActivityPub::createActivityFromItem($target_item['id']);
|
||||
$content = json_encode($data);
|
||||
ActivityPub::transmit($content, $contact['notify'], $owner['uid']);
|
||||
// ActivityPub::sendFollowup($target_item, $owner, $contact, $public_message);
|
||||
return;
|
||||
} elseif ($target_item['uri'] !== $target_item['parent-uri']) {
|
||||
// we are the relay - send comments, likes and relayable_retractions to our conversants
|
||||
logger('ActivityPub relay: ' . $loc);
|
||||
$data = ActivityPub::createActivityFromItem($target_item['id']);
|
||||
$content = json_encode($data);
|
||||
ActivityPub::transmit($content, $contact['notify'], $owner['uid']);
|
||||
// ActivityPub::sendRelay($target_item, $owner, $contact, $public_message);
|
||||
return;
|
||||
} elseif ($top_level && !$walltowall) {
|
||||
// currently no workable solution for sending walltowall
|
||||
logger('ActivityPub status: ' . $loc);
|
||||
$data = ActivityPub::createActivityFromItem($target_item['id']);
|
||||
$content = json_encode($data);
|
||||
ActivityPub::transmit($content, $contact['notify'], $owner['uid']);
|
||||
// ActivityPub::sendStatus($target_item, $owner, $contact, $public_message);
|
||||
return;
|
||||
}
|
||||
|
||||
logger('Unknown mode ' . $cmd . ' for ' . $loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deliver content via mail
|
||||
*
|
||||
|
|
|
@ -448,7 +448,7 @@ class Notifier
|
|||
}
|
||||
}
|
||||
|
||||
$condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
|
||||
$condition = ['network' => [Protocol::DFRN, Protocol::ACTIVITYPUB], 'uid' => $owner['uid'], 'blocked' => false,
|
||||
'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
|
||||
|
||||
$r2 = DBA::toArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue