Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { createNotification } from "../../../../services/create-notification.js";
|
||||
import define from "../../define.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"notifications"
|
||||
],
|
||||
requireCredential: true,
|
||||
kind: "write:notifications",
|
||||
errors: {}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
body: {
|
||||
type: "string"
|
||||
},
|
||||
header: {
|
||||
type: "string",
|
||||
nullable: true
|
||||
},
|
||||
icon: {
|
||||
type: "string",
|
||||
nullable: true
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"body"
|
||||
]
|
||||
};
|
||||
export default define(meta, paramDef, async (ps, user, token)=>{
|
||||
createNotification(user.id, "app", {
|
||||
appAccessTokenId: token ? token.id : null,
|
||||
customBody: ps.body,
|
||||
customHeader: ps.header,
|
||||
customIcon: ps.icon
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { publishMainStream } from "../../../../services/stream.js";
|
||||
import { pushNotification } from "../../../../services/push-notification.js";
|
||||
import { Notifications } from "../../../../models/index.js";
|
||||
import define from "../../define.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"notifications",
|
||||
"account"
|
||||
],
|
||||
requireCredential: true,
|
||||
kind: "write:notifications"
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {},
|
||||
required: []
|
||||
};
|
||||
export default define(meta, paramDef, async (ps, user)=>{
|
||||
// Update documents
|
||||
await Notifications.update({
|
||||
notifieeId: user.id,
|
||||
isRead: false
|
||||
}, {
|
||||
isRead: true
|
||||
});
|
||||
// 全ての通知を読みましたよというイベントを発行
|
||||
publishMainStream(user.id, "readAllNotifications");
|
||||
pushNotification(user.id, "readAllNotifications", undefined);
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
import define from "../../define.js";
|
||||
import { readNotification } from "../../common/read-notification.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"notifications",
|
||||
"account"
|
||||
],
|
||||
requireCredential: true,
|
||||
kind: "write:notifications",
|
||||
description: "Mark a notification as read.",
|
||||
errors: {
|
||||
noSuchNotification: {
|
||||
message: "No such notification.",
|
||||
code: "NO_SUCH_NOTIFICATION",
|
||||
id: "efa929d5-05b5-47d1-beec-e6a4dbed011e"
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
oneOf: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
notificationId: {
|
||||
type: "string",
|
||||
format: "misskey:id"
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"notificationId"
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
notificationIds: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
format: "misskey:id"
|
||||
},
|
||||
maxItems: 100
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"notificationIds"
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
export default define(meta, paramDef, async (ps, user)=>{
|
||||
if ("notificationId" in ps) return readNotification(user.id, [
|
||||
ps.notificationId
|
||||
]);
|
||||
return readNotification(user.id, ps.notificationIds);
|
||||
});
|
||||
Reference in New Issue
Block a user