diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2018-04-11 20:27:09 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-11 20:27:09 +0900 |
| commit | d43fe853c3605696e2e57e240845d0fc9c284f61 (patch) | |
| tree | 838914e262c0fca5737588a7bba64e2b9f3d8e5f /src/api/stream | |
| parent | Update README.md (diff) | |
| parent | wip #1443 (diff) | |
| download | misskey-d43fe853c3605696e2e57e240845d0fc9c284f61.tar.gz misskey-d43fe853c3605696e2e57e240845d0fc9c284f61.tar.bz2 misskey-d43fe853c3605696e2e57e240845d0fc9c284f61.zip | |
Merge pull request #1 from syuilo/master
追従
Diffstat (limited to 'src/api/stream')
| -rw-r--r-- | src/api/stream/channel.ts | 12 | ||||
| -rw-r--r-- | src/api/stream/drive.ts | 10 | ||||
| -rw-r--r-- | src/api/stream/home.ts | 62 | ||||
| -rw-r--r-- | src/api/stream/messaging-index.ts | 10 | ||||
| -rw-r--r-- | src/api/stream/messaging.ts | 24 | ||||
| -rw-r--r-- | src/api/stream/requests.ts | 19 | ||||
| -rw-r--r-- | src/api/stream/server.ts | 19 |
7 files changed, 0 insertions, 156 deletions
diff --git a/src/api/stream/channel.ts b/src/api/stream/channel.ts deleted file mode 100644 index d67d77cbf4..0000000000 --- a/src/api/stream/channel.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as websocket from 'websocket'; -import * as redis from 'redis'; - -export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient): void { - const channel = request.resourceURL.query.channel; - - // Subscribe channel stream - subscriber.subscribe(`misskey:channel-stream:${channel}`); - subscriber.on('message', (_, data) => { - connection.send(data); - }); -} diff --git a/src/api/stream/drive.ts b/src/api/stream/drive.ts deleted file mode 100644 index c97ab80dcc..0000000000 --- a/src/api/stream/drive.ts +++ /dev/null @@ -1,10 +0,0 @@ -import * as websocket from 'websocket'; -import * as redis from 'redis'; - -export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void { - // Subscribe drive stream - subscriber.subscribe(`misskey:drive-stream:${user._id}`); - subscriber.on('message', (_, data) => { - connection.send(data); - }); -} diff --git a/src/api/stream/home.ts b/src/api/stream/home.ts deleted file mode 100644 index 7c8f3bfec8..0000000000 --- a/src/api/stream/home.ts +++ /dev/null @@ -1,62 +0,0 @@ -import * as websocket from 'websocket'; -import * as redis from 'redis'; -import * as debug from 'debug'; - -import User from '../models/user'; -import serializePost from '../serializers/post'; -import readNotification from '../common/read-notification'; - -const log = debug('misskey'); - -export default function homeStream(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void { - // Subscribe Home stream channel - subscriber.subscribe(`misskey:user-stream:${user._id}`); - - subscriber.on('message', async (channel, data) => { - switch (channel.split(':')[1]) { - case 'user-stream': - connection.send(data); - break; - case 'post-stream': - const postId = channel.split(':')[2]; - log(`RECEIVED: ${postId} ${data} by @${user.username}`); - const post = await serializePost(postId, user, { - detail: true - }); - connection.send(JSON.stringify({ - type: 'post-updated', - body: { - post: post - } - })); - break; - } - }); - - connection.on('message', data => { - const msg = JSON.parse(data.utf8Data); - - switch (msg.type) { - case 'alive': - // Update lastUsedAt - User.update({ _id: user._id }, { - $set: { - last_used_at: new Date() - } - }); - break; - - case 'read_notification': - if (!msg.id) return; - readNotification(user._id, msg.id); - break; - - case 'capture': - if (!msg.id) return; - const postId = msg.id; - log(`CAPTURE: ${postId} by @${user.username}`); - subscriber.subscribe(`misskey:post-stream:${postId}`); - break; - } - }); -} diff --git a/src/api/stream/messaging-index.ts b/src/api/stream/messaging-index.ts deleted file mode 100644 index c1b2fbc806..0000000000 --- a/src/api/stream/messaging-index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import * as websocket from 'websocket'; -import * as redis from 'redis'; - -export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void { - // Subscribe messaging index stream - subscriber.subscribe(`misskey:messaging-index-stream:${user._id}`); - subscriber.on('message', (_, data) => { - connection.send(data); - }); -} diff --git a/src/api/stream/messaging.ts b/src/api/stream/messaging.ts deleted file mode 100644 index 3f505cfafa..0000000000 --- a/src/api/stream/messaging.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as websocket from 'websocket'; -import * as redis from 'redis'; -import read from '../common/read-messaging-message'; - -export default function messagingStream(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void { - const otherparty = request.resourceURL.query.otherparty; - - // Subscribe messaging stream - subscriber.subscribe(`misskey:messaging-stream:${user._id}-${otherparty}`); - subscriber.on('message', (_, data) => { - connection.send(data); - }); - - connection.on('message', async (data) => { - const msg = JSON.parse(data.utf8Data); - - switch (msg.type) { - case 'read': - if (!msg.id) return; - read(user._id, otherparty, msg.id); - break; - } - }); -} diff --git a/src/api/stream/requests.ts b/src/api/stream/requests.ts deleted file mode 100644 index 2c36e58b6e..0000000000 --- a/src/api/stream/requests.ts +++ /dev/null @@ -1,19 +0,0 @@ -import * as websocket from 'websocket'; -import Xev from 'xev'; - -const ev = new Xev(); - -export default function homeStream(request: websocket.request, connection: websocket.connection): void { - const onRequest = request => { - connection.send(JSON.stringify({ - type: 'request', - body: request - })); - }; - - ev.addListener('request', onRequest); - - connection.on('close', () => { - ev.removeListener('request', onRequest); - }); -} diff --git a/src/api/stream/server.ts b/src/api/stream/server.ts deleted file mode 100644 index 0db6643d40..0000000000 --- a/src/api/stream/server.ts +++ /dev/null @@ -1,19 +0,0 @@ -import * as websocket from 'websocket'; -import Xev from 'xev'; - -const ev = new Xev(); - -export default function homeStream(request: websocket.request, connection: websocket.connection): void { - const onStats = stats => { - connection.send(JSON.stringify({ - type: 'stats', - body: stats - })); - }; - - ev.addListener('stats', onStats); - - connection.on('close', () => { - ev.removeListener('stats', onStats); - }); -} |