Skip to content

Commit

Permalink
Rename controller methods and adjust routing
Browse files Browse the repository at this point in the history
Signed-off-by: MB-Finski <sami.finnila@gmail.com>
  • Loading branch information
MB-Finski committed Dec 21, 2023
1 parent edb729d commit ad8dd89
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
['name' => 'config#setConfig', 'url' => '/config', 'verb' => 'PUT'],
['name' => 'config#setAdminConfig', 'url' => '/admin-config', 'verb' => 'PUT'],

['name' => 'assistant#getTaskResultPage', 'url' => '/t/{taskId}', 'verb' => 'GET'],
['name' => 'assistant#runTask', 'url' => '/run', 'verb' => 'POST'],
['name' => 'assistant#runOrScheduleTask', 'url' => '/run-or-schedule', 'verb' => 'POST'],
['name' => 'assistant#getTextProcessingTaskResultPage', 'url' => '/t/{taskId}', 'verb' => 'GET'],
['name' => 'assistant#runTextProcessingTask', 'url' => '/run', 'verb' => 'POST'],
['name' => 'assistant#runOrScheduleTextProcessingTask', 'url' => '/run-or-schedule', 'verb' => 'POST'],

['name' => 'Text2Image#processPrompt', 'url' => '/i/process_prompt', 'verb' => 'POST'],
['name' => 'Text2Image#getPromptHistory', 'url' => '/i/prompt_history', 'verb' => 'GET'],
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/AssistantController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
#[NoAdminRequired]
#[NoCSRFRequired]
#[BruteForceProtection(action: 'taskResultPage')]
public function getTaskResultPage(int $taskId): TemplateResponse {
public function getTextProcessingTaskResultPage(int $taskId): TemplateResponse {
$task = $this->assistantService->getTextProcessingTask($this->userId, $taskId);
if ($task === null) {
$response = new TemplateResponse(
Expand All @@ -59,7 +59,7 @@ public function getTaskResultPage(int $taskId): TemplateResponse {
* @return DataResponse
*/
#[NoAdminRequired]
public function runTask(string $type, string $input, string $appId, string $identifier): DataResponse {
public function runTextProcessingTask(string $type, string $input, string $appId, string $identifier): DataResponse {
try {
$task = $this->assistantService->runTextProcessingTask($type, $input, $appId, $this->userId, $identifier);
} catch (\Exception | \Throwable $e) {
Expand All @@ -78,7 +78,7 @@ public function runTask(string $type, string $input, string $appId, string $iden
* @return DataResponse
*/
#[NoAdminRequired]
public function runOrScheduleTask(string $type, string $input, string $appId, string $identifier): DataResponse {
public function runOrScheduleTextProcessingTask(string $type, string $input, string $appId, string $identifier): DataResponse {
try {
$task = $this->assistantService->runOrScheduleTextProcessingTask($type, $input, $appId, $this->userId, $identifier);
} catch (\Exception | \Throwable $e) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function prepare(INotification $notification, string $languageCode): INot
? $l->t('Task for "%1$s" has finished', [$schedulingAppName])
: $l->t('"%1$s" task for "%2$s" has finished', [$taskTypeName, $schedulingAppName]);
$content = $l->t('Input: %1$s', [$params['input']]);
$link = $params['target'] ?? $this->url->linkToRouteAbsolute(Application::APP_ID . '.assistant.getTaskResultPage', ['taskId' => $params['id']]);
$link = $params['target'] ?? $this->url->linkToRouteAbsolute(Application::APP_ID . '.assistant.getTextProcessingTaskResultPage', ['taskId' => $params['id']]);
$iconUrl = $this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.svg'));

$notification
Expand All @@ -114,7 +114,7 @@ public function prepare(INotification $notification, string $languageCode): INot
? $l->t('Task for "%1$s" has failed', [$schedulingAppName])
: $l->t('"%1$s" task for "%2$s" has failed', [$taskTypeName, $schedulingAppName]);
$content = $l->t('Input: %1$s', [$params['input']]);
$link = $params['target'] ?? $this->url->linkToRouteAbsolute(Application::APP_ID . '.assistant.getTaskResultPage', ['taskId' => $params['id']]);
$link = $params['target'] ?? $this->url->linkToRouteAbsolute(Application::APP_ID . '.assistant.getTextProcessingTaskResultPage', ['taskId' => $params['id']]);
$iconUrl = $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/error.svg'));

$notification
Expand Down

0 comments on commit ad8dd89

Please # to comment.