From 7fe0abc5cec71759807a41f383606dd156f11d88 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 17:45:23 +0900 Subject: [PATCH] Implement #745 --- CHANGELOG.md | 1 + src/api/stream/home.ts | 10 ++++++++++ src/web/app/common/scripts/home-stream.js | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a362dbef..cc5a6bc8a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ChangeLog (Release Notes) unreleased ---------- * New: 投稿のピン留め (#746) +* New: ホームストリームにメッセージを流すことでlast_used_atを更新できるようにする (#745) * その他細かな修正 2508 (2017/08/30) diff --git a/src/api/stream/home.ts b/src/api/stream/home.ts index 2ab8d3025b..d5fe01c261 100644 --- a/src/api/stream/home.ts +++ b/src/api/stream/home.ts @@ -2,6 +2,7 @@ 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'; const log = debug('misskey'); @@ -35,6 +36,15 @@ export default function homeStream(request: websocket.request, connection: webso 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 'capture': if (!msg.id) return; const postId = msg.id; diff --git a/src/web/app/common/scripts/home-stream.js b/src/web/app/common/scripts/home-stream.js index c54cbd7f19..de9ceb3b51 100644 --- a/src/web/app/common/scripts/home-stream.js +++ b/src/web/app/common/scripts/home-stream.js @@ -12,6 +12,11 @@ class Connection extends Stream { i: me.token }); + // 最終利用日時を更新するため定期的にaliveメッセージを送信 + setInterval(() => { + this.send({ type: 'alive' }); + }, 1000 * 60); + this.on('i_updated', me.update); this.on('my_token_regenerated', () => {