Merge pull request #12364 from MrPetovan/bug/warnings
Address several warning messages
This commit is contained in:
commit
46660c9462
6 changed files with 70 additions and 35 deletions
|
@ -1395,9 +1395,17 @@ class Contact
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data['network'] == Protocol::DIASPORA) {
|
if ($data['network'] == Protocol::DIASPORA) {
|
||||||
DI::dsprContact()->updateFromProbeArray($data);
|
try {
|
||||||
|
DI::dsprContact()->updateFromProbeArray($data);
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
Logger::error($e->getMessage(), ['url' => $url, 'data' => $data]);
|
||||||
|
}
|
||||||
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
|
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
|
||||||
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
|
try {
|
||||||
|
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
Logger::error($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self::updateFromProbeArray($contact_id, $data);
|
self::updateFromProbeArray($contact_id, $data);
|
||||||
|
@ -2485,15 +2493,23 @@ class Contact
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = Probe::uri($contact['url'], $network, $contact['uid']);
|
$data = Probe::uri($contact['url'], $network, $contact['uid']);
|
||||||
|
|
||||||
if ($ret['network'] == Protocol::DIASPORA) {
|
if ($data['network'] == Protocol::DIASPORA) {
|
||||||
DI::dsprContact()->updateFromProbeArray($ret);
|
try {
|
||||||
} elseif (!empty($ret['networks'][Protocol::DIASPORA])) {
|
DI::dsprContact()->updateFromProbeArray($data);
|
||||||
DI::dsprContact()->updateFromProbeArray($ret['networks'][Protocol::DIASPORA]);
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
Logger::error($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
|
||||||
|
}
|
||||||
|
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
|
||||||
|
try {
|
||||||
|
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
Logger::error($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::updateFromProbeArray($id, $ret);
|
return self::updateFromProbeArray($id, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3193,8 +3209,9 @@ class Contact
|
||||||
self::clearFollowerFollowingEndpointCache($contact['uid']);
|
self::clearFollowerFollowingEndpointCache($contact['uid']);
|
||||||
|
|
||||||
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
|
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
|
||||||
|
if (!empty($cdata['public'])) {
|
||||||
DI::notification()->deleteForUserByVerb($contact['uid'], Activity::FOLLOW, ['actor-id' => $cdata['public']]);
|
DI::notification()->deleteForUserByVerb($contact['uid'], Activity::FOLLOW, ['actor-id' => $cdata['public']]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -70,18 +70,8 @@ class Notify extends BaseModule
|
||||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||||
}
|
}
|
||||||
$this->dispatchPrivate($user, $postdata);
|
$this->dispatchPrivate($user, $postdata);
|
||||||
} elseif (!$this->dispatchPublic($postdata)) {
|
} else {
|
||||||
(new Salmon(
|
$this->dispatchPublic($postdata);
|
||||||
$this->database,
|
|
||||||
$this->l10n,
|
|
||||||
$this->baseUrl,
|
|
||||||
$this->args,
|
|
||||||
$this->logger,
|
|
||||||
$this->profiler,
|
|
||||||
$this->response,
|
|
||||||
$this->server,
|
|
||||||
$this->parameters
|
|
||||||
))->rawContent($request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ use Friendica\Navigation\Notifications\Factory;
|
||||||
use Friendica\Navigation\Notifications\Repository;
|
use Friendica\Navigation\Notifications\Repository;
|
||||||
use Friendica\Navigation\Notifications\ValueObject;
|
use Friendica\Navigation\Notifications\ValueObject;
|
||||||
use Friendica\Navigation\SystemMessages;
|
use Friendica\Navigation\SystemMessages;
|
||||||
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
|
@ -229,7 +230,11 @@ class Ping extends BaseModule
|
||||||
|
|
||||||
// merge all notification types in one array
|
// merge all notification types in one array
|
||||||
foreach ($intros as $intro) {
|
foreach ($intros as $intro) {
|
||||||
$navNotifications[] = $this->formattedNavNotification->createFromIntro($intro);
|
try {
|
||||||
|
$navNotifications[] = $this->formattedNavNotification->createFromIntro($intro);
|
||||||
|
} catch (HTTPException\NotFoundException $e) {
|
||||||
|
$this->introductionRepo->delete($intro);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($registrations) <= 1 || $this->pconfig->get($this->session->getLocalUserId(), 'system', 'detailed_notif')) {
|
if (count($registrations) <= 1 || $this->pconfig->get($this->session->getLocalUserId(), 'system', 'detailed_notif')) {
|
||||||
|
@ -242,7 +247,7 @@ class Ping extends BaseModule
|
||||||
new Uri($this->baseUrl->get(true) . '/moderation/users/pending')
|
new Uri($this->baseUrl->get(true) . '/moderation/users/pending')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif (count($registrations) > 1) {
|
} else {
|
||||||
$navNotifications[] = $this->formattedNavNotification->createFromParams(
|
$navNotifications[] = $this->formattedNavNotification->createFromParams(
|
||||||
$registrations[0]['name'],
|
$registrations[0]['name'],
|
||||||
$registrations[0]['url'],
|
$registrations[0]['url'],
|
||||||
|
|
|
@ -66,11 +66,12 @@ class Salmon extends \Friendica\BaseModule
|
||||||
{
|
{
|
||||||
$xml = Network::postdata();
|
$xml = Network::postdata();
|
||||||
|
|
||||||
$this->logger->debug('New Salmon', ['nickname' => $this->parameters['nickname'], 'xml' => $xml]);
|
|
||||||
|
|
||||||
// Despite having a route with a mandatory nickname parameter, this method can also be called from
|
|
||||||
// \Friendica\Module\DFRN\Notify->post where the same parameter is optional 🤷
|
|
||||||
$nickname = $this->parameters['nickname'] ?? '';
|
$nickname = $this->parameters['nickname'] ?? '';
|
||||||
|
if (empty($nickname)) {
|
||||||
|
throw new HTTPException\BadRequestException('nickname parameter is mandatory');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->logger->debug('New Salmon', ['nickname' => $nickname, 'xml' => $xml]);
|
||||||
|
|
||||||
$importer = $this->database->selectFirst('user', [], ['nickname' => $nickname, 'account_expired' => false, 'account_removed' => false]);
|
$importer = $this->database->selectFirst('user', [], ['nickname' => $nickname, 'account_expired' => false, 'account_removed' => false]);
|
||||||
if (!$this->database->isResult($importer)) {
|
if (!$this->database->isResult($importer)) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ use Friendica\Model\Contact;
|
||||||
use Friendica\Navigation\Notifications\Entity;
|
use Friendica\Navigation\Notifications\Entity;
|
||||||
use Friendica\Navigation\Notifications\Exception\NoMessageException;
|
use Friendica\Navigation\Notifications\Exception\NoMessageException;
|
||||||
use Friendica\Navigation\Notifications\ValueObject;
|
use Friendica\Navigation\Notifications\ValueObject;
|
||||||
use Friendica\Network\HTTPException\ServiceUnavailableException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Proxy;
|
use Friendica\Util\Proxy;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
@ -73,7 +73,7 @@ class FormattedNavNotification extends BaseFactory
|
||||||
* @param Uri $href
|
* @param Uri $href
|
||||||
* @param bool $seen
|
* @param bool $seen
|
||||||
* @return ValueObject\FormattedNavNotification
|
* @return ValueObject\FormattedNavNotification
|
||||||
* @throws ServiceUnavailableException
|
* @throws HTTPException\ServiceUnavailableException
|
||||||
*/
|
*/
|
||||||
public function createFromParams(string $contact_name, string $contact_url, string $message, \DateTime $date, Uri $href, bool $seen = false): ValueObject\FormattedNavNotification
|
public function createFromParams(string $contact_name, string $contact_url, string $message, \DateTime $date, Uri $href, bool $seen = false): ValueObject\FormattedNavNotification
|
||||||
{
|
{
|
||||||
|
@ -115,9 +115,9 @@ class FormattedNavNotification extends BaseFactory
|
||||||
* @param Entity\Notification $notification
|
* @param Entity\Notification $notification
|
||||||
* @return ValueObject\FormattedNavNotification
|
* @return ValueObject\FormattedNavNotification
|
||||||
* @throws NoMessageException
|
* @throws NoMessageException
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \Friendica\Network\HTTPException\NotFoundException
|
* @throws HTTPException\NotFoundException
|
||||||
* @throws \Friendica\Network\HTTPException\ServiceUnavailableException
|
* @throws HTTPException\ServiceUnavailableException
|
||||||
*/
|
*/
|
||||||
public function createFromNotification(Entity\Notification $notification): ValueObject\FormattedNavNotification
|
public function createFromNotification(Entity\Notification $notification): ValueObject\FormattedNavNotification
|
||||||
{
|
{
|
||||||
|
@ -141,10 +141,20 @@ class FormattedNavNotification extends BaseFactory
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Friendica\Contact\Introduction\Entity\Introduction $intro
|
||||||
|
* @return ValueObject\FormattedNavNotification
|
||||||
|
* @throws HTTPException\NotFoundException when the contact record couldn't be located
|
||||||
|
* @throws HTTPException\ServiceUnavailableException
|
||||||
|
*/
|
||||||
public function createFromIntro(\Friendica\Contact\Introduction\Entity\Introduction $intro): ValueObject\FormattedNavNotification
|
public function createFromIntro(\Friendica\Contact\Introduction\Entity\Introduction $intro): ValueObject\FormattedNavNotification
|
||||||
{
|
{
|
||||||
if (!isset(self::$contacts[$intro->cid])) {
|
if (empty(self::$contacts[$intro->cid])) {
|
||||||
self::$contacts[$intro->cid] = Contact::getById($intro->cid, ['name', 'url', 'pending']);
|
if ($contact = Contact::getById($intro->cid, ['name', 'url', 'pending'])) {
|
||||||
|
self::$contacts[$intro->cid] = $contact;
|
||||||
|
} else {
|
||||||
|
throw new HTTPException\NotFoundException('Contact not found with id' . $intro->cid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$contacts[$intro->cid]['pending']) {
|
if (self::$contacts[$intro->cid]['pending']) {
|
||||||
|
|
|
@ -234,6 +234,18 @@ class DiasporaContact extends BaseRepository
|
||||||
*/
|
*/
|
||||||
public function updateFromProbeArray(array $data): Entity\DiasporaContact
|
public function updateFromProbeArray(array $data): Entity\DiasporaContact
|
||||||
{
|
{
|
||||||
|
if (empty($data['url'])) {
|
||||||
|
throw new \InvalidArgumentException('Missing url key in Diaspora probe data array');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($data['guid'])) {
|
||||||
|
throw new \InvalidArgumentException('Missing guid key in Diaspora probe data array');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($data['pubkey'])) {
|
||||||
|
throw new \InvalidArgumentException('Missing pubkey key in Diaspora probe data array');
|
||||||
|
}
|
||||||
|
|
||||||
$uriId = ItemURI::insert(['uri' => $data['url'], 'guid' => $data['guid']]);
|
$uriId = ItemURI::insert(['uri' => $data['url'], 'guid' => $data['guid']]);
|
||||||
|
|
||||||
$contact = Contact::getByUriId($uriId, ['id', 'created']);
|
$contact = Contact::getByUriId($uriId, ['id', 'created']);
|
||||||
|
|
Loading…
Reference in a new issue