-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: add Context Chat OCP API #53859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
4dc4697
to
1290be2
Compare
Looks good! You can suppress psalm errors for the OCA\ContextChat classes by adding them to the psalm.xml suppress handler. |
0291146
to
ccbf226
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a isContextChatAvailable
method in the content manager so providers could even avoid calling submitContent
if it's not available.
There could be a new section in the docs (after "Submitting ContentItem data") about this new method.
Ah, yes. Good point. OCA\ContextChat\Public\ContentManager would also have to implement this, then, which is a bit useless, but we can just return true there. |
6a256a8
to
87d4253
Compare
Signed-off-by: Edward Ly <contact@edward.ly>
Signed-off-by: Edward Ly <contact@edward.ly>
…ContentManager Signed-off-by: Edward Ly <contact@edward.ly>
Signed-off-by: Edward Ly <contact@edward.ly>
87d4253
to
70204ea
Compare
/** | ||
* @since 32.0.0 | ||
*/ | ||
class ContentItem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this class really be in OCP?
Would it not be better to have it an interface instead as we do everywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and implementation in OC)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a data object that is supposed to be used be consumers of the API to submit data to context chat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See docs on how this is intended to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be helpful if the items are generated by the apps
*/ | ||
class UpdateAccessOp { | ||
public const ALLOW = 'allow'; | ||
public const DENY = 'deny'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Op? Should probably have a better understandable name?
Also why not use an enum instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is based on an existing API in OCA\ContextChat\Public with the rationale being to change as little as possible for apps that already implement the old API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments
* @return void | ||
* @since 32.0.0 | ||
*/ | ||
public function registerContentProvider(string $appId, string $providerId, string $providerClass): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be moved into the app bootstrap mechanism to be a bit more lightweight? The current implementation needs the content manager to be build to perform a registration. The bootstrap context is always built when we bootstrap apps, but only if the context chat content manager is really needed in a request it will be built
/** | ||
* @since 32.0.0 | ||
*/ | ||
class ContentItem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be helpful if the items are generated by the apps
* @since 32.0.0 | ||
*/ | ||
public function __construct( | ||
public string $itemId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: missing since tags for the properties
@@ -0,0 +1,113 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new classes do are not strict. it should not cause an issues to make the strict from the beginning, so I suggest to add the declare line for the newly added interfaces and classes
@@ -0,0 +1,54 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declare(strict_types=1); |
Checklist