renderWebPushNotification: fix account without display_name

This commit is contained in:
Alex Gleason 2024-10-15 17:16:53 -05:00
parent 7fbda4a56b
commit bfe2c620e6
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -33,20 +33,22 @@ type MastodonNotification = NonNullable<Awaited<ReturnType<typeof renderNotifica
function renderTitle(notification: MastodonNotification): string { function renderTitle(notification: MastodonNotification): string {
const { account } = notification; const { account } = notification;
const name = account.display_name || account.username;
switch (notification.type) { switch (notification.type) {
case 'ditto:name_grant': case 'ditto:name_grant':
return `You were granted the name ${notification.name}`; return `You were granted the name ${notification.name}`;
case 'ditto:zap': case 'ditto:zap':
return `${account.display_name} zapped you ${notification.amount} sats`; return `${name} zapped you ${notification.amount} sats`;
case 'pleroma:emoji_reaction': case 'pleroma:emoji_reaction':
return `${account.display_name} reacted to your post`; return `${name} reacted to your post`;
case 'favourite': case 'favourite':
return `${account.display_name} liked your post`; return `${name} liked your post`;
case 'mention': case 'mention':
return `${account.display_name} mentioned you`; return `${name} mentioned you`;
case 'reblog': case 'reblog':
return `${account.display_name} reposted your post`; return `${name} reposted your post`;
default: default:
return account.display_name || account.username; return name;
} }
} }