mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 04:32:35 +01:00
Use UserSettings.status when presence is "offline"
This commit is contained in:
parent
b8fed0700b
commit
efb514038b
@ -26,6 +26,7 @@ async function getMembers(guild_id: string, range: [number, number]) {
|
|||||||
.leftJoinAndSelect("member.roles", "role")
|
.leftJoinAndSelect("member.roles", "role")
|
||||||
.leftJoinAndSelect("member.user", "user")
|
.leftJoinAndSelect("member.user", "user")
|
||||||
.leftJoinAndSelect("user.sessions", "session")
|
.leftJoinAndSelect("user.sessions", "session")
|
||||||
|
.addSelect("user.settings")
|
||||||
.addSelect(
|
.addSelect(
|
||||||
"CASE WHEN session.status = 'offline' THEN 0 ELSE 1 END",
|
"CASE WHEN session.status = 'offline' THEN 0 ELSE 1 END",
|
||||||
"_status"
|
"_status"
|
||||||
@ -83,7 +84,7 @@ async function getMembers(guild_id: string, range: [number, number]) {
|
|||||||
"idle": 1,
|
"idle": 1,
|
||||||
"dnd": 2,
|
"dnd": 2,
|
||||||
"invisible": 3,
|
"invisible": 3,
|
||||||
"offline": 4, // for ts, will never be accessed
|
"offline": 4,
|
||||||
};
|
};
|
||||||
// sort sessions by relevance
|
// sort sessions by relevance
|
||||||
const sessions = member.user.sessions.sort((a, b) => {
|
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();
|
var session: Session | undefined = sessions.first();
|
||||||
|
|
||||||
|
if (session?.status == "offline") {
|
||||||
|
session.status = member.user.settings.status || "online";
|
||||||
|
}
|
||||||
|
|
||||||
const item = {
|
const item = {
|
||||||
member: {
|
member: {
|
||||||
...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";
|
item.member.presence.status = "offline";
|
||||||
offlineItems.push(item);
|
offlineItems.push(item);
|
||||||
group.count--;
|
group.count--;
|
||||||
|
Loading…
Reference in New Issue
Block a user