refactor: code readability

This commit is contained in:
Nicolas Meienberger 2026-01-02 14:23:21 +01:00
parent a5242fa64a
commit d535f02536
2 changed files with 13 additions and 7 deletions

View file

@ -527,7 +527,9 @@ export const CreateNotificationForm = ({ onSubmit, mode = "create", initialValue
<FormControl> <FormControl>
<SecretInput {...field} placeholder="••••••••" /> <SecretInput {...field} placeholder="••••••••" />
</FormControl> </FormControl>
<FormDescription>Access token for server authentication, if required.</FormDescription> <FormDescription>
Access token for server authentication. Will take precedence over username/password if set.
</FormDescription>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}

View file

@ -4,13 +4,17 @@ export function buildNtfyShoutrrrUrl(config: Extract<NotificationConfig, { type:
let shoutrrrUrl: string; let shoutrrrUrl: string;
const params = new URLSearchParams(); const params = new URLSearchParams();
const { username, password, accessToken } = config;
const auth = let auth = "";
config.accessToken
? `:${encodeURIComponent(config.accessToken)}@` if (username && password) {
: config.username && config.password auth = `${encodeURIComponent(username)}:${encodeURIComponent(password)}@`;
? `${encodeURIComponent(config.username)}:${encodeURIComponent(config.password)}@` }
: "";
if (accessToken) {
auth = `:${encodeURIComponent(accessToken)}@`;
}
if (config.serverUrl) { if (config.serverUrl) {
const url = new URL(config.serverUrl); const url = new URL(config.serverUrl);