forked from langgenius/dify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: missing default user for APP service api (langgenius#2606)
- Loading branch information
Showing
8 changed files
with
141 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +0,0 @@ | ||
from extensions.ext_database import db | ||
from models.model import EndUser | ||
|
||
|
||
def create_or_update_end_user_for_user_id(app_model, user_id): | ||
""" | ||
Create or update session terminal based on user ID. | ||
""" | ||
end_user = db.session.query(EndUser) \ | ||
.filter( | ||
EndUser.tenant_id == app_model.tenant_id, | ||
EndUser.session_id == user_id, | ||
EndUser.type == 'service_api' | ||
).first() | ||
|
||
if end_user is None: | ||
end_user = EndUser( | ||
tenant_id=app_model.tenant_id, | ||
app_id=app_model.id, | ||
type='service_api', | ||
is_anonymous=True, | ||
session_id=user_id | ||
) | ||
db.session.add(end_user) | ||
db.session.commit() | ||
|
||
return end_user | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.