Skip to content

Commit f571e35

Browse files
committed
Merge pull request 'fix(sql): remove unneeded where with user_id' (#472) from fix-sql into main
Reviewed-on: https://git.biggo.com/Funmula/dive-mcp-host/pulls/472
2 parents 89437c8 + 2cc1d44 commit f571e35

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
@@ -320,16 +320,19 @@ async def lock_msg(
320320
chat_id: Unique identifier for the chat.
321321
message_id: Unique identifier for the message.
322322
user_id: User ID or fingerprint, depending on the prefix.
323+
Should not be used in this current implementation.
323324
324325
Returns:
325326
If the message exist and is locked, returns True, False otherwise.
326327
"""
328+
if user_id is not None:
329+
raise ValueError("user_id should not be used.")
330+
327331
query = (
328332
select(ORMMessage.message_id)
329333
.where(
330334
ORMMessage.message_id == message_id,
331335
ORMMessage.chat_id == chat_id,
332-
ORMChat.user_id == user_id,
333336
)
334337
.with_for_update()
335338
)
@@ -348,10 +351,14 @@ async def update_message_content(
348351
message_id: Unique identifier for the message.
349352
data: New content for the message.
350353
user_id: User ID or fingerprint, depending on the prefix.
354+
Should not be used in this current implementation.
351355
352356
Returns:
353357
Updated Message object.
354358
"""
359+
if user_id is not None:
360+
raise ValueError("user_id should not be used.")
361+
355362
# Prepare files list
356363
files = []
357364
if data.images:
@@ -364,7 +371,6 @@ async def update_message_content(
364371
update(ORMMessage)
365372
.where(
366373
ORMMessage.message_id == message_id,
367-
ORMChat.user_id == user_id,
368374
)
369375
.values(
370376
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)