diff --git a/lib/private/ContextChat/ContentManager.php b/lib/private/ContextChat/ContentManager.php new file mode 100644 index 00000000000..2185829a633 --- /dev/null +++ b/lib/private/ContextChat/ContentManager.php @@ -0,0 +1,50 @@ +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); + } +} diff --git a/lib/private/Server.php b/lib/private/Server.php index 4b88a446405..1e1ba2a1ad3 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -277,6 +277,8 @@ class Server extends ServerContainer implements IServerContainer { $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); diff --git a/lib/public/ContextChat/ContentItem.php b/lib/public/ContextChat/ContentItem.php new file mode 100644 index 00000000000..3cd193a2f60 --- /dev/null +++ b/lib/public/ContextChat/ContentItem.php @@ -0,0 +1,34 @@ + $providerClass + * @return void + * @since 32.0.0 + */ + public function registerContentProvider(string $appId, string $providerId, string $providerClass): void { + $this->contentManager->registerContentProvider($appId, $providerId, $providerClass); + } +} diff --git a/lib/public/ContextChat/IContentManager.php b/lib/public/ContextChat/IContentManager.php new file mode 100644 index 00000000000..b6a81892e15 --- /dev/null +++ b/lib/public/ContextChat/IContentManager.php @@ -0,0 +1,105 @@ + $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; +} diff --git a/lib/public/ContextChat/IContentProvider.php b/lib/public/ContextChat/IContentProvider.php new file mode 100644 index 00000000000..79380db3e9b --- /dev/null +++ b/lib/public/ContextChat/IContentProvider.php @@ -0,0 +1,47 @@ +