mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-28 12:03:08 +02:00
リアクションもServiceWorkerで通知するように
This commit is contained in:
parent
78609f5edd
commit
182612d540
2 changed files with 17 additions and 1 deletions
|
@ -7,7 +7,9 @@ import Post from '../../../models/post';
|
|||
import Watching from '../../../models/post-watching';
|
||||
import notify from '../../../common/notify';
|
||||
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
|
||||
|
@ -87,6 +89,12 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
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
|
||||
Watching
|
||||
.find({
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import getPostSummary from '../../../../common/get-post-summary';
|
||||
import getReactionEmoji from '../../../../common/get-reaction-emoji';
|
||||
|
||||
type Notification = {
|
||||
title: string;
|
||||
|
@ -39,6 +40,13 @@ export default function(type, data): Notification {
|
|||
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':
|
||||
return {
|
||||
title: `${data.user.name}さんからメッセージ:`,
|
||||
|
|
Loading…
Reference in a new issue