mirror of
https://github.com/open-webui/open-webui
synced 2025-05-18 20:31:36 +00:00
fix: db issues
This commit is contained in:
parent
a7fb560e84
commit
c1d706dc5a
@ -169,7 +169,6 @@ class AuthsTable:
|
|||||||
def update_user_password_by_id(self, id: str, new_password: str) -> bool:
|
def update_user_password_by_id(self, id: str, new_password: str) -> bool:
|
||||||
try:
|
try:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
|
|
||||||
result = (
|
result = (
|
||||||
db.query(Auth).filter_by(id=id).update({"password": new_password})
|
db.query(Auth).filter_by(id=id).update({"password": new_password})
|
||||||
)
|
)
|
||||||
@ -181,7 +180,6 @@ class AuthsTable:
|
|||||||
def update_email_by_id(self, id: str, email: str) -> bool:
|
def update_email_by_id(self, id: str, email: str) -> bool:
|
||||||
try:
|
try:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
|
|
||||||
result = db.query(Auth).filter_by(id=id).update({"email": email})
|
result = db.query(Auth).filter_by(id=id).update({"email": email})
|
||||||
db.commit()
|
db.commit()
|
||||||
return True if result == 1 else False
|
return True if result == 1 else False
|
||||||
|
@ -141,13 +141,14 @@ class ChatTable:
|
|||||||
db.add(shared_result)
|
db.add(shared_result)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(shared_result)
|
db.refresh(shared_result)
|
||||||
|
|
||||||
# Update the original chat with the share_id
|
# Update the original chat with the share_id
|
||||||
result = (
|
result = (
|
||||||
db.query(Chat)
|
db.query(Chat)
|
||||||
.filter_by(id=chat_id)
|
.filter_by(id=chat_id)
|
||||||
.update({"share_id": shared_chat.id})
|
.update({"share_id": shared_chat.id})
|
||||||
)
|
)
|
||||||
|
db.commit()
|
||||||
return shared_chat if (shared_result and result) else None
|
return shared_chat if (shared_result and result) else None
|
||||||
|
|
||||||
def update_shared_chat_by_chat_id(self, chat_id: str) -> Optional[ChatModel]:
|
def update_shared_chat_by_chat_id(self, chat_id: str) -> Optional[ChatModel]:
|
||||||
@ -206,8 +207,8 @@ class ChatTable:
|
|||||||
def archive_all_chats_by_user_id(self, user_id: str) -> bool:
|
def archive_all_chats_by_user_id(self, user_id: str) -> bool:
|
||||||
try:
|
try:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
|
|
||||||
db.query(Chat).filter_by(user_id=user_id).update({"archived": True})
|
db.query(Chat).filter_by(user_id=user_id).update({"archived": True})
|
||||||
|
db.commit()
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
@ -212,6 +212,7 @@ class UsersTable:
|
|||||||
try:
|
try:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
db.query(User).filter_by(id=id).update({"oauth_sub": oauth_sub})
|
db.query(User).filter_by(id=id).update({"oauth_sub": oauth_sub})
|
||||||
|
db.commit()
|
||||||
|
|
||||||
user = db.query(User).filter_by(id=id).first()
|
user = db.query(User).filter_by(id=id).first()
|
||||||
return UserModel.model_validate(user)
|
return UserModel.model_validate(user)
|
||||||
|
Loading…
Reference in New Issue
Block a user