diff --git a/appinfo/info.xml b/appinfo/info.xml index 81000692357d..b82ed096eacc 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -16,7 +16,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m ]]> - 19.0.0-dev.0 + 19.0.0-dev.1 agpl Daniel Calviño Sánchez diff --git a/lib/Federation/CloudFederationProviderTalk.php b/lib/Federation/CloudFederationProviderTalk.php index 0a331cdb466a..fc3f6c682cb4 100644 --- a/lib/Federation/CloudFederationProviderTalk.php +++ b/lib/Federation/CloudFederationProviderTalk.php @@ -121,20 +121,20 @@ public function shareReceived(ICloudFederationShare $share): string { $roomToken = $share->getResourceName(); $roomName = $share->getProtocol()['roomName']; $roomType = (int) $roomType; - $sharedBy = $share->getSharedByDisplayName(); + $sharedByDisplayName = $share->getSharedByDisplayName(); $sharedByFederatedId = $share->getSharedBy(); - $owner = $share->getOwnerDisplayName(); + $ownerDisplayName = $share->getOwnerDisplayName(); $ownerFederatedId = $share->getOwner(); [, $remote] = $this->addressHandler->splitUserRemote($ownerFederatedId); - // if no explicit information about the person who created the share was send + // if no explicit information about the person who created the share was sent // we assume that the share comes from the owner if ($sharedByFederatedId === null) { - $sharedBy = $owner; + $sharedByDisplayName = $ownerDisplayName; $sharedByFederatedId = $ownerFederatedId; } - if ($remote && $shareSecret && $shareWith && $roomToken && $remoteId && is_string($roomName) && $roomName && $owner) { + if ($remote && $shareSecret && $shareWith && $roomToken && $remoteId && is_string($roomName) && $roomName && $ownerDisplayName) { $shareWith = $this->userManager->get($shareWith); if ($shareWith === null) { $this->logger->debug('Received a federation invite for user that could not be found'); @@ -151,9 +151,9 @@ public function shareReceived(ICloudFederationShare $share): string { throw new ProviderCouldNotAddShareException('User does not exist', '', Http::STATUS_BAD_REQUEST); } - $invite = $this->federationManager->addRemoteRoom($shareWith, (int) $remoteId, $roomType, $roomName, $roomToken, $remote, $shareSecret); + $invite = $this->federationManager->addRemoteRoom($shareWith, (int) $remoteId, $roomType, $roomName, $roomToken, $remote, $shareSecret, $sharedByFederatedId, $sharedByDisplayName); - $this->notifyAboutNewShare($shareWith, (string) $invite->getId(), $sharedByFederatedId, $sharedBy, $roomName, $roomToken, $remote); + $this->notifyAboutNewShare($shareWith, (string) $invite->getId(), $sharedByFederatedId, $sharedByDisplayName, $roomName, $roomToken, $remote); return (string) $invite->getId(); } diff --git a/lib/Federation/FederationManager.php b/lib/Federation/FederationManager.php index d2149d0f4270..5edf942902d7 100644 --- a/lib/Federation/FederationManager.php +++ b/lib/Federation/FederationManager.php @@ -77,6 +77,8 @@ public function addRemoteRoom( string $remoteServerUrl, #[SensitiveParameter] string $sharedSecret, + string $inviterFederatedId, + string $inviterDisplayName, ): Invitation { try { $room = $this->manager->getRoomByToken($remoteToken, null, $remoteServerUrl); @@ -92,6 +94,8 @@ public function addRemoteRoom( $invitation->setRemoteServerUrl($remoteServerUrl); $invitation->setRemoteToken($remoteToken); $invitation->setRemoteAttendeeId($remoteAttendeeId); + $invitation->setInviterFederatedId($inviterFederatedId); + $invitation->setInviterDisplayName($inviterDisplayName); $this->invitationMapper->insert($invitation); return $invitation; diff --git a/lib/Migration/Version19000Date20240212155937.php b/lib/Migration/Version19000Date20240212155937.php new file mode 100644 index 000000000000..278eab5e22dd --- /dev/null +++ b/lib/Migration/Version19000Date20240212155937.php @@ -0,0 +1,64 @@ + + * + * @author Joas Schilling + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Talk\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Add inviter information to the invites for rendering them outside of notifications later + */ +class Version19000Date20240212155937 extends SimpleMigrationStep { + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->getTable('talk_invitations'); + if (!$table->hasColumn('inviter_user_id')) { + $table->addColumn('inviter_user_id', Types::STRING, [ + 'notnull' => false, + 'length' => 255, + ]); + $table->addColumn('inviter_display_name', Types::STRING, [ + 'notnull' => false, + 'length' => 255, + ]); + return $schema; + } + + return null; + } +} diff --git a/lib/Model/Invitation.php b/lib/Model/Invitation.php index 33918e0a6632..7c4d3516d429 100644 --- a/lib/Model/Invitation.php +++ b/lib/Model/Invitation.php @@ -43,6 +43,10 @@ * @method string getRemoteToken() * @method void setRemoteAttendeeId(int $remoteAttendeeId) * @method int getRemoteAttendeeId() + * @method void setInviterFederatedId(string $inviterFederatedId) + * @method string getInviterFederatedId() + * @method void setInviterDisplayName(string $inviterDisplayName) + * @method string getInviterDisplayName() */ class Invitation extends Entity implements \JsonSerializable { public const STATE_PENDING = 0; @@ -55,6 +59,8 @@ class Invitation extends Entity implements \JsonSerializable { protected string $remoteServerUrl = ''; protected string $remoteToken = ''; protected int $remoteAttendeeId = 0; + protected string $inviterFederatedId = ''; + protected string $inviterDisplayName = ''; public function __construct() { $this->addType('userId', 'string'); @@ -64,10 +70,12 @@ public function __construct() { $this->addType('remoteServerUrl', 'string'); $this->addType('remoteToken', 'string'); $this->addType('remoteAttendeeId', 'int'); + $this->addType('inviterFederatedId', 'string'); + $this->addType('inviterDisplayName', 'string'); } /** - * @return array{accessToken: string, id: int, localRoomId: int, remoteAttendeeId: int, remoteServerUrl: string, remoteToken: string, state: int, userId: string} + * @return array{accessToken: string, id: int, localRoomId: int, remoteAttendeeId: int, remoteServerUrl: string, remoteToken: string, state: int, userId: string, inviterFederatedId: string, inviterDisplayName: string} */ public function jsonSerialize(): array { return [ @@ -79,6 +87,8 @@ public function jsonSerialize(): array { 'remoteServerUrl' => $this->getRemoteServerUrl(), 'remoteToken' => $this->getRemoteToken(), 'remoteAttendeeId' => $this->getRemoteAttendeeId(), + 'inviterFederatedId' => $this->getInviterFederatedId(), + 'inviterDisplayName' => $this->getInviterDisplayName() ?: $this->getInviterFederatedId(), ]; } } diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php index 835dfeb400a1..40fca4445e22 100644 --- a/lib/ResponseDefinitions.php +++ b/lib/ResponseDefinitions.php @@ -109,6 +109,8 @@ * remoteToken: string, * roomName: string, * userId: string, + * inviterFederatedId: string, + * inviterDisplayName: string, * } * * @psalm-type TalkMatterbridgeConfigFields = array> diff --git a/openapi-federation.json b/openapi-federation.json index 56007fb351f2..ac649a4235bd 100644 --- a/openapi-federation.json +++ b/openapi-federation.json @@ -133,7 +133,9 @@ "remoteServerUrl", "remoteToken", "roomName", - "userId" + "userId", + "inviterFederatedId", + "inviterDisplayName" ], "properties": { "accessToken": { @@ -166,6 +168,12 @@ }, "userId": { "type": "string" + }, + "inviterFederatedId": { + "type": "string" + }, + "inviterDisplayName": { + "type": "string" } } }, diff --git a/openapi-full.json b/openapi-full.json index d62a8b850763..0d290f18709e 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -330,7 +330,9 @@ "remoteServerUrl", "remoteToken", "roomName", - "userId" + "userId", + "inviterFederatedId", + "inviterDisplayName" ], "properties": { "accessToken": { @@ -363,6 +365,12 @@ }, "userId": { "type": "string" + }, + "inviterFederatedId": { + "type": "string" + }, + "inviterDisplayName": { + "type": "string" } } },