Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9bf0041
Inbox mail table
lumburovskalina Nov 6, 2025
b3f8d91
Create and get requests for inbox mail
lumburovskalina Nov 6, 2025
5afff30
merge
LennartSchmidtKern Nov 11, 2025
6628359
new model
LennartSchmidtKern Nov 12, 2025
7809311
mail collection by threads
LennartSchmidtKern Nov 12, 2025
3640ac3
enums inboxmail reference
LennartSchmidtKern Nov 13, 2025
1f96ec8
restructure return inbox mails
LennartSchmidtKern Nov 13, 2025
3f79d9a
is admin notificaiton
LennartSchmidtKern Nov 13, 2025
10009c4
Merge branch 'inbox-mail' of github.com:code-kern-ai/refinery-submodu…
LennartSchmidtKern Nov 13, 2025
b9997e1
create admin notification
LennartSchmidtKern Nov 13, 2025
c9991de
Merge branch 'inbox-mail' of github.com:code-kern-ai/refinery-submodu…
LennartSchmidtKern Nov 13, 2025
721f939
kratos
LennartSchmidtKern Nov 13, 2025
ba02c8f
Merge branch 'inbox-mail' of github.com:code-kern-ai/refinery-submodu…
LennartSchmidtKern Nov 13, 2025
38647f6
inbox mail threads
LennartSchmidtKern Nov 17, 2025
a817046
fix warning subquery
LennartSchmidtKern Nov 17, 2025
a90d2c8
is in progress inbox mail thread
LennartSchmidtKern Nov 17, 2025
de62400
update progress
LennartSchmidtKern Nov 17, 2025
e4e444a
unread mail count
LennartSchmidtKern Nov 17, 2025
6a7b6e4
Merge branch 'inbox-mail' of github.com:code-kern-ai/refinery-submodu…
LennartSchmidtKern Nov 17, 2025
2aed3c1
unread mails
LennartSchmidtKern Nov 18, 2025
b186fc8
remove kratos
LennartSchmidtKern Nov 18, 2025
b12d922
remove org filter
LennartSchmidtKern Nov 19, 2025
ccf656a
inbox mail support progress state
LennartSchmidtKern Nov 19, 2025
e34f80a
merge
LennartSchmidtKern Nov 19, 2025
93d4978
clear prints
LennartSchmidtKern Nov 20, 2025
97af92d
Merge branch 'inbox-mail' of github.com:code-kern-ai/refinery-submodu…
LennartSchmidtKern Nov 20, 2025
f661b82
extend
LennartSchmidtKern Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions business_objects/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ def get_user_cached_if_not_admin(user_id: str) -> Optional[User]:
return user


# TODO use new roles form kratos
def get_admin_users() -> List[User]:
kernai_admins = (
session.query(User)
.filter(User.email.ilike("%@kern.ai"), User.verified == True)
.all()
)

query = """
SELECT email FROM global.full_admin_access
"""

result = general.execute_all(query)
full_admin_emails = [row[0].lower() for row in result] if result else []

if full_admin_emails:
full_admins = (
session.query(User).filter(User.email.in_(full_admin_emails)).all()
)
else:
full_admins = []

admin_users = {user.id: user for user in kernai_admins + full_admins}
return list(admin_users.values())


@TTLCacheDecorator(CacheEnum.USER, 5, "user_id")
def get_user_cached(user_id: str) -> User:
user = get(user_id)
Expand All @@ -52,6 +78,23 @@ def get_all(
return query.all()


def get_all_users_by_users_team(user_id: str) -> List[User]:
if not user_id:
return []
teams_subquery = (
session.query(TeamMember.team_id)
.filter(TeamMember.user_id == user_id)
.subquery()
)
query = (
session.query(User)
.join(TeamMember, TeamMember.user_id == User.id)
.filter(TeamMember.team_id.in_(teams_subquery))
.distinct(User.id)
)
return query.all()


def get_all_team_members_by_project(project_id: str) -> List[User]:
query = (
session.query(TeamMember)
Expand Down
10 changes: 10 additions & 0 deletions enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ class Tablenames(Enum):
TIMED_EXECUTIONS = "timed_executions"
CONVERSATION_SHARE = "conversation_share"
CONVERSATION_GLOBAL_SHARE = "conversation_global_share"
INBOX_MAIL = "inbox_mail"
INBOX_MAIL_THREAD = "inbox_mail_thread"
INBOX_MAIL_THREAD_ASSOCIATION = "inbox_mail_thread_association"

def snake_case_to_pascal_case(self):
# the type name (written in PascalCase) of a table is needed to create backrefs
Expand Down Expand Up @@ -1025,3 +1028,10 @@ class MessageType(Enum):

class TimedExecutionKey(Enum):
LAST_RESET_USER_MESSAGE_COUNT = "LAST_RESET_USER_MESSAGE_COUNT"


class InboxMailThreadSupportProgressState(Enum):
PENDING = "PENDING"
IN_PROGRESS = "IN_PROGRESS"
RESOLVED = "RESOLVED"
FAILED = "FAILED"
Loading