]> git.mxchange.org Git - friendica.git/commitdiff
Don't show permissions from permissiongroups on comments
authorMichael <heluecht@pirati.ca>
Wed, 22 Mar 2023 21:43:03 +0000 (21:43 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 22 Mar 2023 21:43:03 +0000 (21:43 +0000)
src/Module/PermissionTooltip.php

index 4265ff40109cea2a380b088202a1a6d6a1d0a381..1f41584d65321e4015641a3f06a43439ac6e5f9a 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\Core\Hook;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -32,7 +33,6 @@ use Friendica\Model\Post;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
 use Friendica\Network\HTTPException;
-use Friendica\Protocol\ActivityPub;
 
 /**
  * Outputs the permission tooltip HTML content for the provided item, photo or event id.
@@ -51,8 +51,21 @@ class PermissionTooltip extends \Friendica\BaseModule
 
                $condition = ['id' => $referenceId, 'uid' => [0, DI::userSession()->getLocalUserId()]];
                if ($type == 'item') {
-                       $fields = ['uid', 'psid', 'private', 'uri-id'];
-                       $model = Post::selectFirst($fields, $condition);
+                       $fields = ['uid', 'psid', 'private', 'uri-id', 'origin', 'network'];
+                       $model = Post::selectFirst($fields, $condition, ['order' => ['uid' => true]]);
+
+                       if ($model['origin'] || ($model['network'] != Protocol::ACTIVITYPUB)) {
+                               $permissionSet = DI::permissionSet()->selectOneById($model['psid'], $model['uid']);
+                               $model['allow_cid'] = $permissionSet->allow_cid;
+                               $model['allow_gid'] = $permissionSet->allow_gid;
+                               $model['deny_cid']  = $permissionSet->deny_cid;
+                               $model['deny_gid']  = $permissionSet->deny_gid;
+                       } else {
+                               $model['allow_cid'] = [];
+                               $model['allow_gid'] = [];
+                               $model['deny_cid']  = [];
+                               $model['deny_gid']  = [];
+                       }
                } else {
                        $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
                        $model = DBA::selectFirst($type, $fields, $condition);
@@ -66,14 +79,6 @@ class PermissionTooltip extends \Friendica\BaseModule
                        throw new HttpException\NotFoundException(DI::l10n()->t('Model not found'));
                }
 
-               if (isset($model['psid'])) {
-                       $permissionSet = DI::permissionSet()->selectOneById($model['psid'], $model['uid']);
-                       $model['allow_cid'] = $permissionSet->allow_cid;
-                       $model['allow_gid'] = $permissionSet->allow_gid;
-                       $model['deny_cid']  = $permissionSet->deny_cid;
-                       $model['deny_gid']  = $permissionSet->deny_gid;
-               }
-
                // Kept for backwards compatiblity
                Hook::callAll('lockview_content', $model);
 
@@ -161,11 +166,10 @@ class PermissionTooltip extends \Friendica\BaseModule
                }
 
                if (!empty($l)) {
-                       echo $o . implode(', ', $l);
+                       System::httpExit($o . implode(', ', $l));
                } else {
-                       echo $o . $receivers;
+                       System::httpExit($o . $receivers);;
                }
-               System::exit();
        }
 
        /**