refactor: code readability
This commit is contained in:
parent
a5242fa64a
commit
d535f02536
2 changed files with 13 additions and 7 deletions
|
|
@ -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>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue