Skip to content
Merged
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
6 changes: 6 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@
'OCP\\Contacts\\ContactsMenu\\IProvider' => $baseDir . '/lib/public/Contacts/ContactsMenu/IProvider.php',
'OCP\\Contacts\\Events\\ContactInteractedWithEvent' => $baseDir . '/lib/public/Contacts/Events/ContactInteractedWithEvent.php',
'OCP\\Contacts\\IManager' => $baseDir . '/lib/public/Contacts/IManager.php',
'OCP\\ContextChat\\ContentItem' => $baseDir . '/lib/public/ContextChat/ContentItem.php',
'OCP\\ContextChat\\Events\\ContentProviderRegisterEvent' => $baseDir . '/lib/public/ContextChat/Events/ContentProviderRegisterEvent.php',
'OCP\\ContextChat\\IContentManager' => $baseDir . '/lib/public/ContextChat/IContentManager.php',
'OCP\\ContextChat\\IContentProvider' => $baseDir . '/lib/public/ContextChat/IContentProvider.php',
'OCP\\ContextChat\\Type\\UpdateAccessOp' => $baseDir . '/lib/public/ContextChat/Type/UpdateAccessOp.php',
'OCP\\DB\\Events\\AddMissingColumnsEvent' => $baseDir . '/lib/public/DB/Events/AddMissingColumnsEvent.php',
'OCP\\DB\\Events\\AddMissingIndicesEvent' => $baseDir . '/lib/public/DB/Events/AddMissingIndicesEvent.php',
'OCP\\DB\\Events\\AddMissingPrimaryKeyEvent' => $baseDir . '/lib/public/DB/Events/AddMissingPrimaryKeyEvent.php',
Expand Down Expand Up @@ -1216,6 +1221,7 @@
'OC\\Contacts\\ContactsMenu\\Providers\\EMailProvider' => $baseDir . '/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php',
'OC\\Contacts\\ContactsMenu\\Providers\\LocalTimeProvider' => $baseDir . '/lib/private/Contacts/ContactsMenu/Providers/LocalTimeProvider.php',
'OC\\Contacts\\ContactsMenu\\Providers\\ProfileProvider' => $baseDir . '/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php',
'OC\\ContextChat\\ContentManager' => $baseDir . '/lib/private/ContextChat/ContentManager.php',
'OC\\Core\\AppInfo\\Application' => $baseDir . '/core/AppInfo/Application.php',
'OC\\Core\\BackgroundJobs\\BackgroundCleanupUpdaterBackupsJob' => $baseDir . '/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php',
'OC\\Core\\BackgroundJobs\\CheckForUserCertificates' => $baseDir . '/core/BackgroundJobs/CheckForUserCertificates.php',
Expand Down
6 changes: 6 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Contacts\\ContactsMenu\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IProvider.php',
'OCP\\Contacts\\Events\\ContactInteractedWithEvent' => __DIR__ . '/../../..' . '/lib/public/Contacts/Events/ContactInteractedWithEvent.php',
'OCP\\Contacts\\IManager' => __DIR__ . '/../../..' . '/lib/public/Contacts/IManager.php',
'OCP\\ContextChat\\ContentItem' => __DIR__ . '/../../..' . '/lib/public/ContextChat/ContentItem.php',
'OCP\\ContextChat\\Events\\ContentProviderRegisterEvent' => __DIR__ . '/../../..' . '/lib/public/ContextChat/Events/ContentProviderRegisterEvent.php',
'OCP\\ContextChat\\IContentManager' => __DIR__ . '/../../..' . '/lib/public/ContextChat/IContentManager.php',
'OCP\\ContextChat\\IContentProvider' => __DIR__ . '/../../..' . '/lib/public/ContextChat/IContentProvider.php',
'OCP\\ContextChat\\Type\\UpdateAccessOp' => __DIR__ . '/../../..' . '/lib/public/ContextChat/Type/UpdateAccessOp.php',
'OCP\\DB\\Events\\AddMissingColumnsEvent' => __DIR__ . '/../../..' . '/lib/public/DB/Events/AddMissingColumnsEvent.php',
'OCP\\DB\\Events\\AddMissingIndicesEvent' => __DIR__ . '/../../..' . '/lib/public/DB/Events/AddMissingIndicesEvent.php',
'OCP\\DB\\Events\\AddMissingPrimaryKeyEvent' => __DIR__ . '/../../..' . '/lib/public/DB/Events/AddMissingPrimaryKeyEvent.php',
Expand Down Expand Up @@ -1257,6 +1262,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Contacts\\ContactsMenu\\Providers\\EMailProvider' => __DIR__ . '/../../..' . '/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php',
'OC\\Contacts\\ContactsMenu\\Providers\\LocalTimeProvider' => __DIR__ . '/../../..' . '/lib/private/Contacts/ContactsMenu/Providers/LocalTimeProvider.php',
'OC\\Contacts\\ContactsMenu\\Providers\\ProfileProvider' => __DIR__ . '/../../..' . '/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php',
'OC\\ContextChat\\ContentManager' => __DIR__ . '/../../..' . '/lib/private/ContextChat/ContentManager.php',
'OC\\Core\\AppInfo\\Application' => __DIR__ . '/../../..' . '/core/AppInfo/Application.php',
'OC\\Core\\BackgroundJobs\\BackgroundCleanupUpdaterBackupsJob' => __DIR__ . '/../../..' . '/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php',
'OC\\Core\\BackgroundJobs\\CheckForUserCertificates' => __DIR__ . '/../../..' . '/core/BackgroundJobs/CheckForUserCertificates.php',
Expand Down
56 changes: 56 additions & 0 deletions lib/private/ContextChat/ContentManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OC\ContextChat;

use OCA\ContextChat\Public\ContentManager as ContextChatContentManager;
use OCP\ContextChat\IContentManager;

class ContentManager implements IContentManager {
public function __construct(
private ?ContextChatContentManager $contentManager,
) {
}

public function isContextChatAvailable(): bool {
return $this->contentManager !== null;
}

public function registerContentProvider(string $appId, string $providerId, string $providerClass): void {
$this->contentManager?->registerContentProvider($appId, $providerId, $providerClass);
}

public function collectAllContentProviders(): void {
$this->contentManager?->collectAllContentProviders();
}

public function submitContent(string $appId, array $items): void {
$this->contentManager?->submitContent($appId, $items);
}

public function updateAccess(string $appId, string $providerId, string $itemId, string $op, array $userIds): void {
$this->contentManager?->updateAccess($appId, $providerId, $itemId, $op, $userIds);
}

public function updateAccessProvider(string $appId, string $providerId, string $op, array $userIds): void {
$this->contentManager?->updateAccessProvider($appId, $providerId, $op, $userIds);
}

public function updateAccessDeclarative(string $appId, string $providerId, string $itemId, array $userIds): void {
$this->contentManager?->updateAccessDeclarative($appId, $providerId, $itemId, $op, $userIds);
}

public function deleteProvider(string $appId, string $providerId): void {
$this->contentManager?->deleteProvider($appId, $providerId);
}

public function deleteContent(string $appId, string $providerId, array $itemIds): void {
$this->contentManager?->deleteContent($appId, $providerId, $itemIds);
}
}
2 changes: 2 additions & 0 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ public function __construct($webRoot, \OC\Config $config) {

$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);

$this->registerAlias(\OCP\ContextChat\IContentManager::class, \OC\ContextChat\ContentManager::class);

$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
$this->registerAlias(ITemplateManager::class, TemplateManager::class);
$this->registerAlias(\OCP\Template\ITemplateManager::class, \OC\Template\TemplateManager::class);
Expand Down
57 changes: 57 additions & 0 deletions lib/public/ContextChat/ContentItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\ContextChat;

/**
* @since 32.0.0
*/
class ContentItem {
/**
* @param string $itemId
* @param string $providerId
* @param string $title
* @param string $content
* @param string $documentType
* @param \DateTime $lastModified
* @param string[] $users
* @since 32.0.0
*/
public function __construct(
/**
* @since 32.0.0
*/
public string $itemId,
/**
* @since 32.0.0
*/
public string $providerId,
/**
* @since 32.0.0
*/
public string $title,
/**
* @since 32.0.0
*/
public string $content,
/**
* @since 32.0.0
*/
public string $documentType,
/**
* @since 32.0.0
*/
public \DateTime $lastModified,
/**
* @since 32.0.0
*/
public array $users,
) {
}
}
35 changes: 35 additions & 0 deletions lib/public/ContextChat/Events/ContentProviderRegisterEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\ContextChat\Events;

use OCP\ContextChat\IContentManager;
use OCP\ContextChat\IContentProvider;
use OCP\EventDispatcher\Event;

/**
* @since 32.0.0
*/
class ContentProviderRegisterEvent extends Event {
public function __construct(
private IContentManager $contentManager,
) {
}

/**
* @param string $appId
* @param string $providerId
* @param class-string<IContentProvider> $providerClass
* @return void
* @since 32.0.0
*/
public function registerContentProvider(string $appId, string $providerId, string $providerClass): void {
$this->contentManager->registerContentProvider($appId, $providerId, $providerClass);
}
}
115 changes: 115 additions & 0 deletions lib/public/ContextChat/IContentManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\ContextChat;

/**
* @since 32.0.0
*/
interface IContentManager {
/**
* Checks if the context chat app is enabled or not
*
* @return bool
* @since 32.0.0
*/
public function isContextChatAvailable(): bool;

/**
* @param string $appId
* @param string $providerId
* @param class-string<IContentProvider> $providerClass
* @return void
* @since 32.0.0
*/
public function registerContentProvider(string $appId, string $providerId, string $providerClass): void;

/**
* Emits an event to collect all content providers
*
* @return void
* @since 32.0.0
*/
public function collectAllContentProviders(): void;

/**
* Providers can use this to submit content for indexing in context chat
*
* @param string $appId
* @param ContentItem[] $items
* @return void
* @since 32.0.0
*/
public function submitContent(string $appId, array $items): void;

/**
* Update access for a content item for specified users.
* This modifies the access list for the content item,
* allowing or denying access to the specified users.
* If no user has access to the content item, it will be removed from the knowledge base.
*
* @param string $appId
* @param string $providerId
* @param string $itemId
* @param Type\UpdateAccessOp::* $op
* @param array $userIds
* @return void
* @since 32.0.0
*/
public function updateAccess(string $appId, string $providerId, string $itemId, string $op, array $userIds): void;

/**
* Update access for content items from the given provider for specified users.
* If no user has access to the content item, it will be removed from the knowledge base.
*
* @param string $appId
* @param string $providerId
* @param Type\UpdateAccessOp::* $op
* @param array $userIds
* @return void
* @since 32.0.0
*/
public function updateAccessProvider(string $appId, string $providerId, string $op, array $userIds): void;

/**
* Update access for a content item for specified users declaratively.
* This overwrites the access list for the content item,
* allowing only the specified users access to it.
*
* @param string $appId
* @param string $providerId
* @param string $itemId
* @param array $userIds
* @return void
* @since 32.0.0
*/
public function updateAccessDeclarative(string $appId, string $providerId, string $itemId, array $userIds): void;

/**
* Delete all content items and access lists for a provider.
* This does not unregister the provider itself.
*
* @param string $appId
* @param string $providerId
* @return void
* @since 32.0.0
*/
public function deleteProvider(string $appId, string $providerId): void;

/**
* Remove a content item from the knowledge base of context chat.
*
* @param string $appId
* @param string $providerId
* @param string[] $itemIds
* @return void
* @since 32.0.0
*/
public function deleteContent(string $appId, string $providerId, array $itemIds): void;
}
49 changes: 49 additions & 0 deletions lib/public/ContextChat/IContentProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\ContextChat;

/**
* This interface defines methods to implement a content provider
* @since 32.0.0
*/
interface IContentProvider {
/**
* The ID of the provider
*
* @return string
* @since 32.0.0
*/
public function getId(): string;

/**
* The ID of the app making the provider avaialble
*
* @return string
* @since 32.0.0
*/
public function getAppId(): string;

/**
* The absolute URL to the content item
*
* @param string $id
* @return string
* @since 32.0.0
*/
public function getItemUrl(string $id): string;

/**
* Starts the initial import of content items into context chat
*
* @return void
* @since 32.0.0
*/
public function triggerInitialImport(): void;
}
18 changes: 18 additions & 0 deletions lib/public/ContextChat/Type/UpdateAccessOp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\ContextChat\Type;

/**
* @since 32.0.0
*/
class UpdateAccessOp {
public const ALLOW = 'allow';
public const DENY = 'deny';
}
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<referencedClass name="OCA\Circles\Exceptions\CircleNotFoundException"/>
<referencedClass name="OCA\Circles\Model\Circle"/>
<referencedClass name="OCA\Circles\Model\Member"/>
<referencedClass name="OCA\ContextChat\Public\ContentManager"/>
<referencedClass name="OCA\GroupFolders\Mount\GroupFolderStorage"/>
<referencedClass name="OCA\TwoFactorNextcloudNotification\Controller\APIController"/>
<referencedClass name="OCA\GlobalSiteSelector\Service\SlaveService"/>
Expand Down
Loading