Skip to content

Commit 1fb5126

Browse files
committed
Merge branch 'main' into gemini-image
2 parents 0a8151f + adfa0df commit 1fb5126

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

dive_mcp_host/httpd/database/msg_store/abstract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ async def delete_messages_after(
122122
user_id: User ID or fingerprint, depending on the prefix.
123123
"""
124124

125-
# NOTE: Might change, currently not used
126125
@abstractmethod
127126
async def update_message_content(
128127
self,
@@ -136,6 +135,7 @@ async def update_message_content(
136135
message_id: Unique identifier for the message.
137136
data: New content for the message.
138137
user_id: User ID or fingerprint, depending on the prefix.
138+
Should not be used in this current implementation.
139139
140140
Returns:
141141
Updated Message object.

dive_mcp_host/httpd/database/msg_store/base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,19 @@ async def lock_msg(
372372
chat_id: Unique identifier for the chat.
373373
message_id: Unique identifier for the message.
374374
user_id: User ID or fingerprint, depending on the prefix.
375+
Should not be used in this current implementation.
375376
376377
Returns:
377378
If the message exist and is locked, returns True, False otherwise.
378379
"""
380+
if user_id is not None:
381+
raise ValueError("user_id should not be used.")
382+
379383
query = (
380384
select(ORMMessage.message_id)
381385
.where(
382386
ORMMessage.message_id == message_id,
383387
ORMMessage.chat_id == chat_id,
384-
ORMChat.user_id == user_id,
385388
)
386389
.with_for_update()
387390
)
@@ -400,10 +403,14 @@ async def update_message_content(
400403
message_id: Unique identifier for the message.
401404
data: New content for the message.
402405
user_id: User ID or fingerprint, depending on the prefix.
406+
Should not be used in this current implementation.
403407
404408
Returns:
405409
Updated Message object.
406410
"""
411+
if user_id is not None:
412+
raise ValueError("user_id should not be used.")
413+
407414
# Prepare files list
408415
files = []
409416
if data.images:
@@ -416,7 +423,6 @@ async def update_message_content(
416423
update(ORMMessage)
417424
.where(
418425
ORMMessage.message_id == message_id,
419-
ORMChat.user_id == user_id,
420426
)
421427
.values(
422428
content=data.text or "",

tests/test_base_message_store_sqlite.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,6 @@ async def test_update_message_content(
632632
updated_message = await message_store.update_message_content(
633633
message_id=user_message.message_id,
634634
data=update_data,
635-
user_id=sample_chat.user_id,
636635
)
637636

638637
# Verify the returned message
@@ -673,36 +672,6 @@ async def test_update_message_content_not_found(
673672
await message_store.update_message_content(
674673
message_id="non_existent_message",
675674
data=update_data,
676-
user_id=sample_chat.user_id,
677-
)
678-
679-
680-
@pytest.mark.asyncio
681-
async def test_update_message_content_wrong_user(
682-
message_store: BaseMessageStore,
683-
sample_chat: ORMChat,
684-
sample_messages: dict[str, ORMMessage],
685-
):
686-
"""Test updating a message with wrong user ID."""
687-
# Get the user message to update
688-
user_message = sample_messages["user_message"]
689-
690-
# Create update data
691-
update_data = QueryInput(
692-
text="Updated message content",
693-
images=["image1.jpg"],
694-
documents=["doc1.pdf"],
695-
)
696-
697-
# Try to update the message with wrong user ID
698-
with pytest.raises(
699-
ValueError,
700-
match=f"Message {user_message.message_id} not found",
701-
):
702-
await message_store.update_message_content(
703-
message_id=user_message.message_id,
704-
data=update_data,
705-
user_id="wrong_user_id",
706675
)
707676

708677

@@ -724,7 +693,6 @@ async def test_update_message_content_empty_data(
724693
updated_message = await message_store.update_message_content(
725694
message_id=user_message.message_id,
726695
data=update_data,
727-
user_id=sample_chat.user_id,
728696
)
729697

730698
# Verify the returned message

0 commit comments

Comments
 (0)