summaryrefslogtreecommitdiff
path: root/src/web/app/common/scripts/compose-notification.ts
blob: 181dca734f33b7b9efc0cf05ee2e84f111296917 (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
import getPostSummary from '../../../../common/get-post-summary';

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.avatar_url + '?thumbnail&size=64'
			};

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

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

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

		default:
			return null;
	}
}