Implement pull request feedback

- Improve formatting of drop_item in mod/item
- Replace deprecated Logger::log() calls in Protocol\Feed::consume
This commit is contained in:
Hypolite Petovan 2020-06-17 21:44:28 -04:00
parent 4e7c45f835
commit f544c8383b
2 changed files with 8 additions and 10 deletions

View File

@ -928,9 +928,9 @@ function drop_item(int $id, string $return = '')
DI::baseUrl()->redirect('display/' . $item['guid']); DI::baseUrl()->redirect('display/' . $item['guid']);
} }
$is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false; $is_comment = $item['gravity'] == GRAVITY_COMMENT;
$parentitem = null; $parentitem = null;
if (!empty($item['parent'])){ if (!empty($item['parent'])) {
$fields = ['guid']; $fields = ['guid'];
$parentitem = Item::selectFirstForUser(local_user(), $fields, ['id' => $item['parent']]); $parentitem = Item::selectFirstForUser(local_user(), $fields, ['id' => $item['parent']]);
} }
@ -949,14 +949,12 @@ function drop_item(int $id, string $return = '')
if (!empty($parentitem)) { if (!empty($parentitem)) {
DI::baseUrl()->redirect('display/' . $parentitem['guid']); DI::baseUrl()->redirect('display/' . $parentitem['guid']);
//NOTREACHED //NOTREACHED
} } // In case something goes wrong
// In case something goes wrong
else { else {
DI::baseUrl()->redirect('network'); DI::baseUrl()->redirect('network');
//NOTREACHED //NOTREACHED
} }
} } else {
else {
// if unknown location or deleting top level post called from display // if unknown location or deleting top level post called from display
if (empty($return_url) || strpos($return_url, 'display') !== false) { if (empty($return_url) || strpos($return_url, 'display') !== false) {
DI::baseUrl()->redirect('network'); DI::baseUrl()->redirect('network');

View File

@ -74,24 +74,24 @@ class Feed
public static function consume($xml, array $importer, array $contact, &$hub) public static function consume($xml, array $importer, array $contact, &$hub)
{ {
if ($contact['network'] === Protocol::OSTATUS) { if ($contact['network'] === Protocol::OSTATUS) {
Logger::log('Consume OStatus messages ', Logger::DEBUG); Logger::info('Consume OStatus messages');
OStatus::import($xml, $importer, $contact, $hub); OStatus::import($xml, $importer, $contact, $hub);
return; return;
} }
if ($contact['network'] === Protocol::FEED) { if ($contact['network'] === Protocol::FEED) {
Logger::log('Consume feeds', Logger::DEBUG); Logger::info('Consume feeds');
self::import($xml, $importer, $contact); self::import($xml, $importer, $contact);
return; return;
} }
if ($contact['network'] === Protocol::DFRN) { if ($contact['network'] === Protocol::DFRN) {
Logger::log('Consume DFRN messages', Logger::DEBUG); Logger::info('Consume DFRN messages');
$dfrn_importer = DFRN::getImporter($contact['id'], $importer['uid']); $dfrn_importer = DFRN::getImporter($contact['id'], $importer['uid']);
if (!empty($dfrn_importer)) { if (!empty($dfrn_importer)) {
Logger::log('Now import the DFRN feed'); Logger::info('Now import the DFRN feed');
DFRN::import($xml, $dfrn_importer, true); DFRN::import($xml, $dfrn_importer, true);
return; return;
} }