]> git.mxchange.org Git - friendica.git/commitdiff
Blocked users need to be blocked
authorMichael <heluecht@pirati.ca>
Wed, 29 May 2024 13:34:56 +0000 (13:34 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 29 May 2024 13:34:56 +0000 (13:34 +0000)
database.sql
src/Model/Contact.php
src/Model/User.php
static/dbstructure.config.php
update.php

index e9003baa39b8ae80086acc9da6c9ad9659f92014..a504b9f74e1939f82a656728d89b55ebbdb43c9c 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 2024.06-dev (Yellow Archangel)
--- DB_UPDATE_VERSION 1563
+-- DB_UPDATE_VERSION 1564
 -- ------------------------------------------
 
 
index 3ea78a38951f164a56afd43c0d963f4490ea62d8..5cd77048c9624dec92963cca43b595bd43e6c1c5 100644 (file)
@@ -626,11 +626,8 @@ class Contact
         */
        public static function getPublicIdByUserId(int $uid)
        {
-               $self = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
-               if (!DBA::isResult($self)) {
-                       return false;
-               }
-               return self::getIdForURL($self['url']);
+               $self = self::selectFirstAccountUser(['pid'], ['self' => true, 'uid' => $uid]);
+               return $self['pid'] ?? false;
        }
 
        /**
index 3728458258d36e37157e45c3b1be32ca0a4d43ee..0701df4a26d13ef68ffd089b4144ec2da3c40527 100644 (file)
@@ -1492,6 +1492,12 @@ class User
         */
        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]);
        }
 
index 71a555eafa7e03702df7b6533b890aa4382211ca..f88e60eae971cac6646a840113b8764be826a298 100644 (file)
@@ -56,7 +56,7 @@ use Friendica\Database\DBA;
 
 // This file is required several times during the test in DbaDefinition which justifies this condition
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1563);
+       define('DB_UPDATE_VERSION', 1564);
 }
 
 return [
index 03a95fb145ca3f4afd1f485cd535e55addc9f869..228e454e6ded34f3d15dc2c538424c0fe4216139 100644 (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)) {
                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;
 }
\ No newline at end of file