Skip to content

Commit

Permalink
fix: do not compare read/typing privacy with constants casted to string
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Nov 5, 2024
1 parent fa7b7af commit 0feb738
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
* 400: Updating user setting is not possible
*/
#[NoAdminRequired]
public function setUserSetting(string $key, $value): DataResponse {
public function setUserSetting(string $key, string|int|null $value): DataResponse {
if (!$this->preferenceListener->validatePreference($this->userId, $key, $value)) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Settings/BeforePreferenceSetEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function handle(Event $event): void {
/**
* @internal Make private/protected once SettingsController route was removed
*/
public function validatePreference(string $userId, string $key, string $value): bool {
public function validatePreference(string $userId, string $key, string|int|null $value): bool {
if ($key === 'attachment_folder') {
return $this->validateAttachmentFolder($userId, $value);
}
Expand All @@ -67,7 +67,7 @@ public function validatePreference(string $userId, string $key, string $value):
// "privacy" 0/1
if ($key === UserPreference::TYPING_PRIVACY
|| $key === UserPreference::READ_STATUS_PRIVACY) {
$valid = $value === (string)Participant::PRIVACY_PRIVATE || $value === (string)Participant::PRIVACY_PUBLIC;
$valid = (int)$value === Participant::PRIVACY_PRIVATE || (int)$value === Participant::PRIVACY_PUBLIC;

if ($valid && $key === 'read_status_privacy') {
$this->participantService->updateReadPrivacyForActor(Attendee::ACTOR_USERS, $userId, (int)$value);
Expand Down

0 comments on commit 0feb738

Please sign in to comment.