Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions lib/Chat/Changelog/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@

namespace OCA\Talk\Chat\Changelog;

use OCA\Talk\AppInfo\Application;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Config;
use OCA\Talk\Manager as RoomManager;
use OCP\IConfig;
use OCP\Config\IUserConfig;
use OCP\IL10N;
use OCP\PreConditionNotMetException;

class Manager {

public function __construct(
private readonly IConfig $config,
private readonly IUserConfig $userConfig,
private readonly RoomManager $roomManager,
private readonly ChatManager $chatManager,
private readonly IL10N $l,
) {
}

public function getChangelogForUser(string $userId): int {
return (int)$this->config->getUserValue($userId, 'spreed', 'changelog', '0');
return $this->userConfig->getValueInt($userId, Application::APP_ID, Config::CHANGELOG);
}

public function updateChangelog(string $userId): void {
Expand All @@ -37,12 +38,7 @@ public function updateChangelog(string $userId): void {
return;
}

try {
$this->config->setUserValue($userId, 'spreed', 'changelog', (string)$shouldHaveReceived, (string)$hasReceivedLog);
} catch (PreConditionNotMetException) {
// Parallel request won the race
return;
}
$this->userConfig->setValueInt($userId, Application::APP_ID, Config::CHANGELOG, $shouldHaveReceived);

$room = $this->roomManager->getChangelogRoom($userId);

Expand Down
74 changes: 36 additions & 38 deletions lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ public function getAllowedTalkGroupIds(): array {
* @return Participant::PRIVACY_*
*/
public function getUserReadPrivacy(string $userId): int {
return match ((int)$this->config->getUserValue(
return match ($this->userConfig->getValueInt(
$userId,
'spreed', UserPreference::READ_STATUS_PRIVACY,
(string)Participant::PRIVACY_PUBLIC)) {
Application::APP_ID,
UserPreference::READ_STATUS_PRIVACY,
Participant::PRIVACY_PUBLIC)) {
Participant::PRIVACY_PUBLIC => Participant::PRIVACY_PUBLIC,
default => Participant::PRIVACY_PRIVATE,
};
Expand All @@ -185,10 +186,11 @@ public function getUserReadPrivacy(string $userId): int {
* @return Participant::PRIVACY_*
*/
public function getUserTypingPrivacy(string $userId): int {
return match ((int)$this->config->getUserValue(
return match ($this->userConfig->getValueInt(
$userId,
'spreed', UserPreference::TYPING_PRIVACY,
(string)Participant::PRIVACY_PUBLIC)) {
Application::APP_ID,
UserPreference::TYPING_PRIVACY,
Participant::PRIVACY_PUBLIC)) {
Participant::PRIVACY_PUBLIC => Participant::PRIVACY_PUBLIC,
default => Participant::PRIVACY_PRIVATE,
};
Expand Down Expand Up @@ -312,18 +314,18 @@ public function getRecordingConsentConfig(): int {
}

public function getRecordingFolder(string $userId): string {
return $this->config->getUserValue(
return $this->userConfig->getValueString(
$userId,
'spreed',
Application::APP_ID,
UserPreference::RECORDING_FOLDER,
$this->getAttachmentFolder($userId) . '/Recording'
);
}

public function getLiveTranscriptionTargetLanguageId(?string $userId = null): string {
return $this->config->getUserValue(
return $this->userConfig->getvalueString(
$userId,
'spreed',
Application::APP_ID,
UserPreference::LIVE_TRANSCRIPTION_TARGET_LANGUAGE_ID,
''
);
Expand Down Expand Up @@ -395,7 +397,7 @@ public function getDefaultPermissions(): int {

public function getAttachmentFolder(string $userId): string {
$defaultAttachmentFolder = $this->appConfig->getAppValueString(self::DEFAULT_ATTACHMENT_FOLDER);
return $this->config->getUserValue($userId, 'spreed', UserPreference::ATTACHMENT_FOLDER, $defaultAttachmentFolder);
return $this->userConfig->getValueString($userId, Application::APP_ID, UserPreference::ATTACHMENT_FOLDER, $defaultAttachmentFolder);
}

/**
Expand Down Expand Up @@ -730,7 +732,7 @@ private function getSignalingTicketV1(?string $userId): string {
if (empty($userId)) {
$secret = $this->appConfig->getAppValueString(self::SIGNALING_TICKET_SECRET);
} else {
$secret = $this->config->getUserValue($userId, 'spreed', 'signaling_ticket_secret');
$secret = $this->userConfig->getValueString($userId, Application::APP_ID, self::SIGNALING_TICKET_SECRET);
}
if (empty($secret)) {
// Create secret lazily on first access.
Expand All @@ -739,7 +741,7 @@ private function getSignalingTicketV1(?string $userId): string {
if (empty($userId)) {
$this->appConfig->setAppValueString(self::SIGNALING_TICKET_SECRET, $secret);
} else {
$this->config->setUserValue($userId, 'spreed', 'signaling_ticket_secret', $secret);
$this->userConfig->setValueString($userId, Application::APP_ID, self::SIGNALING_TICKET_SECRET, $secret);
}
}

Expand Down Expand Up @@ -914,7 +916,7 @@ public function validateSignalingTicket(?string $userId, #[SensitiveParameter] s
if (empty($userId)) {
$secret = $this->appConfig->getAppValueString(self::SIGNALING_TICKET_SECRET);
} else {
$secret = $this->config->getUserValue($userId, 'spreed', 'signaling_ticket_secret');
$secret = $this->userConfig->getValueString($userId, Application::APP_ID, self::SIGNALING_TICKET_SECRET);
}
if (empty($secret)) {
return false;
Expand Down Expand Up @@ -948,10 +950,7 @@ public function getGridVideosLimitEnforced(): bool {
*/
public function getCallsStartWithoutMedia(?string $userId): bool {
if ($userId !== null) {
$userSetting = $this->config->getUserValue($userId, 'spreed', UserPreference::CALLS_START_WITHOUT_MEDIA);
if ($userSetting === 'yes' || $userSetting === 'no') {
return $userSetting === 'yes';
}
return $this->userConfig->getValueBool($userId, Application::APP_ID, UserPreference::CALLS_START_WITHOUT_MEDIA);
}

return $this->appConfig->getAppValueBool(self::CALLS_START_WITHOUT_MEDIA);
Expand All @@ -965,8 +964,7 @@ public function getCallsStartWithoutMedia(?string $userId): bool {
*/
public function getBlurVirtualBackground(?string $userId): bool {
if ($userId !== null) {
$userSetting = $this->config->getUserValue($userId, 'spreed', UserPreference::BLUR_VIRTUAL_BACKGROUND);
return $userSetting === 'yes';
return $this->userConfig->getValueBool($userId, Application::APP_ID, UserPreference::BLUR_VIRTUAL_BACKGROUND);
}
return false;
}
Expand All @@ -979,10 +977,10 @@ public function getBlurVirtualBackground(?string $userId): bool {
*/
public function getConversationsListStyle(?string $userId): string {
if ($userId !== null) {
$userSetting = $this->config->getUserValue(
$userSetting = $this->userConfig->getValueString(
$userId,
'spreed',
UserPreference::CONVERSATIONS_LIST_STYLE,
Application::APP_ID,
UserPreference::CONVERSATIONS_LIST_STYLE
);

if (in_array($userSetting, [UserPreference::CONVERSATION_LIST_STYLE_TWO_LINES, UserPreference::CONVERSATION_LIST_STYLE_COMPACT], true)) {
Expand All @@ -1006,10 +1004,10 @@ public function getConversationsListStyle(?string $userId): string {
*/
public function getChatStyle(?string $userId): string {
if ($userId !== null) {
$userSetting = $this->config->getUserValue(
$userSetting = $this->userConfig->getValueString(
$userId,
'spreed',
UserPreference::CHAT_STYLE,
Application::APP_ID,
UserPreference::CHAT_STYLE
);

if (in_array($userSetting, [UserPreference::CHAT_STYLE_SPLIT, UserPreference::CHAT_STYLE_UNIFIED], true)) {
Expand All @@ -1033,10 +1031,10 @@ public function getChatStyle(?string $userId): string {
*/
public function getConversationsSortOrder(?string $userId): string {
if ($userId !== null) {
$userSetting = $this->config->getUserValue(
$userSetting = $this->userConfig->getValueString(
$userId,
'spreed',
UserPreference::CONVERSATIONS_SORT_ORDER,
Application::APP_ID,
UserPreference::CONVERSATIONS_SORT_ORDER
);

if (in_array($userSetting, [UserPreference::CONVERSATIONS_SORT_ORDER_ACTIVITY, UserPreference::CONVERSATIONS_SORT_ORDER_ALPHABETICAL], true)) {
Expand All @@ -1055,10 +1053,10 @@ public function getConversationsSortOrder(?string $userId): string {
*/
public function getConversationsGroupMode(?string $userId): string {
if ($userId !== null) {
$userSetting = $this->config->getUserValue(
$userSetting = $this->userConfig->getValueString(
$userId,
'spreed',
UserPreference::CONVERSATIONS_GROUP_MODE,
Application::APP_ID,
UserPreference::CONVERSATIONS_GROUP_MODE
);

if (in_array($userSetting, [
Expand All @@ -1081,10 +1079,10 @@ public function getConversationsGroupMode(?string $userId): string {
*/
public function getConversationsUnarchive(?string $userId): string {
if ($userId !== null) {
$userSetting = $this->config->getUserValue(
$userSetting = $this->userConfig->getValueString(
$userId,
'spreed',
UserPreference::CONVERSATIONS_UNARCHIVE,
Application::APP_ID,
UserPreference::CONVERSATIONS_UNARCHIVE
);

if (in_array($userSetting, [
Expand All @@ -1107,10 +1105,10 @@ public function getConversationsUnarchive(?string $userId): string {
*/
public function getConversationsTagsShowUnread(?string $userId): string {
if ($userId !== null) {
$userSetting = $this->config->getUserValue(
$userSetting = $this->userConfig->getValueString(
$userId,
'spreed',
UserPreference::CONVERSATIONS_TAGS_SHOW_UNREAD,
Application::APP_ID,
UserPreference::CONVERSATIONS_TAGS_SHOW_UNREAD
);

if (in_array($userSetting, [
Expand Down
9 changes: 4 additions & 5 deletions lib/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

namespace OCA\Talk\Controller;

use OCA\Talk\AppInfo\Application;
use OCA\Talk\AuditLog\Operation;
use OCA\Talk\Authenticator;
use OCA\Talk\Config;
use OCA\Talk\Exceptions\DialOutFailedException;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Manager;
use OCA\Talk\Middleware\Attribute\FederationSupported;
use OCA\Talk\Middleware\Attribute\RequireCallEnabled;
use OCA\Talk\Middleware\Attribute\RequireFederatedParticipant;
Expand Down Expand Up @@ -45,8 +45,8 @@
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Config\IUserConfig;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\Log\Audit\CriticalActionPerformedEvent;
Expand All @@ -59,15 +59,14 @@ class CallController extends AEnvironmentAwareOCSController {
public function __construct(
string $appName,
IRequest $request,
private readonly Manager $manager,
private readonly ConsentService $consentService,
private readonly ParticipantService $participantService,
private readonly PhoneNumberMapper $phoneNumberMapper,
private readonly RoomService $roomService,
private readonly IUserManager $userManager,
private readonly ITimeFactory $timeFactory,
private readonly IConfig $serverConfig,
private readonly IAppConfig $appConfig,
private readonly IUserConfig $userConfig,
private readonly Config $talkConfig,
private readonly Authenticator $federationAuthenticator,
private readonly SIPDialOutService $dialOutService,
Expand Down Expand Up @@ -205,7 +204,7 @@ public function downloadParticipantsForCall(string $format = 'csv'): DataDownloa

$timezone = 'UTC';
if ($this->participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
$timezone = $this->serverConfig->getUserValue($this->participant->getAttendee()->getActorId(), 'core', 'timezone', 'UTC');
$timezone = $this->userConfig->getValueString($this->participant->getAttendee()->getActorId(), Application::APP_ID, 'timezone', 'UTC');
}

try {
Expand Down
11 changes: 10 additions & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace OCA\Talk\Controller;

use OCA\Talk\AppInfo\Application;
use OCA\Talk\AuditLog\Operation;
use OCA\Talk\Config;
use OCA\Talk\Settings\BeforePreferenceSetEventListener;
Expand All @@ -18,6 +19,7 @@
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Services\IAppConfig;
use OCP\Config\IUserConfig;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroup;
Expand All @@ -33,6 +35,7 @@ public function __construct(
IRequest $request,
private readonly IConfig $config,
private readonly IAppConfig $appConfig,
private readonly IUserConfig $userConfig,
private readonly IGroupManager $groupManager,
private readonly BeforePreferenceSetEventListener $preferenceListener,
private readonly ?string $userId,
Expand Down Expand Up @@ -60,7 +63,13 @@ public function setUserSetting(string $key, string|int|null $value): DataRespons
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
}

$this->config->setUserValue($this->userId, 'spreed', $key, $value);
if (is_string($value)) {
$this->userConfig->setValueString($this->userId, Application::APP_ID, $key, $value);
}

if (is_int($value)) {
$this->userConfig->setValueInt($this->userId, Application::APP_ID, $key, $value);
}

return new DataResponse(null);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/Federation/Proxy/TalkV1/ProxyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use OCA\Talk\Participant;
use OCA\Talk\Settings\UserPreference;
use OCP\AppFramework\Http;
use OCP\Config\IUserConfig;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\IConfig;
Expand All @@ -30,6 +31,7 @@
class ProxyRequest {
public function __construct(
private readonly IConfig $config,
private readonly IUserConfig $userConfig,
private readonly IClientService $clientService,
private readonly LoggerInterface $logger,
private readonly IFactory $l10nFactory,
Expand All @@ -39,11 +41,11 @@ public function __construct(
}

public function overwrittenRemoteTalkHash(string $hash): string {
$typingIndicator = $this->config->getUserValue(
$typingIndicator = $this->userConfig->getValueInt(
$this->userSession->getUser()?->getUID(),
Application::APP_ID,
UserPreference::TYPING_PRIVACY,
Participant::PRIVACY_PRIVATE,
Participant::PRIVACY_PRIVATE
);
return sha1(json_encode([
'remoteHash' => $hash,
Expand Down
5 changes: 4 additions & 1 deletion lib/Notification/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Config\IUserConfig;
use OCP\Config\ValueType;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
Expand All @@ -43,6 +45,7 @@ class Listener implements IEventListener {

public function __construct(
private readonly IConfig $serverConfig,
private readonly IUserConfig $userConfig,
private readonly IDBConnection $connection,
private readonly IManager $notificationManager,
private readonly Notifier $notificationProvider,
Expand Down Expand Up @@ -304,7 +307,7 @@ protected function sendCallNotifications(Room $room, array $silentFor = []): voi
} else {
$fallbackLang = $this->serverConfig->getSystemValueString('default_language', 'en');
/** @psalm-var array<string, string> $userLanguages */
$userLanguages = $this->serverConfig->getUserValueForUsers('core', 'lang', array_map(strval(...), array_keys($users)));
$userLanguages = $this->userConfig->getValuesByUsers('core', 'lang', ValueType::STRING, array_map(strval(...), array_keys($users)));
}
}

Expand Down
Loading
Loading