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

Источник: 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:
2026-07-06 14:07:50 +00:00
commit 01acfa3b40
1716 changed files with 613013 additions and 0 deletions
+142
View File
@@ -0,0 +1,142 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Talk\Activity\Provider;
use OCA\Talk\Config;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
use OCA\Talk\Service\AvatarService;
use OCA\Talk\Service\ParticipantService;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OCP\Federation\ICloudIdManager;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
abstract class Base implements IProvider {
public function __construct(
protected IFactory $languageFactory,
protected IURLGenerator $url,
protected Config $config,
protected IManager $activityManager,
protected IUserManager $userManager,
protected ICloudIdManager $cloudIdManager,
protected ParticipantService $participantService,
protected AvatarService $avatarService,
protected Manager $manager,
) {
}
/**
* @param IEvent $event
* @return IEvent
* @throws UnknownActivityException
*/
public function preParse(IEvent $event): IEvent {
if ($event->getApp() !== 'spreed') {
throw new UnknownActivityException('app');
}
$uid = $event->getAffectedUser();
$user = $this->userManager->get($uid);
if (!$user instanceof IUser || $this->config->isDisabledForUser($user)) {
throw new UnknownActivityException('User can not use Talk');
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('spreed', 'app-dark.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('spreed', 'app-dark.svg')));
}
return $event;
}
/**
* @param IEvent $event
* @param string $subject
* @param array $parameters
*/
protected function setSubjects(IEvent $event, string $subject, array $parameters): void {
$placeholders = $replacements = [];
foreach ($parameters as $placeholder => $parameter) {
$placeholders[] = '{' . $placeholder . '}';
$replacements[] = $parameter['name'];
}
$event->setParsedSubject(str_replace($placeholders, $replacements, $subject))
->setRichSubject($subject, $parameters);
}
protected function getRoom(Room $room, string $userId): array {
switch ($room->getType()) {
case Room::TYPE_ONE_TO_ONE:
case Room::TYPE_ONE_TO_ONE_FORMER:
$stringType = 'one2one';
break;
case Room::TYPE_GROUP:
$stringType = 'group';
break;
case Room::TYPE_PUBLIC:
default:
$stringType = 'public';
break;
}
return [
'type' => 'call',
'id' => (string)$room->getId(),
'name' => $room->getDisplayName($userId),
'link' => $this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]),
'call-type' => $stringType,
'icon-url' => $this->avatarService->getAvatarUrl($room),
];
}
protected function getFormerRoom(IL10N $l): array {
return [
'type' => 'highlight',
'id' => 'deleted',
'name' => $l->t('a conversation'),
];
}
protected function getUser(string $uid): array {
return [
'type' => 'user',
'id' => $uid,
'name' => $this->userManager->getDisplayName($uid) ?? $uid,
];
}
protected function getRemoteUser(Room $room, string $federationId): array {
$cloudId = $this->cloudIdManager->resolveCloudId($federationId);
$displayName = $cloudId->getDisplayId();
try {
$participant = $this->participantService->getParticipantByActor($room, Attendee::ACTOR_FEDERATED_USERS, $federationId);
$displayName = $participant->getAttendee()->getDisplayName();
} catch (ParticipantNotFoundException) {
}
return [
'type' => 'user',
'id' => $cloudId->getUser(),
'name' => $displayName,
'server' => $cloudId->getRemote(),
];
}
}
+156
View File
@@ -0,0 +1,156 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Talk\Activity\Provider;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Room;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\IL10N;
class Call extends Base {
/**
* @param string $language
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws UnknownActivityException
* @since 11.0.0
*/
#[\Override]
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
$event = $this->preParse($event);
if ($event->getSubject() === 'call') {
$l = $this->languageFactory->get('spreed', $language);
$parameters = $event->getSubjectParameters();
try {
$room = $this->manager->getRoomForUser((int)$parameters['room'], $this->activityManager->getCurrentUserId());
} catch (RoomNotFoundException) {
$room = null;
}
$result = $this->parseCall($room, $event, $l);
$result['subject'] .= ' ' . $this->getDuration($l, (int)$parameters['duration']);
// $result['params']['call'] = $roomParameter;
$this->setSubjects($event, $result['subject'], $result['params']);
} else {
throw new UnknownActivityException('subject');
}
return $event;
}
protected function getDuration(IL10N $l, int $seconds): string {
$hours = floor($seconds / 3600);
$seconds %= 3600;
$minutes = floor($seconds / 60);
$seconds %= 60;
if ($hours > 0) {
$duration = sprintf('%1$d:%2$02d:%3$02d', $hours, $minutes, $seconds);
} else {
$duration = sprintf('%1$d:%2$02d', $minutes, $seconds);
}
return $l->t('(Duration %s)', $duration);
}
protected function parseCall(?Room $room, IEvent $event, IL10N $l): array {
$parameters = $event->getSubjectParameters();
$currentUser = array_search($this->activityManager->getCurrentUserId(), $parameters['users'], true);
if ($currentUser === false) {
throw new UnknownActivityException('Unknown case');
}
unset($parameters['users'][$currentUser]);
sort($parameters['users']);
if (!isset($parameters['cloudIds'])) {
// Compatibility with old messages
$parameters['cloudIds'] = [];
}
sort($parameters['users']);
sort($parameters['cloudIds']);
$numUsers = $numRealUsers = count($parameters['users']);
// Without room, we can not resolve cloudIds, so we list them as guests instead
if (!$room instanceof Room) {
$numUsers += count($parameters['cloudIds']);
} else {
$parameters['guests'] += count($parameters['cloudIds']);
}
$displayedUsers = $numUsers;
switch ($numUsers) {
case 0:
$subject = $l->t('You attended a call with {user1}');
$subject = str_replace('{user1}', $l->n('%n guest', '%n guests', $parameters['guests']), $subject);
break;
case 1:
if ($parameters['guests'] === 0) {
$subject = $l->t('You attended a call with {user1}');
} else {
$subject = $l->t('You attended a call with {user1} and {user2}');
$subject = str_replace('{user2}', $l->n('%n guest', '%n guests', $parameters['guests']), $subject);
}
break;
case 2:
if ($parameters['guests'] === 0) {
$subject = $l->t('You attended a call with {user1} and {user2}');
} else {
$subject = $l->t('You attended a call with {user1}, {user2} and {user3}');
$subject = str_replace('{user3}', $l->n('%n guest', '%n guests', $parameters['guests']), $subject);
}
break;
case 3:
if ($parameters['guests'] === 0) {
$subject = $l->t('You attended a call with {user1}, {user2} and {user3}');
} else {
$subject = $l->t('You attended a call with {user1}, {user2}, {user3} and {user4}');
$subject = str_replace('{user4}', $l->n('%n guest', '%n guests', $parameters['guests']), $subject);
}
break;
case 4:
if ($parameters['guests'] === 0) {
$subject = $l->t('You attended a call with {user1}, {user2}, {user3} and {user4}');
} else {
$subject = $l->t('You attended a call with {user1}, {user2}, {user3}, {user4} and {user5}');
$subject = str_replace('{user5}', $l->n('%n guest', '%n guests', $parameters['guests']), $subject);
}
break;
case 5:
default:
$subject = $l->t('You attended a call with {user1}, {user2}, {user3}, {user4} and {user5}');
if ($numUsers === 5 && $parameters['guests'] === 0) {
$displayedUsers = 5;
} else {
$displayedUsers = 4;
$numOthers = $parameters['guests'] + $numUsers - $displayedUsers;
$subject = str_replace('{user5}', $l->n('%n other', '%n others', $numOthers), $subject);
}
}
$params = [];
for ($i = 1; $i <= $displayedUsers; $i++) {
if ($i <= $numRealUsers) {
$params['user' . $i] = $this->getUser($parameters['users'][$i - 1]);
} else {
$params['user' . $i] = $this->getRemoteUser($room, $parameters['cloudIds'][$i - $numRealUsers - 1]);
}
}
return [
'subject' => $subject,
'params' => $params,
];
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Talk\Activity\Provider;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
class Invitation extends Base {
/**
* @param string $language
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws UnknownActivityException
* @since 11.0.0
*/
#[\Override]
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
$event = $this->preParse($event);
if ($event->getSubject() === 'invitation') {
$l = $this->languageFactory->get('spreed', $language);
$parameters = $event->getSubjectParameters();
try {
$room = $this->manager->getRoomById((int)$parameters['room']);
$roomParameter = $this->getRoom($room, $event->getAffectedUser());
} catch (RoomNotFoundException) {
$roomParameter = $this->getFormerRoom($l);
}
$this->setSubjects($event, $l->t('{actor} invited you to {call}'), [
'actor' => $this->getUser($parameters['user']),
'call' => $roomParameter,
]);
} else {
throw new UnknownActivityException('subject');
}
return $event;
}
}