Blocked users need to be blocked

This commit is contained in:
Michael 2024-05-29 13:34:56 +00:00
parent eb2a8e47b0
commit b61cfd193f
5 changed files with 21 additions and 7 deletions

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2024.06-dev (Yellow Archangel) -- Friendica 2024.06-dev (Yellow Archangel)
-- DB_UPDATE_VERSION 1563 -- DB_UPDATE_VERSION 1564
-- ------------------------------------------ -- ------------------------------------------

View file

@ -626,11 +626,8 @@ class Contact
*/ */
public static function getPublicIdByUserId(int $uid) public static function getPublicIdByUserId(int $uid)
{ {
$self = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]); $self = self::selectFirstAccountUser(['pid'], ['self' => true, 'uid' => $uid]);
if (!DBA::isResult($self)) { return $self['pid'] ?? false;
return false;
}
return self::getIdForURL($self['url']);
} }
/** /**

View file

@ -1492,6 +1492,12 @@ class User
*/ */
public static function block(int $uid, bool $block = true): bool public static function block(int $uid, bool $block = true): bool
{ {
$self = Contact::getPublicIdByUserId($uid);
if ($block) {
Contact::block($self['id']);
} else {
Contact::unblock($self['id']);
}
return DBA::update('user', ['blocked' => $block], ['uid' => $uid]); return DBA::update('user', ['blocked' => $block], ['uid' => $uid]);
} }

View file

@ -56,7 +56,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition // This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1563); define('DB_UPDATE_VERSION', 1564);
} }
return [ return [

View file

@ -1466,4 +1466,15 @@ function update_1560()
SELECT `id`, `uri-id`, `uid`, `parent-uri-id`, `thr-parent-id`, `created`, `received`, `gravity`, `vid`, `private`, `wall` FROM `post-user` WHERE `post-user`.`origin` AND `post-user`.`uid` != ?", 0)) { SELECT `id`, `uri-id`, `uid`, `parent-uri-id`, `thr-parent-id`, `created`, `received`, `gravity`, `vid`, `private`, `wall` FROM `post-user` WHERE `post-user`.`origin` AND `post-user`.`uid` != ?", 0)) {
return Update::FAILED; return Update::FAILED;
} }
}
function update_1564()
{
$users = DBA::select('user', ['uid'], ['blocked' => true]);
while ($user = DBA::fetch($users)) {
User::block($user['uid']);
}
DBA::close($users);
return Update::SUCCESS;
} }