2023-01-13 05:40:33 +01:00
|
|
|
import { publishMainStream } from "@/services/stream.js";
|
|
|
|
import { pushNotification } from "@/services/push-notification.js";
|
|
|
|
import { Notifications } from "@/models/index.js";
|
|
|
|
import define from "../../define.js";
|
2017-10-30 14:12:10 +01:00
|
|
|
|
2018-07-16 21:36:44 +02:00
|
|
|
export const meta = {
|
2023-01-13 05:40:33 +01:00
|
|
|
tags: ["notifications", "account"],
|
2019-02-23 03:20:58 +01:00
|
|
|
|
2022-01-18 14:27:10 +01:00
|
|
|
requireCredential: true,
|
2018-07-16 21:36:44 +02:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
kind: "write:notifications",
|
2022-01-18 14:27:10 +01:00
|
|
|
} as const;
|
2018-07-16 21:36:44 +02:00
|
|
|
|
2022-02-20 05:15:40 +01:00
|
|
|
export const paramDef = {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "object",
|
2022-02-19 06:05:32 +01:00
|
|
|
properties: {},
|
|
|
|
required: [],
|
|
|
|
} as const;
|
|
|
|
|
2023-01-13 05:54:33 +01:00
|
|
|
|
2022-02-19 06:05:32 +01:00
|
|
|
export default define(meta, paramDef, async (ps, user) => {
|
2017-10-30 14:12:10 +01:00
|
|
|
// Update documents
|
2023-01-13 05:40:33 +01:00
|
|
|
await Notifications.update(
|
|
|
|
{
|
|
|
|
notifieeId: user.id,
|
|
|
|
isRead: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
isRead: true,
|
|
|
|
},
|
|
|
|
);
|
2018-05-28 18:22:39 +02:00
|
|
|
|
2017-10-30 14:12:10 +01:00
|
|
|
// 全ての通知を読みましたよというイベントを発行
|
2023-01-13 05:40:33 +01:00
|
|
|
publishMainStream(user.id, "readAllNotifications");
|
|
|
|
pushNotification(user.id, "readAllNotifications", undefined);
|
2019-02-22 03:46:58 +01:00
|
|
|
});
|