-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(calls): Add appconfig and user preference for default setting of…
… media Signed-off-by: Joas Schilling <[email protected]>
- Loading branch information
1 parent
b681d0e
commit bd1c758
Showing
10 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Talk\Settings; | ||
|
||
use OCA\Talk\AppInfo\Application; | ||
use OCA\Talk\Participant; | ||
use OCP\Config\BeforePreferenceSetEvent; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
|
||
/** | ||
* @template-implements IEventListener<Event> | ||
*/ | ||
class BeforePreferenceSetEventListener implements IEventListener { | ||
public function handle(Event $event): void { | ||
if (!($event instanceof BeforePreferenceSetEvent)) { | ||
// Unrelated | ||
return; | ||
} | ||
|
||
if ($event->getAppId() !== Application::APP_ID) { | ||
return; | ||
} | ||
|
||
$event->setValid($this->validatePreference( | ||
$event->getConfigKey(), | ||
$event->getConfigValue(), | ||
)); | ||
} | ||
|
||
protected function validatePreference(string $key, string $value): bool { | ||
// "boolean" yes/no | ||
if ($key === UserPreference::CALLS_START_WITHOUT_MEDIA | ||
|| $key === UserPreference::PLAY_SOUNDS) { | ||
return $value === 'yes' || $value === 'no'; | ||
} | ||
|
||
// "privacy" 0/1 | ||
if ($key === UserPreference::TYPING_PRIVACY | ||
|| $key === UserPreference::READ_STATUS_PRIVACY) { | ||
return $value === (string)Participant::PRIVACY_PRIVATE || $value === (string)Participant::PRIVACY_PUBLIC; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Talk\Settings; | ||
|
||
class UserPreference { | ||
public const CALLS_START_WITHOUT_MEDIA = 'calls_start_without_media'; | ||
public const PLAY_SOUNDS = 'play_sounds'; | ||
public const TYPING_PRIVACY = 'typing_privacy'; | ||
public const READ_STATUS_PRIVACY = 'read_status_privacy'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters