Revert "remove follow action"

This reverts commit defbb41648.
This commit is contained in:
tamaina 2021-09-21 03:22:52 +09:00
parent f94919cb9c
commit 9f174bb380
3 changed files with 14 additions and 0 deletions

View File

@ -1709,6 +1709,7 @@ _notification:
app: "連携アプリからの通知"
_actions:
followBack: "フォローバック"
reply: "返信"
renote: "Renote"

View File

@ -36,10 +36,20 @@ async function composeNotification<K extends keyof pushNotificationDataMap>(data
case 'notification':
switch (data.body.type) {
case 'follow':
// users/showの型定義をswos.apiへ当てはめるのが困難なのでapiFetch.requestを直接使用
const account = await getAccountFromId(data.userId);
if (!account) return null;
const userDetail = apiFetch.request('users/show', { userId: data.body.userId }, account.token);
return [t('_notification.youWereFollowed'), {
body: getUserName(data.body.user),
icon: data.body.user.avatarUrl,
data,
actions: userDetail.isFollowing ? [] : [
{
action: 'follow',
title: t('_notification._actions.followBack')
}
],
}];
case 'mention':

View File

@ -108,6 +108,9 @@ self.addEventListener('notificationclick', <K extends keyof pushNotificationData
switch (data.type) {
case 'notification':
switch (action) {
case 'follow':
if ('userId' in data.body) await swos.api('following/create', id, { userId: data.body.userId });
break;
case 'showUser':
if ('user' in data.body) client = await swos.openUser(getAcct(data.body.user), id);
break;