Skip to content

Commit 9d688a2

Browse files
committed
fix: extend OCP API only if available
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent efb2cb3 commit 9d688a2

4 files changed

Lines changed: 92 additions & 8 deletions

File tree

lib/Public/ContentItem.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,30 @@
77

88
namespace OCA\ContextChat\Public;
99

10-
class ContentItem extends \OCP\ContextChat\ContentItem {
10+
if (class_exists(\OCP\ContextChat\ContenItem::class)) {
11+
// Available starting with nc 32
12+
class ContentItem extends \OCP\ContextChat\ContentItem {
13+
}
14+
} else {
15+
class ContentItem {
16+
/**
17+
* @param string $itemId
18+
* @param string $providerId
19+
* @param string $title
20+
* @param string $content
21+
* @param string $documentType
22+
* @param \DateTime $lastModified
23+
* @param string[] $users
24+
*/
25+
public function __construct(
26+
public string $itemId,
27+
public string $providerId,
28+
public string $title,
29+
public string $content,
30+
public string $documentType,
31+
public \DateTime $lastModified,
32+
public array $users,
33+
) {
34+
}
35+
}
1136
}

lib/Public/ContentManager.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@
1616
use OCA\ContextChat\Service\ActionScheduler;
1717
use OCA\ContextChat\Service\ProviderConfigService;
1818
use OCP\BackgroundJob\IJobList;
19-
use OCP\ContextChat\IContentManager;
2019
use OCP\EventDispatcher\IEventDispatcher;
2120
use OCP\Server;
2221
use Psr\Container\ContainerExceptionInterface;
2322
use Psr\Container\NotFoundExceptionInterface;
2423

25-
class ContentManager implements IContentManager {
24+
if (class_exists(\OCP\ContextChat\IContentManager::class)) {
25+
// Available starting with nc 32
26+
interface IInternalContentManager extends OCP\ContextChat\IContentManager {
27+
}
28+
} else {
29+
interface IInternalContentManager {
30+
}
31+
}
32+
33+
class ContentManager implements IInternalContentManager {
2634
public function __construct(
2735
private IJobList $jobList,
2836
private ProviderConfigService $providerConfig,

lib/Public/IContentProvider.php

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,51 @@
77

88
namespace OCA\ContextChat\Public;
99

10-
/**
11-
* @since 1.1.0
12-
*/
13-
interface IContentProvider extends \OCP\ContextChat\IContentProvider {
10+
if (class_exists(\OCP\ContextChat\IContentProvider::class)) {
11+
// Available starting with nc 32
12+
/**
13+
* @since 1.1.0
14+
*/
15+
interface IContentProvider extends \OCP\ContextChat\IContentProvider {
16+
}
17+
} else {
18+
19+
/**
20+
* This interface defines methods to implement a content provider
21+
* @since 1.1.0
22+
*/
23+
interface IContentProvider {
24+
/**
25+
* The ID of the provider
26+
*
27+
* @return string
28+
* @since 1.1.0
29+
*/
30+
public function getId(): string;
31+
32+
/**
33+
* The ID of the app making the provider avaialble
34+
*
35+
* @return string
36+
* @since 1.1.0
37+
*/
38+
public function getAppId(): string;
39+
40+
/**
41+
* The absolute URL to the content item
42+
*
43+
* @param string $id
44+
* @return string
45+
* @since 1.1.0
46+
*/
47+
public function getItemUrl(string $id): string;
48+
49+
/**
50+
* Starts the initial import of content items into content chat
51+
*
52+
* @return void
53+
* @since 1.1.0
54+
*/
55+
public function triggerInitialImport(): void;
56+
}
1457
}

lib/Public/UpdateAccessOp.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@
77

88
namespace OCA\ContextChat\Public;
99

10-
class UpdateAccessOp extends \OCA\ContextChat\Type\UpdateAccessOp {
10+
if (class_exists(\OCA\ContextChat\Type\UpdateAccessOp::class)) {
11+
// Available starting with nc 32
12+
class UpdateAccessOp extends \OCA\ContextChat\Type\UpdateAccessOp {
13+
}
14+
} else {
15+
class UpdateAccessOp {
16+
public const ALLOW = 'allow';
17+
public const DENY = 'deny';
18+
}
1119
}

0 commit comments

Comments
 (0)