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