UPSTREAM BASELINE: nextcloud/spreed v22.0.12 (без изменений)
Type checking / changes (push) Has been cancelled
Type checking / test (push) Has been cancelled
Type checking / typescript-summary (push) Has been cancelled
Node tests / changes (push) Has been cancelled
Node tests / test (push) Has been cancelled
Node tests / test-summary (push) Has been cancelled
Type checking / changes (push) Has been cancelled
Type checking / test (push) Has been cancelled
Type checking / typescript-summary (push) Has been cancelled
Node tests / changes (push) Has been cancelled
Node tests / test (push) Has been cancelled
Node tests / test-summary (push) Has been cancelled
Источник: https://github.com/nextcloud/spreed/archive/refs/tags/v22.0.12.tar.gz С этого коммита ветка официального Nextcloud Talk отрезана (решение владельца 2026-07-06). Все дальнейшие изменения — только наши; версии релизов: 22.0.12-f7.N.
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Talk\Service;
|
||||
|
||||
use OCA\Talk\Model\PhoneNumber;
|
||||
use OCA\Talk\Model\PhoneNumberMapper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\User\IAvailabilityCoordinator;
|
||||
|
||||
class PhoneService {
|
||||
|
||||
public function __construct(
|
||||
protected IUserManager $userManager,
|
||||
protected IAvailabilityCoordinator $availabilityCoordinator,
|
||||
protected PhoneNumberMapper $mapper,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user ID to call
|
||||
*
|
||||
* Internally falling back to the OOO replacement,
|
||||
* if one is defined that has a phone number and is not OOO itself.
|
||||
*
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function getAccountToCallForPhoneNumber(string $phoneNumber): PhoneNumber {
|
||||
$entity = $this->mapper->findByPhoneNumber($phoneNumber);
|
||||
|
||||
$user = $this->userManager->get($entity->getActorId());
|
||||
if (!$user instanceof IUser) {
|
||||
throw new DoesNotExistException('Invalid user');
|
||||
}
|
||||
|
||||
$outOfOffice = $this->availabilityCoordinator->getCurrentOutOfOfficeData($user);
|
||||
if ($outOfOffice === null
|
||||
|| $outOfOffice->getReplacementUserId() === null
|
||||
|| !$this->availabilityCoordinator->isInEffect($outOfOffice)) {
|
||||
return $entity;
|
||||
}
|
||||
|
||||
$replacementUser = $this->userManager->get($outOfOffice->getReplacementUserId());
|
||||
if (!$replacementUser instanceof IUser) {
|
||||
// Replacement is wrong, fall back to original user
|
||||
return $entity;
|
||||
}
|
||||
|
||||
$outOfOffice = $this->availabilityCoordinator->getCurrentOutOfOfficeData($replacementUser);
|
||||
if ($outOfOffice !== null
|
||||
&& $this->availabilityCoordinator->isInEffect($outOfOffice)) {
|
||||
// Replacement is also OOO, fall back to original user
|
||||
return $entity;
|
||||
}
|
||||
|
||||
$entities = $this->mapper->findByUser($replacementUser->getUID());
|
||||
if (empty($entities)) {
|
||||
// Replacement has no phone number, fall back to original user
|
||||
return $entity;
|
||||
}
|
||||
|
||||
return array_shift($entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<PhoneNumber>
|
||||
*/
|
||||
public function findByUser(string $userId): array {
|
||||
return $this->mapper->findByUser($userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<PhoneNumber>
|
||||
*/
|
||||
public function findByPhoneNumbers(array $phoneNumbers): array {
|
||||
return $this->mapper->findByPhoneNumbers($phoneNumbers);
|
||||
}
|
||||
|
||||
public function deleteByPhoneNumber(string $phoneNumber): void {
|
||||
$this->mapper->deleteByPhoneNumber($phoneNumber);
|
||||
}
|
||||
|
||||
public function deleteByUser(string $userId): void {
|
||||
$this->mapper->deleteByUser($userId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user