Convert static methods to dynamic in Module\DFRN\Notify
This commit is contained in:
parent
46152ab400
commit
bd9292fe19
|
@ -52,37 +52,37 @@ class Notify extends BaseModule
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||||
}
|
}
|
||||||
self::dispatchPrivate($user, $postdata);
|
$this->dispatchPrivate($user, $postdata);
|
||||||
} elseif (!self::dispatchPublic($postdata)) {
|
} elseif (!$this->dispatchPublic($postdata)) {
|
||||||
require_once 'mod/salmon.php';
|
require_once 'mod/salmon.php';
|
||||||
salmon_post(DI::app(), $postdata);
|
salmon_post(DI::app(), $postdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function dispatchPublic(string $postdata): bool
|
private function dispatchPublic(string $postdata): bool
|
||||||
{
|
{
|
||||||
$msg = Diaspora::decodeRaw($postdata, '', true);
|
$msg = Diaspora::decodeRaw($postdata, '', true);
|
||||||
if (!is_array($msg)) {
|
if (!is_array($msg)) {
|
||||||
// We have to fail silently to be able to hand it over to the salmon parser
|
// We have to fail silently to be able to hand it over to the salmon parser
|
||||||
Logger::warning('Diaspora::decodeRaw() has failed for some reason.');
|
$this->logger->warning('Diaspora::decodeRaw() has failed for some reason.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the corresponding public contact
|
// Fetch the corresponding public contact
|
||||||
$contact_id = Contact::getIdForURL($msg['author']);
|
$contact_id = Contact::getIdForURL($msg['author']);
|
||||||
if (empty($contact_id)) {
|
if (empty($contact_id)) {
|
||||||
Logger::notice('Contact not found', ['address' => $msg['author']]);
|
$this->logger->notice('Contact not found', ['address' => $msg['author']]);
|
||||||
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the importer (Mixture of sender and receiver)
|
// Fetch the importer (Mixture of sender and receiver)
|
||||||
$importer = DFRN::getImporter($contact_id);
|
$importer = DFRN::getImporter($contact_id);
|
||||||
if (empty($importer)) {
|
if (empty($importer)) {
|
||||||
Logger::notice('Importer contact not found', ['address' => $msg['author']]);
|
$this->logger->notice('Importer contact not found', ['address' => $msg['author']]);
|
||||||
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::debug('Importing post with the public envelope.', ['transmitter' => $msg['author']]);
|
$this->logger->debug('Importing post with the public envelope.', ['transmitter' => $msg['author']]);
|
||||||
|
|
||||||
// Now we should be able to import it
|
// Now we should be able to import it
|
||||||
$ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::RELAY);
|
$ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::RELAY);
|
||||||
|
@ -91,7 +91,7 @@ class Notify extends BaseModule
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function dispatchPrivate(array $user, string $postdata)
|
private function dispatchPrivate(array $user, string $postdata)
|
||||||
{
|
{
|
||||||
$msg = Diaspora::decodeRaw($postdata, $user['prvkey'] ?? '');
|
$msg = Diaspora::decodeRaw($postdata, $user['prvkey'] ?? '');
|
||||||
if (!is_array($msg)) {
|
if (!is_array($msg)) {
|
||||||
|
@ -101,23 +101,23 @@ class Notify extends BaseModule
|
||||||
// Fetch the contact
|
// Fetch the contact
|
||||||
$contact = Contact::getByURLForUser($msg['author'], $user['uid'], null, ['id', 'blocked', 'pending']);
|
$contact = Contact::getByURLForUser($msg['author'], $user['uid'], null, ['id', 'blocked', 'pending']);
|
||||||
if (empty($contact['id'])) {
|
if (empty($contact['id'])) {
|
||||||
Logger::notice('Contact not found', ['address' => $msg['author']]);
|
$this->logger->notice('Contact not found', ['address' => $msg['author']]);
|
||||||
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact['pending'] || $contact['blocked']) {
|
if ($contact['pending'] || $contact['blocked']) {
|
||||||
Logger::notice('Contact is blocked or pending', ['address' => $msg['author'], 'contact' => $contact]);
|
$this->logger->notice('Contact is blocked or pending', ['address' => $msg['author'], 'contact' => $contact]);
|
||||||
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the importer (Mixture of sender and receiver)
|
// Fetch the importer (Mixture of sender and receiver)
|
||||||
$importer = DFRN::getImporter($contact['id'], $user['uid']);
|
$importer = DFRN::getImporter($contact['id'], $user['uid']);
|
||||||
if (empty($importer)) {
|
if (empty($importer)) {
|
||||||
Logger::notice('Importer contact not found for user', ['uid' => $user['uid'], 'cid' => $contact['id'], 'address' => $msg['author']]);
|
$this->logger->notice('Importer contact not found for user', ['uid' => $user['uid'], 'cid' => $contact['id'], 'address' => $msg['author']]);
|
||||||
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::debug('Importing post with the private envelope.', ['transmitter' => $msg['author'], 'receiver' => $user['nickname']]);
|
$this->logger->debug('Importing post with the private envelope.', ['transmitter' => $msg['author'], 'receiver' => $user['nickname']]);
|
||||||
|
|
||||||
// Now we should be able to import it
|
// Now we should be able to import it
|
||||||
$ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::PUSH);
|
$ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::PUSH);
|
||||||
|
|
Loading…
Reference in a new issue