summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-09 20:53:09 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-09 20:53:09 +1000
commitefb514038ba0d7388adb9e3b2ff4bc7ed829b6ca (patch)
tree5f25945602a16256b07ba2f685dcd7bc5e6bbd73
parentSend user settings on PATCH users/@me/settings (diff)
downloadserver-efb514038ba0d7388adb9e3b2ff4bc7ed829b6ca.tar.xz
Use UserSettings.status when presence is "offline"
-rw-r--r--gateway/src/opcodes/LazyRequest.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts
index 3b42b4f3..b0332969 100644
--- a/gateway/src/opcodes/LazyRequest.ts
+++ b/gateway/src/opcodes/LazyRequest.ts
@@ -26,6 +26,7 @@ async function getMembers(guild_id: string, range: [number, number]) {
 			.leftJoinAndSelect("member.roles", "role")
 			.leftJoinAndSelect("member.user", "user")
 			.leftJoinAndSelect("user.sessions", "session")
+			.addSelect("user.settings")
 			.addSelect(
 				"CASE WHEN session.status = 'offline' THEN 0 ELSE 1 END",
 				"_status"
@@ -83,7 +84,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,
 			};
 			// sort sessions by relevance
 			const sessions = member.user.sessions.sort((a, b) => {
@@ -91,6 +92,10 @@ async function getMembers(guild_id: string, range: [number, number]) {
 			});
 			var session: Session | undefined = sessions.first();
 
+			if (session?.status == "offline") {
+				session.status = member.user.settings.status || "online";
+			}
+
 			const item = {
 				member: {
 					...member,
@@ -104,7 +109,7 @@ async function getMembers(guild_id: string, range: [number, number]) {
 				},
 			};
 
-			if (!session || session.status == "invisible") {
+			if (!session || session.status == "invisible" || session.status == "offline") {
 				item.member.presence.status = "offline";
 				offlineItems.push(item);
 				group.count--;