summaryrefslogtreecommitdiff
path: root/src/client/app/common/scripts/compose-notification.ts
blob: ebc15952f69a6c0f9b50aa39eaaebb0cedf160c7 (plain)
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
import getPostSummary from '../../../../renderers/get-post-summary';
import getReactionEmoji from '../../../../renderers/get-reaction-emoji';

type Notification = {
	title: string;
	body: string;
	icon: string;
	onclick?: any;
};

// TODO: i18n

export default function(type, data): Notification {
	switch (type) {
		case 'drive_file_created':
			return {
				title: 'ファイルがアップロードされました',
				body: data.name,
				icon: data.url + '?thumbnail&size=64'
			};

		case 'mention':
			return {
				title: `${data.user.name}さんから:`,
				body: getPostSummary(data),
				icon: data.user.avatarUrl + '?thumbnail&size=64'
			};

		case 'reply':
			return {
				title: `${data.user.name}さんから返信:`,
				body: getPostSummary(data),
				icon: data.user.avatarUrl + '?thumbnail&size=64'
			};

		case 'quote':
			return {
				title: `${data.user.name}さんが引用:`,
				body: getPostSummary(data),
				icon: data.user.avatarUrl + '?thumbnail&size=64'
			};

		case 'reaction':
			return {
				title: `${data.user.name}: ${getReactionEmoji(data.reaction)}:`,
				body: getPostSummary(data.post),
				icon: data.user.avatarUrl + '?thumbnail&size=64'
			};

		case 'unread_messaging_message':
			return {
				title: `${data.user.name}さんからメッセージ:`,
				body: data.text, // TODO: getMessagingMessageSummary(data),
				icon: data.user.avatarUrl + '?thumbnail&size=64'
			};

		case 'othello_invited':
			return {
				title: '対局への招待があります',
				body: `${data.parent.name}さんから`,
				icon: data.parent.avatarUrl + '?thumbnail&size=64'
			};

		default:
			return null;
	}
}