mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-19 19:13:13 +02:00
Use attachment URL for image & add timestamp
This commit is contained in:
parent
f3db0e083e
commit
a8db08c7d4
2 changed files with 13 additions and 2 deletions
web/src/app
|
@ -17,13 +17,17 @@ class Notifier {
|
|||
const displayName = topicDisplayName(subscription);
|
||||
const message = formatMessage(notification);
|
||||
const title = formatTitleWithDefault(notification, displayName);
|
||||
const image = notification.attachment?.name.match(/\.(png|jpe?g|gif|webp)$/i) ? notification.attachment.url : undefined;
|
||||
|
||||
// Show notification
|
||||
console.log(`[Notifier, ${shortUrl}] Displaying notification ${notification.id}: ${message}`);
|
||||
// Please update sw.js if formatting changes
|
||||
const n = new Notification(title, {
|
||||
body: message,
|
||||
tag: subscription.id,
|
||||
icon: logo,
|
||||
icon: image ?? logo,
|
||||
image,
|
||||
timestamp: message.time * 1_000,
|
||||
});
|
||||
if (notification.click) {
|
||||
n.onclick = () => openUrl(notification.click);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue