fix: members only groups

This commit is contained in:
Timothy Jaeryang Baek
2026-01-12 21:53:41 +04:00
parent 7da37b4f66
commit 5a075a2c83
3 changed files with 16 additions and 9 deletions
+7 -7
View File
@@ -165,15 +165,15 @@ class GroupTable:
share_value = filter["share"] share_value = filter["share"]
member_id = filter.get("member_id") member_id = filter.get("member_id")
json_share = Group.data["config"]["share"] json_share = Group.data["config"]["share"]
json_share_bool = json_share.as_boolean() json_share_lower = func.lower(json_share.as_string())
json_share_str = json_share.as_string()
if share_value: if share_value:
# Groups open to anyone: data is null, share is null, or share is true # Groups open to anyone: data is null, config.share is null, or share is true
# Use case-insensitive string comparison to handle variations like "True", "TRUE"
anyone_can_share = or_( anyone_can_share = or_(
Group.data.is_(None), Group.data.is_(None),
json_share_bool.is_(None), json_share_lower.is_(None),
json_share_bool == True, json_share_lower == "true",
) )
if member_id: if member_id:
@@ -184,7 +184,7 @@ class GroupTable:
.subquery() .subquery()
) )
members_only_and_is_member = and_( members_only_and_is_member = and_(
json_share_str == "members", json_share_lower == "members",
Group.id.in_(member_groups_subq), Group.id.in_(member_groups_subq),
) )
query = query.filter( query = query.filter(
@@ -194,7 +194,7 @@ class GroupTable:
query = query.filter(anyone_can_share) query = query.filter(anyone_can_share)
else: else:
query = query.filter( query = query.filter(
and_(Group.data.isnot(None), json_share_bool == False) and_(Group.data.isnot(None), json_share_lower == "false")
) )
else: else:
@@ -42,7 +42,10 @@
}; };
onMount(async () => { onMount(async () => {
groups = await getGroups(localStorage.token, true); groups = await getGroups(localStorage.token, true).catch((error) => {
console.error(error);
return [];
});
if (accessControl === null) { if (accessControl === null) {
initPublicAccess(); initPublicAccess();
@@ -65,7 +65,11 @@
} }
onMount(async () => { onMount(async () => {
groups = await getGroups(localStorage.token, true); groups = await getGroups(localStorage.token, true).catch((error) => {
console.error(error);
return [];
});
if (userIds.length > 0) { if (userIds.length > 0) {
userIds.forEach(async (id) => { userIds.forEach(async (id) => {
const res = await getUserById(localStorage.token, id).catch((error) => { const res = await getUserById(localStorage.token, id).catch((error) => {