mirror of
https://github.com/friendica/friendica
synced 2024-11-20 08:23:41 +00:00
Merge pull request #9663 from MrPetovan/bug/9662-deleted-users-still-post
Add item user owner data check in Model\Item::isValid
This commit is contained in:
commit
4bdeba9d5a
2 changed files with 18 additions and 5 deletions
|
@ -1385,6 +1385,19 @@ class Item
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!empty($item['uid'])) {
|
||||
$owner = User::getOwnerDataById($item['uid'], false);
|
||||
if (!$owner) {
|
||||
Logger::notice('Missing item user owner data', ['uid' => $item['uid']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($owner['account_expired'] || $owner['account_removed']) {
|
||||
Logger::notice('Item user has been deleted/expired/removed', ['uid' => $item['uid'], 'deleted' => $owner['deleted'], 'account_expired' => $owner['account_expired'], 'account_removed' => $owner['account_removed']]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item['author-id']) && Contact::isBlocked($item['author-id'])) {
|
||||
Logger::notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
||||
return false;
|
||||
|
|
|
@ -370,12 +370,12 @@ class User
|
|||
/**
|
||||
* Get owner data by user id
|
||||
*
|
||||
* @param int $uid
|
||||
* @param boolean $check_valid Test if data is invalid and correct it
|
||||
* @param int $uid
|
||||
* @param boolean $repairMissing Repair the owner data if it's missing
|
||||
* @return boolean|array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getOwnerDataById(int $uid, bool $check_valid = true)
|
||||
public static function getOwnerDataById(int $uid, bool $repairMissing = true)
|
||||
{
|
||||
if ($uid == 0) {
|
||||
return self::getSystemAccount();
|
||||
|
@ -387,7 +387,7 @@ class User
|
|||
|
||||
$owner = DBA::selectFirst('owner-view', [], ['uid' => $uid]);
|
||||
if (!DBA::isResult($owner)) {
|
||||
if (!DBA::exists('user', ['uid' => $uid]) || !$check_valid) {
|
||||
if (!DBA::exists('user', ['uid' => $uid]) || !$repairMissing) {
|
||||
return false;
|
||||
}
|
||||
Contact::createSelfFromUserId($uid);
|
||||
|
@ -398,7 +398,7 @@ class User
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!$check_valid) {
|
||||
if (!$repairMissing) {
|
||||
return $owner;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue