forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 12
/
compose-notification.ts
81 lines (69 loc) · 1.76 KB
/
compose-notification.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import getNoteSummary from '../../../../misc/get-note-summary';
import getReactionEmoji from '../../../../misc/get-reaction-emoji';
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 'unreadMessagingMessage':
return {
title: `New message from ${getUserName(data.user)}`,
body: data.text, // TODO: getMessagingMessageSummary(data),
icon: data.user.avatarUrl
};
case 'reversiInvited':
return {
title: 'Play reversi with me',
body: `You got reversi invitation from ${getUserName(data.parent)}`,
icon: data.parent.avatarUrl
};
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)}: ${getReactionEmoji(data.reaction)}:`,
body: getNoteSummary(data.note),
icon: data.user.avatarUrl
};
case 'highlight':
return {
title: `${getUserName(data.user)}:`,
body: getNoteSummary(data),
icon: data.user.avatarUrl
};
default:
return null;
}
default:
return null;
}
}