Improved direction and protocol detection

This commit is contained in:
Michael 2021-01-09 12:59:30 +00:00
commit 2987070d93
14 changed files with 95 additions and 164 deletions

View file

@ -193,7 +193,7 @@ function dfrn_notify_post(App $a) {
Logger::log('Importing post from ' . $importer['addr'] . ' to ' . $importer['nickname'] . ' with the RINO ' . $rino_remote . ' encryption.', Logger::DEBUG);
$ret = DFRN::import($data, $importer, false, Conversation::PARCEL_LEGACY_DFRN);
$ret = DFRN::import($data, $importer, Conversation::PARCEL_LEGACY_DFRN, Conversation::PUSH);
System::xmlExit($ret, 'Processed');
// NOTREACHED
@ -225,7 +225,7 @@ function dfrn_dispatch_public($postdata)
Logger::log('Importing post from ' . $msg['author'] . ' with the public envelope.', Logger::DEBUG);
// Now we should be able to import it
$ret = DFRN::import($msg['message'], $importer, false, Conversation::PARCEL_DIASPORA_DFRN);
$ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::PUSH);
System::xmlExit($ret, 'Done');
}
@ -258,7 +258,7 @@ function dfrn_dispatch_private($user, $postdata)
Logger::log('Importing post from ' . $msg['author'] . ' to ' . $user['nickname'] . ' with the private envelope.', Logger::DEBUG);
// Now we should be able to import it
$ret = DFRN::import($msg['message'], $importer, false, Conversation::PARCEL_DIASPORA_DFRN);
$ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::PUSH);
System::xmlExit($ret, 'Done');
}

View file

@ -25,12 +25,13 @@ use Friendica\Content\Nav;
use Friendica\Content\Widget\CalendarExport;
use Friendica\Core\ACL;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Event;
use Friendica\Model\Item;
use Friendica\Model\User;
@ -204,6 +205,9 @@ function events_post(App $a)
$datarray['deny_gid'] = $str_group_deny;
$datarray['private'] = $private_event;
$datarray['id'] = $event_id;
$datarray['network'] = Protocol::DFRN;
$datarray['protocol'] = Conversation::PARCEL_DIRECT;
$datarray['direction'] = Conversation::PUSH;
if (intval($_REQUEST['preview'])) {
$html = Event::getHTML($datarray);

View file

@ -623,6 +623,7 @@ function item_post(App $a) {
// This field is for storing the raw conversation data
$datarray['protocol'] = Conversation::PARCEL_DIRECT;
$datarray['direction'] = Conversation::PUSH;
$conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['thr-parent']]);
if (DBA::isResult($conversation)) {

View file

@ -139,20 +139,15 @@ function pubsub_post(App $a)
hub_post_return();
}
// We import feeds from OStatus, Friendica and ATOM/RSS.
/// @todo Check if Friendica posts really arrive here - otherwise we can discard some stuff
if (!in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN, Protocol::FEED])) {
// We only import feeds from OStatus here
if ($contact['network'] != Protocol::OSTATUS) {
Logger::warning('Unexpected network', ['contact' => $contact]);
hub_post_return();
}
Logger::log('Import item for ' . $nick . ' from ' . $contact['nick'] . ' (' . $contact['id'] . ')');
$feedhub = '';
Feed::consume($xml, $importer, $contact, $feedhub);
// do it a second time for DFRN so that any children find their parents.
if ($contact['network'] === Protocol::DFRN) {
Feed::consume($xml, $importer, $contact, $feedhub);
}
OStatus::import($xml, $importer, $contact, $feedhub);
hub_post_return();
}