refac
This commit is contained in:
1 parent
c5ec01b1f9
commit
a41faa3c22
2 files changed
+12
-9
No files matched your search
@@ -9,6 +9,7 @@ from open_webui.models.access_grants import (
|
||||
AccessGrants,
|
||||
)
|
||||
from open_webui.models.groups import Groups
|
||||
from open_webui.models.users import User
|
||||
from open_webui.utils.validate import validate_profile_image_url
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
from sqlalchemy import (
|
||||
@@ -437,17 +438,17 @@ class ChannelTable:
|
||||
|
||||
match_count = func.sum(
|
||||
case(
|
||||
(ChannelMember.user_id.in_(unique_user_ids), 1),
|
||||
(User.id.in_(unique_user_ids), 1),
|
||||
else_=0,
|
||||
)
|
||||
)
|
||||
|
||||
subquery = (
|
||||
select(ChannelMember.channel_id)
|
||||
.join(User, User.id == ChannelMember.user_id)
|
||||
.group_by(ChannelMember.channel_id)
|
||||
# 1. Channel must have exactly len(user_ids) members
|
||||
.having(func.count(ChannelMember.user_id) == len(unique_user_ids))
|
||||
# 2. All those members must be in unique_user_ids
|
||||
# Match the exact set of accounts that still exist.
|
||||
.having(func.count(User.id) == len(unique_user_ids))
|
||||
.having(match_count == len(unique_user_ids))
|
||||
.subquery()
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user