@@ -39,19 +39,17 @@ public function __construct(
39
39
* version: string,
40
40
* enabled?: bool
41
41
* },
42
- * declarativeui?: array{
43
- * hooks: list<array{
44
- * type: 'context-menu',
45
- * endpoints: list<array{
42
+ * declarativeui?: array<string, array{
43
+ * context-menu: list<array{
46
44
* name: string,
47
45
* url: string,
48
- * filter: string,
46
+ * method: string,
47
+ * mimetype_filters: string,
49
48
* android_icon: string,
50
49
* desktop_icon: string,
51
50
* ios_icon: string,
52
- * }>
53
51
* }>
54
- * },
52
+ * }> ,
55
53
* }
56
54
*/
57
55
public function getCapabilities (): array {
@@ -80,60 +78,73 @@ public function getCapabilities(): array {
80
78
81
79
if ($ summarizeAvailable || $ sttAvailable || $ ttsAvailable ) {
82
80
$ capabilities ['declarativeui ' ] = [
83
- 'hooks ' => [
84
- [
85
- 'type ' => 'context-menu ' ,
86
- 'endpoints ' => [],
87
- ],
81
+ Application::APP_ID => [
82
+ 'context-menu ' => [],
88
83
],
89
84
];
90
85
86
+ $ textMimeTypes = [
87
+ 'text/ ' ,
88
+ 'application/msword ' ,
89
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document ' ,
90
+ 'application/vnd.oasis.opendocument.text ' ,
91
+ 'application/pdf ' ,
92
+ ];
91
93
if ($ summarizeAvailable ) {
94
+ $ url = $ this ->urlGenerator ->linkToOCSRouteAbsolute (Application::APP_ID . '.assistantApi.runFileAction ' , [
95
+ 'apiVersion ' => 'v1 ' ,
96
+ 'fileId ' => '123456789 ' ,
97
+ 'taskTypeId ' => TextToTextSummary::ID ,
98
+ ]);
99
+ $ url = str_replace ('123456789 ' , '{fileId} ' , $ url );
92
100
$ endpoint = [
93
101
'name ' => $ this ->l ->t ('Summarize ' ),
94
- 'url ' => $ this ->urlGenerator ->linkToOCSRouteAbsolute (Application::APP_ID . '.assistantApi.runFileAction ' , [
95
- 'apiVersion ' => 'v1 ' ,
96
- 'fileId ' => '{s} ' ,
97
- 'taskTypeId ' => TextToTextSummary::ID ,
98
- ]),
99
- 'filter ' => 'text/ ' ,
102
+ 'url ' => $ url ,
103
+ 'method ' => 'POST ' ,
104
+ 'mimetype_filters ' => implode (', ' , $ textMimeTypes ),
100
105
'android_icon ' => 'creation ' ,
101
106
'ios_icon ' => 'creation ' ,
102
107
'desktop_icon ' => 'creation ' ,
103
108
];
104
- $ capabilities ['declarativeui ' ][' hooks ' ][ 0 ][ ' endpoints ' ][] = $ endpoint ;
109
+ $ capabilities ['declarativeui ' ][Application:: APP_ID ][ ' context-menu ' ][] = $ endpoint ;
105
110
}
106
111
107
112
if ($ sttAvailable ) {
113
+ $ url = $ this ->urlGenerator ->linkToOCSRouteAbsolute (Application::APP_ID . '.assistantApi.runFileAction ' , [
114
+ 'apiVersion ' => 'v1 ' ,
115
+ 'fileId ' => '123456789 ' ,
116
+ 'taskTypeId ' => \OCP \TaskProcessing \TaskTypes \TextToSpeech::ID ,
117
+ ]);
118
+ $ url = str_replace ('123456789 ' , '{fileId} ' , $ url );
108
119
$ endpoint = [
109
120
'name ' => $ this ->l ->t ('Transcribe audio ' ),
110
- 'url ' => $ this ->urlGenerator ->linkToOCSRouteAbsolute (Application::APP_ID . '.assistantApi.runFileAction ' , [
111
- 'apiVersion ' => 'v1 ' ,
112
- 'fileId ' => '{s} ' ,
113
- 'taskTypeId ' => \OCP \TaskProcessing \TaskTypes \TextToSpeech::ID ,
114
- ]),
115
- 'filter ' => 'audio/ ' ,
121
+ 'url ' => $ url ,
122
+ 'method ' => 'POST ' ,
123
+ 'mimetype_filters ' => 'audio/ ' ,
116
124
'android_icon ' => 'speech_to_text ' ,
117
125
'ios_icon ' => 'speech_to_text ' ,
118
126
'desktop_icon ' => 'speech_to_text ' ,
119
127
];
120
- $ capabilities ['declarativeui ' ][' hooks ' ][ 0 ][ ' endpoints ' ][] = $ endpoint ;
128
+ $ capabilities ['declarativeui ' ][Application:: APP_ID ][ ' context-menu ' ][] = $ endpoint ;
121
129
}
122
130
123
131
if ($ ttsAvailable ) {
132
+ $ url = $ this ->urlGenerator ->linkToOCSRouteAbsolute (Application::APP_ID . '.assistantApi.runFileAction ' , [
133
+ 'apiVersion ' => 'v1 ' ,
134
+ 'fileId ' => '123456789 ' ,
135
+ 'taskTypeId ' => AudioToText::ID ,
136
+ ]);
137
+ $ url = str_replace ('123456789 ' , '{fileId} ' , $ url );
124
138
$ endpoint = [
125
139
'name ' => $ this ->l ->t ('Text to speech ' ),
126
- 'url ' => $ this ->urlGenerator ->linkToOCSRouteAbsolute (Application::APP_ID . '.assistantApi.runFileAction ' , [
127
- 'apiVersion ' => 'v1 ' ,
128
- 'fileId ' => '{s} ' ,
129
- 'taskTypeId ' => AudioToText::ID ,
130
- ]),
131
- 'filter ' => 'text/ ' ,
140
+ 'url ' => $ url ,
141
+ 'method ' => 'POST ' ,
142
+ 'mimetype_filters ' => implode (', ' , $ textMimeTypes ),
132
143
'android_icon ' => 'text_to_speech ' ,
133
144
'ios_icon ' => 'text_to_speech ' ,
134
145
'desktop_icon ' => 'text_to_speech ' ,
135
146
];
136
- $ capabilities ['declarativeui ' ][' hooks ' ][ 0 ][ ' endpoints ' ][] = $ endpoint ;
147
+ $ capabilities ['declarativeui ' ][Application:: APP_ID ][ ' context-menu ' ][] = $ endpoint ;
137
148
}
138
149
}
139
150
0 commit comments