summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-09 20:32:41 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-09 20:42:03 +1000
commit9ea8f1cd206999a2215902493f198bf8acc38671 (patch)
tree364a2d0fc8e7407bc915fc62de260e97f433aa33
parentFix typo (diff)
downloadserver-9ea8f1cd206999a2215902493f198bf8acc38671.tar.xz
Use status from UserSettings if presence is 'offline' ( mobile )
-rw-r--r--src/gateway/opcodes/LazyRequest.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gateway/opcodes/LazyRequest.ts b/src/gateway/opcodes/LazyRequest.ts
index 129c9ce3..d6bcb43d 100644
--- a/src/gateway/opcodes/LazyRequest.ts
+++ b/src/gateway/opcodes/LazyRequest.ts
@@ -24,6 +24,7 @@ async function getMembers(guild_id: string, range: [number, number]) {
 		.leftJoinAndSelect("member.roles", "role")
 		.leftJoinAndSelect("member.user", "user")
 		.leftJoinAndSelect("user.sessions", "session")
+		.innerJoinAndSelect("user.settings", "settings")
 		.addSelect("CASE WHEN session.status = 'offline' THEN 0 ELSE 1 END", "_status")
 		.orderBy("role.position", "DESC")
 		.addOrderBy("_status", "DESC")
@@ -67,7 +68,7 @@ async function getMembers(guild_id: string, range: [number, number]) {
 				"idle": 1,
 				"dnd": 2,
 				"invisible": 3,
-				"offline": 4,	// for ts, will never be accessed
+				"offline": 4,
 			};
 			const sessions = member.user.sessions.sort((a, b) => {
 				// activities are higher priority than status
@@ -76,6 +77,11 @@ async function getMembers(guild_id: string, range: [number, number]) {
 			});
 			const session = sessions.first();
 
+			if (session?.status == "offline") {
+				// swap out for user settings status
+				session.status = member.user.settings.status;
+			}
+
 			const item = {
 				member: {
 					...member,