From aa4ef6745ad798bd7d4f05cb397ef1dd85279814 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 7 Jul 2018 19:19:00 +0900 Subject: Refactorng --- src/misc/get-notification-summary.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/misc/get-notification-summary.ts (limited to 'src/misc/get-notification-summary.ts') diff --git a/src/misc/get-notification-summary.ts b/src/misc/get-notification-summary.ts new file mode 100644 index 0000000000..71d4973ce9 --- /dev/null +++ b/src/misc/get-notification-summary.ts @@ -0,0 +1,28 @@ +import getUserName from './get-user-name'; +import getNoteSummary from './get-note-summary'; +import getReactionEmoji from './get-reaction-emoji'; + +/** + * 通知を表す文字列を取得します。 + * @param notification 通知 + */ +export default function(notification: any): string { + switch (notification.type) { + case 'follow': + return `${getUserName(notification.user)}にフォローされました`; + case 'mention': + return `言及されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`; + case 'reply': + return `返信されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`; + case 'renote': + return `Renoteされました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`; + case 'quote': + return `引用されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`; + case 'reaction': + return `リアクションされました:\n${getUserName(notification.user)} <${getReactionEmoji(notification.reaction)}>「${getNoteSummary(notification.note)}」`; + case 'poll_vote': + return `投票されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`; + default: + return `<不明な通知タイプ: ${notification.type}>`; + } +} -- cgit v1.2.3-freya