diff options
| author | ha-dai <contact@haradai.net> | 2017-11-02 13:58:47 +0900 |
|---|---|---|
| committer | ha-dai <contact@haradai.net> | 2017-11-02 13:58:47 +0900 |
| commit | 4e83106853e1da2ff7f5b3dabe23c3791c25f289 (patch) | |
| tree | 1fb73d608bfe65ad9274477fc2b99822d36bf76f /src/api/endpoints/notifications/get_unread_count.ts | |
| parent | Merge branch 'master' of https://github.com/syuilo/misskey (diff) | |
| parent | Refactor (diff) | |
| download | misskey-4e83106853e1da2ff7f5b3dabe23c3791c25f289.tar.gz misskey-4e83106853e1da2ff7f5b3dabe23c3791c25f289.tar.bz2 misskey-4e83106853e1da2ff7f5b3dabe23c3791c25f289.zip | |
Merge branch 'master' of https://github.com/syuilo/misskey
Diffstat (limited to 'src/api/endpoints/notifications/get_unread_count.ts')
| -rw-r--r-- | src/api/endpoints/notifications/get_unread_count.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/api/endpoints/notifications/get_unread_count.ts b/src/api/endpoints/notifications/get_unread_count.ts new file mode 100644 index 0000000000..9514e78713 --- /dev/null +++ b/src/api/endpoints/notifications/get_unread_count.ts @@ -0,0 +1,23 @@ +/** + * Module dependencies + */ +import Notification from '../../models/notification'; + +/** + * Get count of unread notifications + * + * @param {any} params + * @param {any} user + * @return {Promise<any>} + */ +module.exports = (params, user) => new Promise(async (res, rej) => { + const count = await Notification + .count({ + notifiee_id: user._id, + is_read: false + }); + + res({ + count: count + }); +}); |