mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac/fix: channel messages
This commit is contained in:
parent
ed20f2ea5f
commit
24805ca79e
1 changed files with 18 additions and 14 deletions
|
|
@ -434,13 +434,6 @@ async def update_message_by_id(
|
||||||
status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND
|
status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND
|
||||||
)
|
)
|
||||||
|
|
||||||
if user.role != "admin" and not has_access(
|
|
||||||
user.id, type="read", access_control=channel.access_control
|
|
||||||
):
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT()
|
|
||||||
)
|
|
||||||
|
|
||||||
message = Messages.get_message_by_id(message_id)
|
message = Messages.get_message_by_id(message_id)
|
||||||
if not message:
|
if not message:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -452,6 +445,15 @@ async def update_message_by_id(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT()
|
status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
user.role != "admin"
|
||||||
|
and message.user_id != user.id
|
||||||
|
and not has_access(user.id, type="read", access_control=channel.access_control)
|
||||||
|
):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT()
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
message = Messages.update_message_by_id(message_id, form_data)
|
message = Messages.update_message_by_id(message_id, form_data)
|
||||||
message = Messages.get_message_by_id(message_id)
|
message = Messages.get_message_by_id(message_id)
|
||||||
|
|
@ -641,13 +643,6 @@ async def delete_message_by_id(
|
||||||
status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND
|
status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND
|
||||||
)
|
)
|
||||||
|
|
||||||
if user.role != "admin" and not has_access(
|
|
||||||
user.id, type="read", access_control=channel.access_control
|
|
||||||
):
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT()
|
|
||||||
)
|
|
||||||
|
|
||||||
message = Messages.get_message_by_id(message_id)
|
message = Messages.get_message_by_id(message_id)
|
||||||
if not message:
|
if not message:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -659,6 +654,15 @@ async def delete_message_by_id(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT()
|
status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
user.role != "admin"
|
||||||
|
and message.user_id != user.id
|
||||||
|
and not has_access(user.id, type="read", access_control=channel.access_control)
|
||||||
|
):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT()
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Messages.delete_message_by_id(message_id)
|
Messages.delete_message_by_id(message_id)
|
||||||
await sio.emit(
|
await sio.emit(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue