Files
nc_bot_webhooks/lib/Settings/Admin.php
T
kyle 6453715bf0 fix: update TalkService for Talk 14 compatibility and add CLI copy helper
- **TalkService**:
  - Refactored `ensureBotParticipants` to use `AttendeeMapper` directly, removing the dependency on `ParticipantService`.
  - Added `getBotDisplayNameForRoom` to resolve the bot's display name via direct DB query.
  - Updated `sendMessage` to use Chat API v1 and include `richObjectsEnd`.
  - Improved `getBaseUrl` logic to handle `overwritehost` and `overwritewebroot`.
- **WebhookController**:
  - Fixed `getAllValues` to iterate known keys manually, preventing `RuntimeException` in Nextcloud 33.
  - Added error handling for `saveConfig`.
  - Removed unused `ParticipantService` import.
- **js/settings.js**:
  - Added functionality to copy CLI commands to the clipboard.
- **Deletions**:
  - Removed `lib/Command/AddBotParticipant.php` as its logic is now integrated into `TalkService`.
- **Templates**:
  - Updated admin settings labels and comments.
2026-06-12 14:32:52 -07:00

75 lines
3.4 KiB
PHP

<?php
namespace OCA\NCdiscordhook\Settings;
use OCA\NCdiscordhook\Service\TalkService;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\Settings\ISettings;
class Admin implements ISettings {
private TalkService $talkService;
private IL10N $l10n;
public function __construct(TalkService $talkService, IL10N $l10n) {
$this->talkService = $talkService;
$this->l10n = $l10n;
}
public function getForm(): TemplateResponse {
\OCP\Util::addStyle('ncdiscordhook', 'adminSettings');
\OCP\Util::addScript('ncdiscordhook', 'settings');
$params = [
'hasBotPassword' => $this->talkService->hasBotPassword(),
'retentionDays' => $this->talkService->getRetentionDays(),
'rooms' => $this->talkService->getRooms(),
'authTokens' => $this->talkService->getAuthTokens(),
'configuredRooms' => $this->talkService->getRooms(),
'serverUrl' => $this->talkService->getBaseUrl(),
'senderName' => $this->talkService->getSenderNameDefault(),
// CLI commands for setup (user copies these to their server)
'l10n' => [
'fetch_rooms' => $this->l10n->t('Fetch Rooms'),
'error_fetching' => $this->l10n->t('Error fetching rooms'),
'save_config' => $this->l10n->t('Save Configuration'),
'config_saved' => $this->l10n->t('Configuration saved'),
'save_failed' => $this->l10n->t('Configuration save failed'),
'generate_token' => $this->l10n->t('Generate Token'),
'revoke_token' => $this->l10n->t('Revoke'),
'no_rooms' => $this->l10n->t('No rooms found'),
'no_rooms_msg' => $this->l10n->t('No Talk rooms are available or you don\'t have permission to view them.'),
'bot_password' => $this->l10n->t('Bot App Password'),
'bot_password_desc' => $this->l10n->t('App password for the "talk-bot" user. Create one in Settings → talk-bot → Devices & sessions.'),
'sender_name' => $this->l10n->t('Default Sender Name'),
'sender_name_desc' => $this->l10n->t('Name used when posting messages as the bot.'),
'image_retention' => $this->l10n->t('Image Retention (days)'),
'image_retention_desc' => $this->l10n->t('How long to keep uploaded images before cleanup.'),
'room_selection' => $this->l10n->t('Room Selection'),
'room_selection_desc' => $this->l10n->t('Select which Talk rooms should accept webhooks. Enable the bot for a room by checking it.'),
'auth_tokens' => $this->l10n->t('Auth Tokens'),
'auth_tokens_desc' => $this->l10n->t('Auth tokens for this room. Used to validate incoming webhook requests.'),
'no_password' => $this->l10n->t('Enter bot password to enable configuration.'),
],
];
$response = new TemplateResponse('ncdiscordhook', 'adminSettings', $params);
return $response;
}
public function getPriority(): int {
return 10;
}
public function getSection(): string {
return 'additional';
}
public function getIcons(): array {
$urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);
return [
$urlGenerator->imagePath('ncdiscordhook', 'app.svg'),
];
}
}