From f6154dc0af1a0d65819e87240f4385f9573095cb Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 30 Jan 2020 04:37:25 +0900 Subject: v12 (#5712) Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com> Co-authored-by: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com> --- src/client/scripts/compose-notification.ts | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/client/scripts/compose-notification.ts (limited to 'src/client/scripts/compose-notification.ts') diff --git a/src/client/scripts/compose-notification.ts b/src/client/scripts/compose-notification.ts new file mode 100644 index 0000000000..bf32552506 --- /dev/null +++ b/src/client/scripts/compose-notification.ts @@ -0,0 +1,59 @@ +import getNoteSummary from '../../misc/get-note-summary'; +import getUserName from '../../misc/get-user-name'; + +type Notification = { + title: string; + body: string; + icon: string; + onclick?: any; +}; + +// TODO: i18n + +export default function(type, data): Notification { + switch (type) { + case 'driveFileCreated': + return { + title: 'File uploaded', + body: data.name, + icon: data.url + }; + + case 'notification': + switch (data.type) { + case 'mention': + return { + title: `${getUserName(data.user)}:`, + body: getNoteSummary(data), + icon: data.user.avatarUrl + }; + + case 'reply': + return { + title: `You got reply from ${getUserName(data.user)}:`, + body: getNoteSummary(data), + icon: data.user.avatarUrl + }; + + case 'quote': + return { + title: `${getUserName(data.user)}:`, + body: getNoteSummary(data), + icon: data.user.avatarUrl + }; + + case 'reaction': + return { + title: `${getUserName(data.user)}: ${data.reaction}:`, + body: getNoteSummary(data.note), + icon: data.user.avatarUrl + }; + + default: + return null; + } + + default: + return null; + } +} -- cgit v1.2.3-freya