Skip to content

Commit

Permalink
Add isAdmin and isGlobalModerator fields to user api response (#1044
Browse files Browse the repository at this point in the history
)
  • Loading branch information
BentiGorlich authored Aug 20, 2024
1 parent a103bd7 commit 4973e4a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/DTO/UserDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class UserDto implements UserDtoInterface
public ?int $id = null;
public ?int $followersCount = 0;
public ?bool $isBot = null;
public ?bool $isAdmin = null;
public ?bool $isGlobalModerator = null;
public ?bool $isFollowedByUser = null;
public ?bool $isFollowerOfUser = null;
public ?bool $isBlockedByUser = null;
Expand Down Expand Up @@ -87,6 +89,8 @@ public static function create(
?int $id = null,
?int $followersCount = 0,
?bool $isBot = null,
?bool $isAdmin = null,
?bool $isGlobalModerator = null,
): self {
$dto = new UserDto();
$dto->id = $id;
Expand All @@ -101,6 +105,8 @@ public static function create(
$dto->apProfileId = $apProfileId;
$dto->followersCount = $followersCount;
$dto->isBot = $isBot;
$dto->isAdmin = $isAdmin;
$dto->isGlobalModerator = $isGlobalModerator;

return $dto;
}
Expand Down
6 changes: 6 additions & 0 deletions src/DTO/UserResponseDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class UserResponseDto implements \JsonSerializable
public ?bool $isFollowedByUser = null;
public ?bool $isFollowerOfUser = null;
public ?bool $isBlockedByUser = null;
public ?bool $isAdmin = null;
public ?bool $isGlobalModerator = null;
public ?int $userId = null;
public ?string $serverSoftware = null;
public ?string $serverSoftwareVersion = null;
Expand All @@ -42,6 +44,8 @@ public function __construct(UserDto $dto)
$this->isBlockedByUser = $dto->isBlockedByUser;
$this->serverSoftware = $dto->serverSoftware;
$this->serverSoftwareVersion = $dto->serverSoftwareVersion;
$this->isAdmin = $dto->isAdmin;
$this->isGlobalModerator = $dto->isGlobalModerator;
}

public function jsonSerialize(): mixed
Expand All @@ -57,6 +61,8 @@ public function jsonSerialize(): mixed
'apId' => $this->apId,
'apProfileId' => $this->apProfileId,
'isBot' => $this->isBot,
'isAdmin' => $this->isAdmin,
'isGlobalModerator' => $this->isGlobalModerator,
'isFollowedByUser' => $this->isFollowedByUser,
'isFollowerOfUser' => $this->isFollowerOfUser,
'isBlockedByUser' => $this->isBlockedByUser,
Expand Down
6 changes: 6 additions & 0 deletions src/DTO/UserSmallResponseDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class UserSmallResponseDto implements \JsonSerializable
public ?bool $isFollowedByUser = null;
public ?bool $isFollowerOfUser = null;
public ?bool $isBlockedByUser = null;
public ?bool $isAdmin = null;
public ?bool $isGlobalModerator = null;
public ?ImageDto $avatar = null;
public ?string $apId = null;
public ?string $apProfileId = null;
Expand All @@ -32,6 +34,8 @@ public function __construct(UserDto $dto)
$this->apId = $dto->apId;
$this->apProfileId = $dto->apProfileId;
$this->createdAt = $dto->createdAt;
$this->isAdmin = $dto->isAdmin;
$this->isGlobalModerator = $dto->isGlobalModerator;
}

public function jsonSerialize(): mixed
Expand All @@ -43,6 +47,8 @@ public function jsonSerialize(): mixed
'isFollowedByUser' => $this->isFollowedByUser,
'isFollowerOfUser' => $this->isFollowerOfUser,
'isBlockedByUser' => $this->isBlockedByUser,
'isAdmin' => $this->isAdmin,
'isGlobalModerator' => $this->isGlobalModerator,
'avatar' => $this->avatar,
'apId' => $this->apId,
'apProfileId' => $this->apProfileId,
Expand Down
4 changes: 3 additions & 1 deletion src/Factory/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function createDto(User $user): UserDto
$user->apProfileId,
$user->getId(),
$user->followersCount,
'Service' === $user->type // setting isBot
'Service' === $user->type, // setting isBot
$user->isAdmin(),
$user->isModerator(),
);

/** @var User $currentUser */
Expand Down

0 comments on commit 4973e4a

Please sign in to comment.