summaryrefslogtreecommitdiff
path: root/src/server/api/stream
diff options
context:
space:
mode:
authorrinsuki <428rinsuki+git@gmail.com>2018-05-17 07:52:24 +0900
committerrinsuki <428rinsuki+git@gmail.com>2018-05-17 07:52:24 +0900
commit829b4012e6dc14eb64a3d8f60826fe9b6a41b40d (patch)
tree42ac37f323db349dca9316e6fdb39fc33b860686 /src/server/api/stream
parentadd yarn.lock to gitignore (diff)
parentUpdate deliver.ts (diff)
downloadmisskey-829b4012e6dc14eb64a3d8f60826fe9b6a41b40d.tar.gz
misskey-829b4012e6dc14eb64a3d8f60826fe9b6a41b40d.tar.bz2
misskey-829b4012e6dc14eb64a3d8f60826fe9b6a41b40d.zip
Merge branch 'master' into fix/yarn-lock-ignore
Diffstat (limited to 'src/server/api/stream')
-rw-r--r--src/server/api/stream/home.ts14
-rw-r--r--src/server/api/stream/user-list.ts14
2 files changed, 22 insertions, 6 deletions
diff --git a/src/server/api/stream/home.ts b/src/server/api/stream/home.ts
index a9d6ff241e..54fde2d776 100644
--- a/src/server/api/stream/home.ts
+++ b/src/server/api/stream/home.ts
@@ -32,17 +32,17 @@ export default async function(
//#region 流れてきたメッセージがミュートしているユーザーが関わるものだったら無視する
if (x.type == 'note') {
- if (mutedUserIds.indexOf(x.body.userId) != -1) {
+ if (mutedUserIds.includes(x.body.userId)) {
return;
}
- if (x.body.reply != null && mutedUserIds.indexOf(x.body.reply.userId) != -1) {
+ if (x.body.reply != null && mutedUserIds.includes(x.body.reply.userId)) {
return;
}
- if (x.body.renote != null && mutedUserIds.indexOf(x.body.renote.userId) != -1) {
+ if (x.body.renote != null && mutedUserIds.includes(x.body.renote.userId)) {
return;
}
} else if (x.type == 'notification') {
- if (mutedUserIds.indexOf(x.body.userId) != -1) {
+ if (mutedUserIds.includes(x.body.userId)) {
return;
}
}
@@ -53,6 +53,7 @@ export default async function(
connection.send(data);
}
break;
+
case 'note-stream':
const noteId = channel.split(':')[2];
log(`RECEIVED: ${noteId} ${data} by @${user.username}`);
@@ -69,12 +70,13 @@ export default async function(
}
});
- connection.on('message', data => {
+ connection.on('message', async data => {
const msg = JSON.parse(data.utf8Data);
switch (msg.type) {
case 'api':
- call(msg.endpoint, user, app, msg.data).then(res => {
+ // 新鮮なデータを利用するためにユーザーをフェッチ
+ call(msg.endpoint, await User.findOne({ _id: user._id }), app, msg.data).then(res => {
connection.send(JSON.stringify({
type: `api-res:${msg.id}`,
body: { res }
diff --git a/src/server/api/stream/user-list.ts b/src/server/api/stream/user-list.ts
new file mode 100644
index 0000000000..ba03b97860
--- /dev/null
+++ b/src/server/api/stream/user-list.ts
@@ -0,0 +1,14 @@
+import * as websocket from 'websocket';
+import * as redis from 'redis';
+import { ParsedUrlQuery } from 'querystring';
+
+export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {
+ const q = request.resourceURL.query as ParsedUrlQuery;
+ const listId = q.listId as string;
+
+ // Subscribe stream
+ subscriber.subscribe(`misskey:user-list-stream:${listId}`);
+ subscriber.on('message', (_, data) => {
+ connection.send(data);
+ });
+}