summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-05-26 12:35:14 +0900
committerGitHub <noreply@github.com>2018-05-26 12:35:14 +0900
commitbc9487822529b260fbdc9a8dcca35c3da25db04e (patch)
treed5fd0dffb95e03b95df8e98692305d75f855e645 /src/server
parentNew translations ja.yml (Portuguese) (diff)
parentMerge pull request #1649 from l2dy/i18n (diff)
downloadmisskey-bc9487822529b260fbdc9a8dcca35c3da25db04e.tar.gz
misskey-bc9487822529b260fbdc9a8dcca35c3da25db04e.tar.bz2
misskey-bc9487822529b260fbdc9a8dcca35c3da25db04e.zip
Merge branch 'master' into l10n_master
Diffstat (limited to 'src/server')
-rw-r--r--src/server/api/common/read-notification.ts9
-rw-r--r--src/server/api/endpoints.ts2
-rw-r--r--src/server/api/endpoints/drive/files/create.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/notes/conversation.ts (renamed from src/server/api/endpoints/notes/context.ts)15
-rw-r--r--src/server/api/endpoints/notifications/get_unread_count.ts3
-rw-r--r--src/server/file/send-drive-file.ts11
-rw-r--r--src/server/index.ts6
-rw-r--r--src/server/web/index.ts4
11 files changed, 50 insertions, 26 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.ts b/src/server/api/endpoints.ts
index 7647c76d3d..892da3540f 100644
--- a/src/server/api/endpoints.ts
+++ b/src/server/api/endpoints.ts
@@ -482,7 +482,7 @@ const endpoints: Endpoint[] = [
name: 'notes/replies'
},
{
- name: 'notes/context'
+ name: 'notes/conversation'
},
{
name: 'notes/create',
diff --git a/src/server/api/endpoints/drive/files/create.ts b/src/server/api/endpoints/drive/files/create.ts
index e9348e4e2f..dd748d6bba 100644
--- a/src/server/api/endpoints/drive/files/create.ts
+++ b/src/server/api/endpoints/drive/files/create.ts
@@ -1,6 +1,7 @@
/**
* Module dependencies
*/
+import * as fs from 'fs';
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import { validateFileName, pack } from '../../../../../models/drive-file';
import create from '../../../../../services/drive/add-file';
@@ -32,15 +33,23 @@ module.exports = async (file, params, user): Promise<any> => {
const [folderId = null, folderIdErr] = $.type(ID).optional().nullable().get(params.folderId);
if (folderIdErr) throw 'invalid folderId param';
+ function cleanup() {
+ fs.unlink(file.path, () => {});
+ }
+
try {
// Create file
const driveFile = await create(user, file.path, name, null, folderId);
+ cleanup();
+
// Serialize
return pack(driveFile);
} catch (e) {
console.error(e);
+ cleanup();
+
throw e;
}
};
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/notes/context.ts b/src/server/api/endpoints/notes/conversation.ts
index 1cd27250e2..02f7229ccf 100644
--- a/src/server/api/endpoints/notes/context.ts
+++ b/src/server/api/endpoints/notes/conversation.ts
@@ -5,11 +5,7 @@ import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note, { pack } from '../../../../models/note';
/**
- * Show a context of a note
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
+ * Show conversation of a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
@@ -33,7 +29,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
return rej('note not found');
}
- const context = [];
+ const conversation = [];
let i = 0;
async function get(id) {
@@ -41,10 +37,10 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
const p = await Note.findOne({ _id: id });
if (i > offset) {
- context.push(p);
+ conversation.push(p);
}
- if (context.length == limit) {
+ if (conversation.length == limit) {
return;
}
@@ -58,6 +54,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Serialize
- res(await Promise.all(context.map(async note =>
- await pack(note, user))));
+ res(await Promise.all(conversation.map(note => pack(note, user))));
});
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/file/send-drive-file.ts b/src/server/file/send-drive-file.ts
index d613a3aa5f..e04400317f 100644
--- a/src/server/file/send-drive-file.ts
+++ b/src/server/file/send-drive-file.ts
@@ -33,11 +33,12 @@ export default async function(ctx: Koa.Context) {
if (file.metadata.deletedAt) {
ctx.status = 410;
- if (file.metadata.isExpired) {
- await send(ctx, '/cache-expired.png', { root: assets });
- } else {
- await send(ctx, '/tombstone.png', { root: assets });
- }
+ await send(ctx, '/tombstone.png', { root: assets });
+ return;
+ }
+
+ if (file.metadata.isMetaOnly) {
+ ctx.status = 204;
return;
}
diff --git a/src/server/index.ts b/src/server/index.ts
index ded8f7706e..fc3d252e10 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -4,8 +4,7 @@
import * as fs from 'fs';
import * as http from 'http';
-import * as https from 'https';
-//import * as http2 from 'http2';
+import * as http2 from 'http2';
import * as zlib from 'zlib';
import * as Koa from 'koa';
import * as Router from 'koa-router';
@@ -68,8 +67,7 @@ function createServer() {
certs[k] = fs.readFileSync(config.https[k]);
});
certs['allowHTTP1'] = true;
- //return http2.createSecureServer(certs, app.callback());
- return https.createServer(certs, app.callback());
+ return http2.createSecureServer(certs, app.callback());
} else {
return http.createServer(app.callback());
}
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'),