fix: 🐛 service worker notification badges
BIN
packages/backend/assets/notification-badges/boost.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 889 B After Width: | Height: | Size: 889 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
packages/backend/assets/notification-badges/reaction.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 798 B |
@ -222,6 +222,12 @@ export type Notification = {
|
|||||||
userId: User["id"];
|
userId: User["id"];
|
||||||
note: Note;
|
note: Note;
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: "pollEnded";
|
||||||
|
user: User;
|
||||||
|
userId: User["id"];
|
||||||
|
note: Note;
|
||||||
|
}
|
||||||
| {
|
| {
|
||||||
type: "follow";
|
type: "follow";
|
||||||
user: User;
|
user: User;
|
||||||
|
@ -19,11 +19,11 @@ const closeNotificationsByTags = async (tags: string[]): Promise<void> => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const iconUrl = (name: BadgeNames): string =>
|
const iconUrl = (name: BadgeNames): string =>
|
||||||
`/static-assets/tabler-badges/${name}.png`;
|
`/static-assets/notification-badges/${name}.png`;
|
||||||
/* How to add a new badge:
|
/* How to add a new badge:
|
||||||
* 1. Find the icon and download png from https://tabler-icons.io/
|
* 1. Find the icon from https://phosphoricons.com/
|
||||||
* 2. vips resize ~/Downloads/icon-name.png vipswork.png 0.4; vips scRGB2BW vipswork.png ~/icon-name.png"[compression=9,strip]"; rm vipswork.png;
|
* 2. Choose #000000 as the color, 96px as the size, and bold as the weight
|
||||||
* 3. mv ~/icon-name.png ~/misskey/packages/backend/assets/tabler-badges/
|
* 3. Move icon-name.png to packages/backend/assets/notification-badges/
|
||||||
* 4. Add 'icon-name' to BadgeNames
|
* 4. Add 'icon-name' to BadgeNames
|
||||||
* 5. Add `badge: iconUrl('icon-name'),`
|
* 5. Add `badge: iconUrl('icon-name'),`
|
||||||
*/
|
*/
|
||||||
@ -131,7 +131,7 @@ async function composeNotification(
|
|||||||
{
|
{
|
||||||
body: data.body.note.text || "",
|
body: data.body.note.text || "",
|
||||||
icon: data.body.user.avatarUrl,
|
icon: data.body.user.avatarUrl,
|
||||||
badge: iconUrl("retweet"),
|
badge: iconUrl("boost"),
|
||||||
data,
|
data,
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
@ -150,7 +150,7 @@ async function composeNotification(
|
|||||||
{
|
{
|
||||||
body: data.body.note.text || "",
|
body: data.body.note.text || "",
|
||||||
icon: data.body.user.avatarUrl,
|
icon: data.body.user.avatarUrl,
|
||||||
badge: iconUrl("quote-right"),
|
badge: iconUrl("quote"),
|
||||||
data,
|
data,
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
@ -182,8 +182,7 @@ async function composeNotification(
|
|||||||
badge = badgeUrl.href;
|
badge = badgeUrl.href;
|
||||||
reaction = name.split("@")[0];
|
reaction = name.split("@")[0];
|
||||||
} else {
|
} else {
|
||||||
// Unicode絵文字の場合
|
badge = iconUrl("reaction");
|
||||||
badge = `/twemoji-badge/${char2fileName(reaction)}.png`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -219,7 +218,7 @@ async function composeNotification(
|
|||||||
{
|
{
|
||||||
body: data.body.note.text || "",
|
body: data.body.note.text || "",
|
||||||
icon: data.body.user.avatarUrl,
|
icon: data.body.user.avatarUrl,
|
||||||
badge: iconUrl("poll-h"),
|
badge: iconUrl("poll"),
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -229,7 +228,7 @@ async function composeNotification(
|
|||||||
t("_notification.pollEnded"),
|
t("_notification.pollEnded"),
|
||||||
{
|
{
|
||||||
body: data.body.note.text || "",
|
body: data.body.note.text || "",
|
||||||
badge: iconUrl("clipboard-check-solid"),
|
badge: iconUrl("clipboard-check"),
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -273,7 +272,7 @@ async function composeNotification(
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
body: data.body.invitation.group.name,
|
body: data.body.invitation.group.name,
|
||||||
badge: iconUrl("id-card-alt"),
|
badge: iconUrl("id-card"),
|
||||||
data,
|
data,
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
|
@ -37,15 +37,17 @@ export type PushNotificationDataMap = {
|
|||||||
|
|
||||||
export type BadgeNames =
|
export type BadgeNames =
|
||||||
| "null"
|
| "null"
|
||||||
| "antenna"
|
|
||||||
| "arrow-back-up"
|
|
||||||
| "at"
|
| "at"
|
||||||
| "chart-arrows"
|
| "boost"
|
||||||
| "circle-check"
|
| "check"
|
||||||
| "medal"
|
| "clipboard-check"
|
||||||
|
| "clock"
|
||||||
|
| "comments"
|
||||||
|
| "id-card"
|
||||||
| "messages"
|
| "messages"
|
||||||
| "plus"
|
| "plus"
|
||||||
|
| "poll"
|
||||||
| "quote"
|
| "quote"
|
||||||
| "repeat"
|
| "reaction"
|
||||||
| "user-plus"
|
| "reply"
|
||||||
| "users";
|
| "user-plus";
|
||||||
|