2022-02-27 11:07:39 +09:00
|
|
|
import define from '../../define.js';
|
|
|
|
import { createNotification } from '@/services/create-notification.js';
|
2020-03-28 18:07:41 +09:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['notifications'],
|
|
|
|
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: true,
|
2020-03-28 18:07:41 +09:00
|
|
|
|
|
|
|
kind: 'write:notifications',
|
|
|
|
|
2022-02-19 14:05:32 +09:00
|
|
|
errors: {
|
2020-03-28 18:07:41 +09:00
|
|
|
},
|
2022-02-19 14:05:32 +09:00
|
|
|
} as const;
|
2020-03-28 18:07:41 +09:00
|
|
|
|
2022-02-20 13:15:40 +09:00
|
|
|
export const paramDef = {
|
2022-02-19 14:05:32 +09:00
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
body: { type: 'string' },
|
|
|
|
header: { type: 'string', nullable: true },
|
|
|
|
icon: { type: 'string', nullable: true },
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
2022-02-19 14:05:32 +09:00
|
|
|
required: ['body'],
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2020-03-28 18:07:41 +09:00
|
|
|
|
2022-01-03 02:12:50 +09:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-02-19 14:05:32 +09:00
|
|
|
export default define(meta, paramDef, async (ps, user, token) => {
|
2020-03-28 18:07:41 +09:00
|
|
|
createNotification(user.id, 'app', {
|
2020-03-29 10:49:43 +09:00
|
|
|
appAccessTokenId: token ? token.id : null,
|
2020-03-28 18:07:41 +09:00
|
|
|
customBody: ps.body,
|
|
|
|
customHeader: ps.header,
|
|
|
|
customIcon: ps.icon,
|
|
|
|
});
|
|
|
|
});
|