Receiving was tested, sending is implemented and tested as well, currently unused
This commit is contained in:
parent
f51a254ed0
commit
0594f13c35
|
@ -32,10 +32,10 @@ function dfrn_notify_post(App $a) {
|
|||
$msg = Diaspora::decodeRaw($user, $postdata);
|
||||
|
||||
// Check if the user has got this contact
|
||||
$cid = getIdForURL($msg['author'], $user['uid']);
|
||||
$cid = Contact::getIdForURL($msg['author'], $user['uid']);
|
||||
if (!$cid) {
|
||||
// Otherwise there should be a public contact
|
||||
$cid = getIdForURL($msg['author']);
|
||||
$cid = Contact::getIdForURL($msg['author']);
|
||||
if (!$cid) {
|
||||
logger('Contact not found for address ' . $msg['author']);
|
||||
System::xmlExit(3, 'Contact not found');
|
||||
|
@ -59,7 +59,7 @@ function dfrn_notify_post(App $a) {
|
|||
|
||||
// Now we should be able to import it
|
||||
$ret = DFRN::import($msg['message'], $importer);
|
||||
System::xmlExit($ret, 'Processed');
|
||||
System::xmlExit($ret, 'Done');
|
||||
} else {
|
||||
require_once 'mod/salmon.php';
|
||||
salmon_post($a, $postdata);
|
||||
|
|
|
@ -31,6 +31,7 @@ use Friendica\Util\Crypto;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\XML;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
|
@ -1368,6 +1369,43 @@ class DFRN
|
|||
return intval($res->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delivers items to the contacts via the Diaspora transport layer
|
||||
*
|
||||
* @param array $owner Owner record
|
||||
* @param array $contact Contact record of the receiver
|
||||
* @param array $items Items that will be transmitted
|
||||
*
|
||||
* @return int HTTP Deliver status
|
||||
*/
|
||||
public static function buildAndTransmit($owner, $contact, $items)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
// Currently disabled, at first we will not use the batch delivery
|
||||
// $public_batch = !$items[0]['private'];
|
||||
$public_batch = false;
|
||||
|
||||
$msg = DFRN::entries($items, $owner);
|
||||
|
||||
$fcontact = Diaspora::personByHandle($contact['addr']);
|
||||
if (empty($fcontact)) {
|
||||
logger("unable to find contact details");
|
||||
return;
|
||||
}
|
||||
|
||||
$envelope = Diaspora::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $fcontact['pubkey'], $public_batch);
|
||||
|
||||
$dest_url = ($public_batch ? $fcontact["batch"] : $contact["notify"]);
|
||||
|
||||
$content_type = ($public_batch ? "application/magic-envelope+xml" : "application/json");
|
||||
|
||||
$ret = Network::post($dest_url, $envelope, ["Content-Type: ".$content_type]);
|
||||
|
||||
/// @ToDo: Add better treating of return codes
|
||||
return $a->get_curl_code();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add new birthday event for this person
|
||||
*
|
||||
|
|
|
@ -3205,7 +3205,7 @@ class Diaspora
|
|||
*
|
||||
* @return string The message that will be transmitted to other servers
|
||||
*/
|
||||
private static function buildMessage($msg, $user, $contact, $prvkey, $pubkey, $public = false)
|
||||
public static function buildMessage($msg, $user, $contact, $prvkey, $pubkey, $public = false)
|
||||
{
|
||||
// The message is put into an envelope with the sender's signature
|
||||
$envelope = self::buildMagicEnvelope($msg, $user);
|
||||
|
|
Loading…
Reference in New Issue
Block a user