rudeshark.net/src/renderers/get-notification-summary.ts

28 lines
1.2 KiB
TypeScript
Raw Normal View History

2017-11-10 16:27:02 +01:00
import getPostSummary from './get-post-summary';
import getReactionEmoji from './get-reaction-emoji';
/**
*
* @param notification
*/
2017-11-10 17:00:14 +01:00
export default function(notification: any): string {
2017-11-10 16:27:02 +01:00
switch (notification.type) {
case 'follow':
2017-11-10 17:00:14 +01:00
return `${notification.user.name}にフォローされました`;
2017-11-10 16:27:02 +01:00
case 'mention':
2017-11-10 17:15:11 +01:00
return `言及されました:\n${notification.user.name}${getPostSummary(notification.post)}`;
2017-11-10 16:27:02 +01:00
case 'reply':
2017-11-10 17:15:11 +01:00
return `返信されました:\n${notification.user.name}${getPostSummary(notification.post)}`;
2017-11-10 16:27:02 +01:00
case 'repost':
2017-11-10 17:15:11 +01:00
return `Repostされました:\n${notification.user.name}${getPostSummary(notification.post)}`;
2017-11-10 16:27:02 +01:00
case 'quote':
2017-11-10 17:15:11 +01:00
return `引用されました:\n${notification.user.name}${getPostSummary(notification.post)}`;
2017-11-10 16:27:02 +01:00
case 'reaction':
2017-11-10 17:15:11 +01:00
return `リアクションされました:\n${notification.user.name} <${getReactionEmoji(notification.reaction)}>「${getPostSummary(notification.post)}`;
2017-11-10 16:27:02 +01:00
case 'poll_vote':
2017-11-10 17:15:11 +01:00
return `投票されました:\n${notification.user.name}${getPostSummary(notification.post)}`;
2017-11-10 16:27:02 +01:00
default:
return `<不明な通知タイプ: ${notification.type}>`;
}
}