aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/UserManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/ApiManagers/UserManager.ts')
-rw-r--r--src/server/ApiManagers/UserManager.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/server/ApiManagers/UserManager.ts b/src/server/ApiManagers/UserManager.ts
index f36506b14..fe80c6a7c 100644
--- a/src/server/ApiManagers/UserManager.ts
+++ b/src/server/ApiManagers/UserManager.ts
@@ -4,6 +4,7 @@ import { Database } from "../database";
import { msToTime } from "../ActionUtilities";
import * as bcrypt from "bcrypt-nodejs";
import { Opt } from "../../fields/Doc";
+import { WebSocket } from "../websocket";
export const timeMap: { [id: string]: number } = {};
interface ActivityUnit {
@@ -131,9 +132,12 @@ export default class UserManager extends ApiManager {
for (const user in timeMap) {
const time = timeMap[user];
- const duration = now - time;
- const target = (duration / 1000) < (60 * 5) ? activeTimes : inactiveTimes;
- target.push({ user, duration });
+ const socketPair = Array.from(WebSocket.socketMap).find(pair => pair[1] === user);
+ if (socketPair && !socketPair[0].disconnected) {
+ const duration = now - time;
+ const target = (duration / 1000) < (60 * 5) ? activeTimes : inactiveTimes;
+ target.push({ user, duration });
+ }
}
const process = (target: { user: string, duration: number }[]) => {