Store the protocol of the received message

This commit is contained in:
Michael 2020-11-29 09:01:51 +00:00
commit 7ab63d2106
9 changed files with 38 additions and 37 deletions

View file

@ -28,6 +28,7 @@ use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\User;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
@ -192,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);
$ret = DFRN::import($data, $importer, false, Conversation::PARCEL_LEGACY_DFRN);
System::xmlExit($ret, 'Processed');
// NOTREACHED
@ -224,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);
$ret = DFRN::import($msg['message'], $importer, false, Conversation::PARCEL_DIASPORA_DFRN);
System::xmlExit($ret, 'Done');
}
@ -257,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);
$ret = DFRN::import($msg['message'], $importer, false, Conversation::PARCEL_DIASPORA_DFRN);
System::xmlExit($ret, 'Done');
}

View file

@ -81,8 +81,6 @@ function item_post(App $a) {
$api_source = $_REQUEST['api_source'] ?? false;
$message_id = ((!empty($_REQUEST['message_id']) && $api_source) ? strip_tags($_REQUEST['message_id']) : '');
$return_path = $_REQUEST['return'] ?? '';
$preview = intval($_REQUEST['preview'] ?? 0);
@ -176,14 +174,6 @@ function item_post(App $a) {
$profile_uid = $toplevel_user_id;
}
// Check for multiple posts with the same message id (when the post was created via API)
if (($message_id != '') && ($profile_uid != 0)) {
if (Item::exists(['uri' => $message_id, 'uid' => $profile_uid])) {
Logger::info('Message already exists for user', ['uri' => $message_id, 'uid' => $profile_uid]);
return 0;
}
}
// Allow commenting if it is an answer to a public post
$allow_comment = local_user() && ($profile_uid == 0) && $toplevel_item_id && in_array($toplevel_item['network'], Protocol::FEDERATED);
@ -562,7 +552,7 @@ function item_post(App $a) {
$origin = $_REQUEST['origin'];
}
$uri = ($message_id ? $message_id : Item::newURI($api_source ? $profile_uid : $uid, $guid));
$uri = Item::newURI($api_source ? $profile_uid : $uid, $guid);
// Fallback so that we alway have a parent uri
if (!$thr_parent_uri || !$toplevel_item_id) {
@ -628,7 +618,7 @@ function item_post(App $a) {
$datarray['api_source'] = $api_source;
// This field is for storing the raw conversation data
$datarray['protocol'] = Conversation::PARCEL_DFRN;
$datarray['protocol'] = Conversation::PARCEL_DIRECT;
$conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['thr-parent']]);
if (DBA::isResult($conversation)) {