Skip to content
Snippets Groups Projects
Commit 182612d5 authored by syuilo's avatar syuilo
Browse files

リアクションもServiceWorkerで通知するように

parent 78609f5e
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,9 @@ import Post from '../../../models/post'; ...@@ -7,7 +7,9 @@ import Post from '../../../models/post';
import Watching from '../../../models/post-watching'; import Watching from '../../../models/post-watching';
import notify from '../../../common/notify'; import notify from '../../../common/notify';
import watch from '../../../common/watch-post'; import watch from '../../../common/watch-post';
import { publishPostStream } from '../../../event'; import { publishPostStream, pushSw } from '../../../event';
import serializePost from '../../../serializers/post';
import serializeUser from '../../../serializers/user';
/** /**
* React to a post * React to a post
...@@ -87,6 +89,12 @@ module.exports = (params, user) => new Promise(async (res, rej) => { ...@@ -87,6 +89,12 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
reaction: reaction reaction: reaction
}); });
pushSw(post.user_id, 'reaction', {
user: await serializeUser(user, post.user_id),
post: await serializePost(post, post.user_id),
reaction: reaction
});
// Fetch watchers // Fetch watchers
Watching Watching
.find({ .find({
......
import getPostSummary from '../../../../common/get-post-summary'; import getPostSummary from '../../../../common/get-post-summary';
import getReactionEmoji from '../../../../common/get-reaction-emoji';
type Notification = { type Notification = {
title: string; title: string;
...@@ -39,6 +40,13 @@ export default function(type, data): Notification { ...@@ -39,6 +40,13 @@ export default function(type, data): Notification {
icon: data.user.avatar_url + '?thumbnail&size=64' icon: data.user.avatar_url + '?thumbnail&size=64'
}; };
case 'reaction':
return {
title: `${data.user.name}: ${getReactionEmoji(data.reaction)}:`,
body: getPostSummary(data.post),
icon: data.user.avatar_url + '?thumbnail&size=64'
};
case 'unread_messaging_message': case 'unread_messaging_message':
return { return {
title: `${data.user.name}さんからメッセージ:`, title: `${data.user.name}さんからメッセージ:`,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment