This commit is contained in:
syuilo
2020-03-28 18:07:41 +09:00
parent 9ea1ed8559
commit 614a1d74dd
21 changed files with 229 additions and 91 deletions

View File

@@ -28,7 +28,9 @@ export const meta = {
}
};
export default define(meta, async (ps, user, isSecure) => {
export default define(meta, async (ps, user, token) => {
const isSecure = token == null;
// Lookup app
const ap = await Apps.findOne(ps.appId);

View File

@@ -78,7 +78,7 @@ export const meta = {
}
};
export default define(meta, async (ps, user, isSecure, file, cleanup) => {
export default define(meta, async (ps, user, _, file, cleanup) => {
// Get 'name' parameter
let name = ps.name || file.originalname;
if (name !== undefined && name !== null) {

View File

@@ -19,7 +19,9 @@ export const meta = {
},
};
export default define(meta, async (ps, user, isSecure) => {
export default define(meta, async (ps, user, token) => {
const isSecure = token == null;
return await Users.pack(user, user, {
detail: true,
includeHasUnreadNotes: true,

View File

@@ -178,7 +178,9 @@ export const meta = {
}
};
export default define(meta, async (ps, user, isSecure) => {
export default define(meta, async (ps, user, token) => {
const isSecure = token == null;
const updates = {} as Partial<User>;
const profileUpdates = {} as Partial<UserProfile>;

View File

@@ -132,7 +132,8 @@ export default define(meta, async (ps, user) => {
});
// Notify
createNotification(note.userId, user.id, 'pollVote', {
createNotification(note.userId, 'pollVote', {
notifierId: user.id,
noteId: note.id,
choice: ps.choice
});
@@ -143,7 +144,8 @@ export default define(meta, async (ps, user) => {
userId: Not(user.id),
}).then(watchers => {
for (const watcher of watchers) {
createNotification(watcher.userId, user.id, 'pollVote', {
createNotification(watcher.userId, 'pollVote', {
notifierId: user.id,
noteId: note.id,
choice: ps.choice
});

View File

@@ -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.id,
customBody: ps.body,
customHeader: ps.header,
customIcon: ps.icon,
});
});

View File

@@ -104,7 +104,8 @@ export default define(meta, async (ps, me) => {
} as UserGroupInvitation);
// 通知を作成
createNotification(user.id, me.id, 'groupInvited', {
createNotification(user.id, 'groupInvited', {
notifierId: me.id,
userGroupInvitationId: invitation.id
});
});