Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions library.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ plugin.addRoutes = async ({ router, middleware, helpers }) => {
const { subscription } = req.body;
const payload = await constructPayload({
nid: utils.generateUUID(),
bodyShort: 'Test notification',
bodyLong: 'This is a test message sent from NodeBB',
bodyShort: '[[web-push:test.title]]',
bodyLong: '[[web-push:test.body]]',
path: `/me/web-push`,
}, req.uid, userLang);
await webPush.sendNotification(subscription, JSON.stringify(payload));
Expand All @@ -116,7 +116,7 @@ plugin.addAdminNavigation = (header) => {
header.plugins.push({
route: '/plugins/web-push',
icon: 'fa-tint',
name: 'Push Notifications (via Push API)',
name: '[[web-push:admin.menu-label]]',
});

return header;
Expand Down
19 changes: 17 additions & 2 deletions public/languages/en-GB/web-push.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,20 @@
"profile.send-test": "Send Test Notification",

"toast.test_success": "Test notification sent.",
"toast.test_unavailable": "Cannot send test notification as push notifications are not enabled on this device."
}
"toast.test_unavailable": "Cannot send test notification as push notifications are not enabled on this device.",

"test.title": "Test notification",
"test.body": "This is a test message sent from NodeBB",

"admin.menu-label": "Push Notifications (via Push API)",
"admin.settings": "Settings",
"admin.max-length": "Maximum length",
"admin.max-length-help": "Additional characters beyond this specified length will be truncated. Due to a software limitation, if the message body is greater than 4096 bytes, the message itself will be an attachment in the push notification.",
"admin.badge": "Badge URL",
"admin.badge-help": "Optional — overrides the badge for messages sent (usually seen in the notification bar on mobile devices). By default, the site's configured \"touch icon\" is sent.",
"admin.icon": "Icon URL",
"admin.icon-help": "Optional — overrides the icon for messages sent (can be used for branding, etc.). By default, the site's configured \"touch icon\" is sent.",
"admin.users": "Users",
"admin.user": "User",
"admin.devices": "Devices"
}
26 changes: 26 additions & 0 deletions public/languages/he/web-push.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"profile.label": "התראות דחיפה",
"profile.introduction": "בנוסף להתראות בתוך האפליקציה ולהתראות בדוא״ל, ניתן לבחור לקבל גם התראות דחיפה. כך תוכלו לקבל התראות גם כשהאפליקציה אינה פתוחה במכשיר.",
"profile.option": "הפעלת התראות דחיפה במכשיר זה",
"profile.devices": "כרגע נשלחות התראות ל־ <strong>%1</strong> מכשיר(ים).",
"profile.permissionBlocked": "המכשיר שלך אינו מאפשר כרגע לקבל התראות מאתר זה. יש לאשר את הרשאת ההתראות כדי להמשיך.",
"profile.send-test": "שליחת התראת בדיקה",

"toast.test_success": "התראת הבדיקה נשלחה.",
"toast.test_unavailable": "לא ניתן לשלוח התראת בדיקה כי התראות דחיפה אינן מופעלות במכשיר זה.",

"test.title": "התראת בדיקה",
"test.body": "זוהי הודעת בדיקה שנשלחה מ־NodeBB",

"admin.menu-label": "התראות דחיפה (Push API)",
"admin.settings": "הגדרות",
"admin.max-length": "אורך מרבי",
"admin.max-length-help": "תווים מעבר לאורך שצוין ייחתכו. בשל מגבלת תוכנה, אם גוף ההודעה גדול מ־4096 בתים, ההודעה עצמה תישלח כקובץ מצורף בהתראת הדחיפה.",
"admin.badge": "כתובת תג (Badge)",
"admin.badge-help": "אופציונלי — מחליף את התג בהודעות הנשלחות (מוצג בדרך כלל בשורת ההתראות במכשירים ניידים). כברירת מחדל נשלח סמל ה־touch icon המוגדר באתר.",
"admin.icon": "כתובת סמל (Icon)",
"admin.icon-help": "אופציונלי — מחליף את הסמל בהודעות הנשלחות (שימושי למיתוג וכדומה). כברירת מחדל נשלח סמל ה־touch icon המוגדר באתר.",
"admin.users": "משתמשים",
"admin.user": "משתמש",
"admin.devices": "מכשירים"
}
19 changes: 17 additions & 2 deletions public/languages/zh-CN/web-push.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,20 @@
"profile.send-test": "发送测试通知",

"toast.test_success": "测试通知已发送。",
"toast.test_unavailable": "由于此设备未启用推送通知,因此无法发送测试通知。"
}
"toast.test_unavailable": "由于此设备未启用推送通知,因此无法发送测试通知。",

"test.title": "测试通知",
"test.body": "这是一条来自 NodeBB 的测试消息",

"admin.menu-label": "推送通知(Push API)",
"admin.settings": "设置",
"admin.max-length": "最大长度",
"admin.max-length-help": "超出指定长度的字符将被截断。由于软件限制,如果消息正文超过 4096 字节,消息本身将作为附件随推送通知发送。",
"admin.badge": "徽章 URL",
"admin.badge-help": "可选 — 覆盖所发送消息的徽章(通常显示在移动设备的通知栏中)。默认发送站点配置的"touch icon"。",
"admin.icon": "图标 URL",
"admin.icon-help": "可选 — 覆盖所发送消息的图标(可用于品牌宣传等)。默认发送站点配置的"touch icon"。",
"admin.users": "用户",
"admin.user": "用户",
"admin.devices": "设备"
}
35 changes: 13 additions & 22 deletions templates/admin/plugins/web-push.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,35 @@
<div id="spy-container" class="col-12 col-md-8 px-0 mb-4" tabindex="0">
<form role="form" class="web-push-settings">
<div class="mb-4">
<h5 class="fw-bold tracking-tight settings-header">Settings</h5>
<h5 class="fw-bold tracking-tight settings-header">[[web-push:admin.settings]]</h5>

<div class="mb-3">
<label class="form-label" for="maxLength">Maximum length</label>
<input type="number" min="0" max="4096" id="maxLength" name="maxLength" title="Maximum message length" class="form-control" placeholder="256">
<p class="form-text">
Additional characters beyond this specified length will be truncated.
Due to a software limitation, if the message body is greater than 4096 bytes, the message itself will be an attachment in the push notification.
</p>
<label class="form-label" for="maxLength">[[web-push:admin.max-length]]</label>
<input type="number" min="0" max="4096" id="maxLength" name="maxLength" title="[[web-push:admin.max-length]]" class="form-control" placeholder="256">
<p class="form-text">[[web-push:admin.max-length-help]]</p>
</div>

<div class="mb-3">
<label class="form-label" for="badge">Badge URL</label>
<input type="text" id="badge" name="badge" title="Badge" class="form-control" placeholder="https://...">
<p class="form-text">
Optional — overrides the badge for messages sent (usually seen in the notification bar on mobile devices)
By default, the site's configured "touch icon" is sent.
</p>
<label class="form-label" for="badge">[[web-push:admin.badge]]</label>
<input type="text" id="badge" name="badge" title="[[web-push:admin.badge]]" class="form-control" placeholder="https://...">
<p class="form-text">[[web-push:admin.badge-help]]</p>
</div>

<div class="mb-3">
<label class="form-label" for="icon">Icon URL</label>
<input type="text" id="icon" name="icon" title="Icon" class="form-control" placeholder="https://...">
<p class="form-text">
Optional — overrides the icon for messages sent (can be used for branding, etc.)
By default, the site's configured "touch icon" is sent.
</p>
<label class="form-label" for="icon">[[web-push:admin.icon]]</label>
<input type="text" id="icon" name="icon" title="[[web-push:admin.icon]]" class="form-control" placeholder="https://...">
<p class="form-text">[[web-push:admin.icon-help]]</p>
</div>
</div>
</form>

<div class="mb-4">
<h5 class="fw-bold tracking-tight settings-header">Users</h5>
<h5 class="fw-bold tracking-tight settings-header">[[web-push:admin.users]]</h5>
<table class="table">
<thead>
<tr>
<th>User</th>
<th>Devices</th>
<th>[[web-push:admin.user]]</th>
<th>[[web-push:admin.devices]]</th>
</tr>
</thead>
<tbody>
Expand Down