Public posts are now transferred successfully to the DFRN part
This commit is contained in:
parent
c59b28a8c4
commit
b77ae3a8a7
1 changed files with 20 additions and 20 deletions
|
@ -25,24 +25,13 @@ function dfrn_notify_post(App $a) {
|
||||||
$data = json_decode($postdata);
|
$data = json_decode($postdata);
|
||||||
if (is_object($data)) {
|
if (is_object($data)) {
|
||||||
$nick = defaults($a->argv, 1, '');
|
$nick = defaults($a->argv, 1, '');
|
||||||
$public = empty($nick);
|
|
||||||
if (!$public) {
|
|
||||||
$user = dba::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
|
$user = dba::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
|
||||||
if (!DBM::is_result($user)) {
|
if (!DBM::is_result($user)) {
|
||||||
System::httpExit(500);
|
System::httpExit(500);
|
||||||
}
|
}
|
||||||
} else {
|
dfrn_dispatch_private($user, $postdata);
|
||||||
// We don't need the user with public posts
|
} elseif (!dfrn_dispatch_public($postdata)) {
|
||||||
$user = [];
|
|
||||||
}
|
|
||||||
$msg = Diaspora::decodeRaw($user, $postdata);
|
|
||||||
|
|
||||||
if ($public) {
|
|
||||||
dfrn_dispatch_public($msg);
|
|
||||||
} else {
|
|
||||||
dfrn_dispatch_private($user, $msg);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
require_once 'mod/salmon.php';
|
require_once 'mod/salmon.php';
|
||||||
salmon_post($a, $postdata);
|
salmon_post($a, $postdata);
|
||||||
}
|
}
|
||||||
|
@ -207,10 +196,16 @@ function dfrn_notify_post(App $a) {
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
function dfrn_dispatch_public($msg)
|
function dfrn_dispatch_public($postdata)
|
||||||
{
|
{
|
||||||
|
$msg = Diaspora::decodeRaw([], $postdata);
|
||||||
|
if (!$msg) {
|
||||||
|
// We have to fail silently to be able to hand it over to the salmon parser
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch the corresponding public contact
|
// Fetch the corresponding public contact
|
||||||
$contact = getDetailsByAddr($msg['author'], 0);
|
$contact = Contact::getDetailsByAddr($msg['author'], 0);
|
||||||
if (!$contact) {
|
if (!$contact) {
|
||||||
logger('Contact not found for address ' . $msg['author']);
|
logger('Contact not found for address ' . $msg['author']);
|
||||||
System::xmlExit(3, 'Contact not found');
|
System::xmlExit(3, 'Contact not found');
|
||||||
|
@ -220,7 +215,7 @@ function dfrn_dispatch_public($msg)
|
||||||
$importer = dba::fetch_first("SELECT *, `name` as `senderName`
|
$importer = dba::fetch_first("SELECT *, `name` as `senderName`
|
||||||
FROM `contact`
|
FROM `contact`
|
||||||
WHERE NOT `blocked` AND `id` = ? LIMIT 1",
|
WHERE NOT `blocked` AND `id` = ? LIMIT 1",
|
||||||
$cid);
|
$contact['id']);
|
||||||
|
|
||||||
// This should never fail
|
// This should never fail
|
||||||
if (!DBM::is_result($importer)) {
|
if (!DBM::is_result($importer)) {
|
||||||
|
@ -235,8 +230,13 @@ function dfrn_dispatch_public($msg)
|
||||||
System::xmlExit($ret, 'Done');
|
System::xmlExit($ret, 'Done');
|
||||||
}
|
}
|
||||||
|
|
||||||
function dfrn_dispatch_private($user, $msg)
|
function dfrn_dispatch_private($user, $postdata)
|
||||||
{
|
{
|
||||||
|
$msg = Diaspora::decodeRaw($user, $postdata);
|
||||||
|
if (!$msg) {
|
||||||
|
System::xmlExit(4, 'Unable to parse message');
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the user has got this contact
|
// Check if the user has got this contact
|
||||||
$cid = Contact::getIdForURL($msg['author'], $user['uid']);
|
$cid = Contact::getIdForURL($msg['author'], $user['uid']);
|
||||||
if (!$cid) {
|
if (!$cid) {
|
||||||
|
|
Loading…
Reference in a new issue