mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-18 10:33:11 +02:00
Better test messages
This commit is contained in:
parent
488aeb119b
commit
3f978bc45f
7 changed files with 60 additions and 12 deletions
web/src/app
|
@ -26,14 +26,24 @@ class Api {
|
|||
return messages;
|
||||
}
|
||||
|
||||
async publish(baseUrl, topic, message) {
|
||||
async publish(baseUrl, topic, message, title, priority, tags) {
|
||||
const user = await userManager.get(baseUrl);
|
||||
const url = topicUrl(baseUrl, topic);
|
||||
console.log(`[Api] Publishing message to ${url}`);
|
||||
const headers = {};
|
||||
if (title) {
|
||||
headers["X-Title"] = title;
|
||||
}
|
||||
if (priority !== 3) {
|
||||
headers["X-Priority"] = `${priority}`;
|
||||
}
|
||||
if (tags.length > 0) {
|
||||
headers["X-Tags"] = tags.join(",");
|
||||
}
|
||||
await fetch(url, {
|
||||
method: 'PUT',
|
||||
body: message,
|
||||
headers: maybeWithBasicAuth({}, user)
|
||||
headers: maybeWithBasicAuth(headers, user)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue