2020-03-28 10:07:41 +01:00
|
|
|
import $ from 'cafy';
|
2021-08-19 14:55:45 +02:00
|
|
|
import define from '../../define';
|
|
|
|
import { createNotification } from '@/services/create-notification';
|
2020-03-28 10:07:41 +01:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['notifications'],
|
|
|
|
|
|
|
|
requireCredential: true as const,
|
|
|
|
|
|
|
|
kind: 'write:notifications',
|
|
|
|
|
|
|
|
params: {
|
|
|
|
body: {
|
2021-12-09 15:58:30 +01:00
|
|
|
validator: $.str,
|
2020-03-28 10:07:41 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
header: {
|
2021-12-09 15:58:30 +01:00
|
|
|
validator: $.optional.nullable.str,
|
2020-03-28 10:07:41 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
icon: {
|
2021-12-09 15:58:30 +01:00
|
|
|
validator: $.optional.nullable.str,
|
2020-03-28 10:07:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
errors: {
|
2021-12-09 15:58:30 +01:00
|
|
|
},
|
2020-03-28 10:07:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default define(meta, async (ps, user, token) => {
|
|
|
|
createNotification(user.id, 'app', {
|
2020-03-29 03:49:43 +02:00
|
|
|
appAccessTokenId: token ? token.id : null,
|
2020-03-28 10:07:41 +01:00
|
|
|
customBody: ps.body,
|
|
|
|
customHeader: ps.header,
|
|
|
|
customIcon: ps.icon,
|
|
|
|
});
|
|
|
|
});
|