summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/api/common/read-notification.ts9
-rw-r--r--src/server/api/endpoints/i/notifications.ts3
-rw-r--r--src/server/api/endpoints/i/update.ts6
-rw-r--r--src/server/api/endpoints/notes.ts8
-rw-r--r--src/server/api/endpoints/notifications/get_unread_count.ts3
-rw-r--r--src/server/web/index.ts4
6 files changed, 27 insertions, 6 deletions
diff --git a/src/server/api/common/read-notification.ts b/src/server/api/common/read-notification.ts
index 7b9faf4cf4..cdb87a4114 100644
--- a/src/server/api/common/read-notification.ts
+++ b/src/server/api/common/read-notification.ts
@@ -1,6 +1,7 @@
import * as mongo from 'mongodb';
import { default as Notification, INotification } from '../../../models/notification';
import publishUserStream from '../../../publishers/stream';
+import Mute from '../../../models/mute';
/**
* Mark as read notification(s)
@@ -26,6 +27,11 @@ export default (
? [new mongo.ObjectID(message)]
: [(message as INotification)._id];
+ const mute = await Mute.find({
+ muterId: userId
+ });
+ const mutedUserIds = mute.map(m => m.muteeId);
+
// Update documents
await Notification.update({
_id: { $in: ids },
@@ -42,6 +48,9 @@ export default (
const count = await Notification
.count({
notifieeId: userId,
+ notifierId: {
+ $nin: mutedUserIds
+ },
isRead: false
}, {
limit: 1
diff --git a/src/server/api/endpoints/i/notifications.ts b/src/server/api/endpoints/i/notifications.ts
index 50ed9b27e8..ba9c47508c 100644
--- a/src/server/api/endpoints/i/notifications.ts
+++ b/src/server/api/endpoints/i/notifications.ts
@@ -96,8 +96,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
});
// Serialize
- res(await Promise.all(notifications.map(async notification =>
- await pack(notification))));
+ res(await Promise.all(notifications.map(notification => pack(notification))));
// Mark as read all
if (notifications.length > 0 && markAsRead) {
diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts
index b7b25d0f65..6e0c5b8515 100644
--- a/src/server/api/endpoints/i/update.ts
+++ b/src/server/api/endpoints/i/update.ts
@@ -47,6 +47,11 @@ module.exports = async (params, user, app) => new Promise(async (res, rej) => {
if (isBotErr) return rej('invalid isBot param');
if (isBot != null) user.isBot = isBot;
+ // Get 'isCat' parameter
+ const [isCat, isCatErr] = $.bool.optional().get(params.isCat);
+ if (isCatErr) return rej('invalid isCat param');
+ if (isCat != null) user.isCat = isCat;
+
// Get 'autoWatch' parameter
const [autoWatch, autoWatchErr] = $.bool.optional().get(params.autoWatch);
if (autoWatchErr) return rej('invalid autoWatch param');
@@ -82,6 +87,7 @@ module.exports = async (params, user, app) => new Promise(async (res, rej) => {
bannerColor: user.bannerColor,
profile: user.profile,
isBot: user.isBot,
+ isCat: user.isCat,
settings: user.settings
}
});
diff --git a/src/server/api/endpoints/notes.ts b/src/server/api/endpoints/notes.ts
index 4ce7613d70..21946d1bd3 100644
--- a/src/server/api/endpoints/notes.ts
+++ b/src/server/api/endpoints/notes.ts
@@ -8,6 +8,10 @@ import Note, { pack } from '../../../models/note';
* Get all notes
*/
module.exports = (params) => new Promise(async (res, rej) => {
+ // Get 'local' parameter
+ const [local, localErr] = $.bool.optional().get(params.local);
+ if (localErr) return rej('invalid local param');
+
// Get 'reply' parameter
const [reply, replyErr] = $.bool.optional().get(params.reply);
if (replyErr) return rej('invalid reply param');
@@ -61,6 +65,10 @@ module.exports = (params) => new Promise(async (res, rej) => {
};
}
+ if (local) {
+ query['_user.host'] = null;
+ }
+
if (reply != undefined) {
query.replyId = reply ? { $exists: true, $ne: null } : null;
}
diff --git a/src/server/api/endpoints/notifications/get_unread_count.ts b/src/server/api/endpoints/notifications/get_unread_count.ts
index 600a80d194..9766366ff1 100644
--- a/src/server/api/endpoints/notifications/get_unread_count.ts
+++ b/src/server/api/endpoints/notifications/get_unread_count.ts
@@ -9,8 +9,7 @@ import Mute from '../../../../models/mute';
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
const mute = await Mute.find({
- muterId: user._id,
- deletedAt: { $exists: false }
+ muterId: user._id
});
const mutedUserIds = mute.map(m => m.muteeId);
diff --git a/src/server/web/index.ts b/src/server/web/index.ts
index 6ceef17c1c..5ce040d083 100644
--- a/src/server/web/index.ts
+++ b/src/server/web/index.ts
@@ -49,8 +49,8 @@ const router = new Router();
//#region static assets
router.get('/assets/*', async ctx => {
- // 無圧縮スクリプトを用意するのは大変なので一時的に無効化
- const path = process.env.NODE_ENV == 'production' ? ctx.path.replace('raw.js', 'min.js') : ctx.path.replace('min.js', 'raw.js');
+ // 互換性のため
+ const path = ctx.path.replace('.raw.js', '.js').replace('.min.js', '.js');
await send(ctx, path, {
root: client,
maxage: ms('7 days'),