Notifications: Fix issues with user fetching
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
d9c3aa44b9
commit
7c6e48d15b
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IGroupManager;
|
||||
@@ -56,7 +57,8 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
* @param $id
|
||||
* @param bool $withLabels
|
||||
* @param bool $withAcl
|
||||
* @return \OCP\AppFramework\Db\Entity if not found
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function find($id, $withLabels = false, $withAcl = false) {
|
||||
$sql = 'SELECT id, title, owner, color, archived, deleted_at FROM `*PREFIX*deck_boards` ' .
|
||||
|
||||
@@ -51,7 +51,7 @@ class PermissionService {
|
||||
/** @var string */
|
||||
private $userId;
|
||||
/** @var array */
|
||||
private $users;
|
||||
private $users = [];
|
||||
|
||||
public function __construct(
|
||||
ILogger $logger,
|
||||
@@ -196,24 +196,24 @@ class PermissionService {
|
||||
} catch (DoesNotExistException $e) {
|
||||
return [];
|
||||
}
|
||||
$users = [
|
||||
new User($this->userManager->get($board->getOwner()))
|
||||
];
|
||||
$owner = $this->userManager->get($board->getOwner());
|
||||
$users = [];
|
||||
$users[$owner->getUID()] = new User($owner);
|
||||
$acls = $this->aclMapper->findAll($boardId);
|
||||
/** @var Acl $acl */
|
||||
foreach ($acls as $acl) {
|
||||
if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
|
||||
$user = $this->userManager->get($acl->getParticipant());
|
||||
$users[] = new User($user);
|
||||
$users[$user->getUID()] = new User($user);
|
||||
}
|
||||
if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
|
||||
$group = $this->groupManager->get($acl->getParticipant());
|
||||
foreach ($group->getUsers() as $user) {
|
||||
$users[] = new User($user);
|
||||
$users[$user->getUID()] = new User($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->users[(string)$boardId] = array_unique($users);
|
||||
return $this->users;
|
||||
$this->users[(string)$boardId] = $users;
|
||||
return $this->users[(string)$boardId];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user