Merge branch 'develop' into notification-read-api
This commit is contained in:
commit
da8263a4ac
1715 changed files with 20804 additions and 11752 deletions
|
|
@ -0,0 +1,37 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../define';
|
||||
import { createNotification } from '@/services/create-notification';
|
||||
|
||||
export const meta = {
|
||||
tags: ['notifications'],
|
||||
|
||||
requireCredential: true as const,
|
||||
|
||||
kind: 'write:notifications',
|
||||
|
||||
params: {
|
||||
body: {
|
||||
validator: $.str
|
||||
},
|
||||
|
||||
header: {
|
||||
validator: $.optional.nullable.str
|
||||
},
|
||||
|
||||
icon: {
|
||||
validator: $.optional.nullable.str
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, 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,24 @@
|
|||
import { publishMainStream } from '@/services/stream';
|
||||
import define from '../../define';
|
||||
import { Notifications } from '@/models/index';
|
||||
|
||||
export const meta = {
|
||||
tags: ['notifications', 'account'],
|
||||
|
||||
requireCredential: true as const,
|
||||
|
||||
kind: 'write:notifications'
|
||||
};
|
||||
|
||||
export default define(meta, async (ps, user) => {
|
||||
// Update documents
|
||||
await Notifications.update({
|
||||
notifieeId: user.id,
|
||||
isRead: false,
|
||||
}, {
|
||||
isRead: true
|
||||
});
|
||||
|
||||
// 全ての通知を読みましたよというイベントを発行
|
||||
publishMainStream(user.id, 'readAllNotifications');
|
||||
});
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { readNotification } from '../../common/read-notification';
|
||||
import { ApiError } from '../../error';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
'ja-JP': '通知を既読にします。',
|
||||
'en-US': 'Mark a notification as read.'
|
||||
},
|
||||
|
||||
tags: ['notifications', 'account'],
|
||||
|
||||
requireCredential: true as const,
|
||||
|
||||
kind: 'write:notifications',
|
||||
|
||||
params: {
|
||||
notificationId: {
|
||||
validator: $.optional.type(ID),
|
||||
desc: {
|
||||
'ja-JP': '対象の通知のID',
|
||||
'en-US': 'Target notification ID.'
|
||||
}
|
||||
},
|
||||
|
||||
notificationIds: {
|
||||
validator: $.optional.arr($.type(ID)),
|
||||
desc: {
|
||||
'ja-JP': '対象の通知のIDの配列',
|
||||
'en-US': 'Target notification IDs.'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
errors: {
|
||||
noNotificationRequested: {
|
||||
message: 'You requested no notification.',
|
||||
code: 'NO_NOTIFICATION_REQUESTED',
|
||||
id: '1dee2109-b88b-21cf-3935-607dad60f5b0'
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default define(meta, async (ps, user) => {
|
||||
let notificationIds = [] as string[];
|
||||
|
||||
if (ps.notificationId) notificationIds.push(ps.notificationId);
|
||||
if (ps.notificationIds) notificationIds = notificationIds.concat(ps.notificationIds);
|
||||
|
||||
return readNotification(user.id, notificationIds);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue