mizzkey/src/server/api/endpoints/notifications/create.ts

38 lines
639 B
TypeScript
Raw Normal View History

2020-03-28 10:07:41 +01:00
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.id,
customBody: ps.body,
customHeader: ps.header,
customIcon: ps.icon,
});
});