diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 0dacaa6929..a3d516b631 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1709,6 +1709,7 @@ _notification: app: "連携アプリからの通知" _actions: + followBack: "フォローバック" reply: "返信" renote: "Renote" diff --git a/src/client/sw/create-notification.ts b/src/client/sw/create-notification.ts index 6803348f3b..77d3460ce5 100644 --- a/src/client/sw/create-notification.ts +++ b/src/client/sw/create-notification.ts @@ -36,10 +36,20 @@ async function composeNotification(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': diff --git a/src/client/sw/sw.ts b/src/client/sw/sw.ts index abb2b20683..162502959f 100644 --- a/src/client/sw/sw.ts +++ b/src/client/sw/sw.ts @@ -108,6 +108,9 @@ self.addEventListener('notificationclick',