summaryrefslogtreecommitdiff
path: root/src/web/app/desktop/scripts/stream.js
blob: 383b55207544016b66caf8f794bb01c264e2b948 (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
const stream = require('../../common/scripts/stream');
const getPostSummary = require('../../common/scripts/get-post-summary');

module.exports = me => {
	const s = stream(me);

	s.event.on('drive_file_created', file => {
		const n = new Notification('ファイルがアップロードされました', {
			body: file.name,
			icon: file.url + '?thumbnail&size=64'
		});
		setTimeout(n.close.bind(n), 5000);
	});

	s.event.on('mention', post => {
		const n = new Notification(post.user.name + "さんから:", {
			body: getPostSummary(post),
			icon: post.user.avatar_url + '?thumbnail&size=64'
		});
		setTimeout(n.close.bind(n), 6000);
	});

	s.event.on('reply', post => {
		const n = new Notification(post.user.name + "さんから返信:", {
			body: getPostSummary(post),
			icon: post.user.avatar_url + '?thumbnail&size=64'
		});
		setTimeout(n.close.bind(n), 6000);
	});

	s.event.on('quote', post => {
		const n = new Notification(post.user.name + "さんが引用:", {
			body: getPostSummary(post),
			icon: post.user.avatar_url + '?thumbnail&size=64'
		});
		setTimeout(n.close.bind(n), 6000);
	});

	return s;
};