* Update notifications.ts

* Update notifications.ts

* Update notifications.ts

* Update notifications.ts

* Add missing semicolon

* Improve readability

* Fix typo
This commit is contained in:
syuilo 2019-01-08 13:32:28 +09:00 committed by GitHub
parent 6c4ea5e087
commit 35e7dca2bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,16 @@ export const meta = {
markAsRead: {
validator: $.bool.optional,
default: true
},
includeTypes: {
validator: $.arr($.str.or(['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'poll_vote', 'receiveFollowRequest'])).optional,
default: [] as string[]
},
excludeTypes: {
validator: $.arr($.str.or(['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'poll_vote', 'receiveFollowRequest'])).optional,
default: [] as string[]
}
}
};
@ -89,6 +99,16 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
};
}
if (ps.includeTypes.length > 0) {
query.type = {
$in: ps.includeTypes
};
} else if (ps.excludeTypes.length > 0) {
query.type = {
$nin: ps.excludeTypes
};
}
const notifications = await Notification
.find(query, {
limit: ps.limit,