mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-07 17:23:05 +02:00
Fix mention detection case sensitivity
This commit is contained in:
+8
-2
@@ -580,7 +580,10 @@ class MessageRepository:
|
|||||||
SELECT m.conversation_key,
|
SELECT m.conversation_key,
|
||||||
COUNT(*) as unread_count,
|
COUNT(*) as unread_count,
|
||||||
MAX(m.received_at) as last_message_time,
|
MAX(m.received_at) as last_message_time,
|
||||||
SUM(CASE WHEN ? <> '' AND INSTR(m.text, ?) > 0 THEN 1 ELSE 0 END) > 0 as has_mention
|
SUM(CASE
|
||||||
|
WHEN ? <> '' AND INSTR(LOWER(m.text), LOWER(?)) > 0 THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) > 0 as has_mention
|
||||||
FROM messages m
|
FROM messages m
|
||||||
JOIN channels c ON m.conversation_key = c.key
|
JOIN channels c ON m.conversation_key = c.key
|
||||||
WHERE m.type = 'CHAN' AND m.outgoing = 0
|
WHERE m.type = 'CHAN' AND m.outgoing = 0
|
||||||
@@ -602,7 +605,10 @@ class MessageRepository:
|
|||||||
SELECT m.conversation_key,
|
SELECT m.conversation_key,
|
||||||
COUNT(*) as unread_count,
|
COUNT(*) as unread_count,
|
||||||
MAX(m.received_at) as last_message_time,
|
MAX(m.received_at) as last_message_time,
|
||||||
SUM(CASE WHEN ? <> '' AND INSTR(m.text, ?) > 0 THEN 1 ELSE 0 END) > 0 as has_mention
|
SUM(CASE
|
||||||
|
WHEN ? <> '' AND INSTR(LOWER(m.text), LOWER(?)) > 0 THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) > 0 as has_mention
|
||||||
FROM messages m
|
FROM messages m
|
||||||
JOIN contacts ct ON m.conversation_key = ct.public_key
|
JOIN contacts ct ON m.conversation_key = ct.public_key
|
||||||
WHERE m.type = 'PRIV' AND m.outgoing = 0
|
WHERE m.type = 'PRIV' AND m.outgoing = 0
|
||||||
|
|||||||
+4
-3
@@ -663,7 +663,7 @@ class TestReadStateEndpoints:
|
|||||||
)
|
)
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
"INSERT INTO messages (type, conversation_key, text, received_at, outgoing) VALUES (?, ?, ?, ?, ?)",
|
"INSERT INTO messages (type, conversation_key, text, received_at, outgoing) VALUES (?, ?, ?, ?, ?)",
|
||||||
("CHAN", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1", "Bob: @[TestUser] hey", 1002, 0),
|
("CHAN", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1", "Bob: @[testuser] hey", 1002, 0),
|
||||||
)
|
)
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
"INSERT INTO messages (type, conversation_key, text, received_at, outgoing) VALUES (?, ?, ?, ?, ?)",
|
"INSERT INTO messages (type, conversation_key, text, received_at, outgoing) VALUES (?, ?, ?, ?, ?)",
|
||||||
@@ -677,7 +677,7 @@ class TestReadStateEndpoints:
|
|||||||
# Insert 1 unread DM
|
# Insert 1 unread DM
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
"INSERT INTO messages (type, conversation_key, text, received_at, outgoing) VALUES (?, ?, ?, ?, ?)",
|
"INSERT INTO messages (type, conversation_key, text, received_at, outgoing) VALUES (?, ?, ?, ?, ?)",
|
||||||
("PRIV", "abcd" * 16, "hi there", 1005, 0),
|
("PRIV", "abcd" * 16, "hi @[TeStUsEr] there", 1005, 0),
|
||||||
)
|
)
|
||||||
await conn.commit()
|
await conn.commit()
|
||||||
|
|
||||||
@@ -691,8 +691,9 @@ class TestReadStateEndpoints:
|
|||||||
assert result["counts"]["channel-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1"] == 2
|
assert result["counts"]["channel-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1"] == 2
|
||||||
assert result["mentions"]["channel-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1"] is True
|
assert result["mentions"]["channel-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1"] is True
|
||||||
|
|
||||||
# Contact: 1 unread
|
# Contact: 1 unread with mention (also case-insensitive)
|
||||||
assert result["counts"][f"contact-{'abcd' * 16}"] == 1
|
assert result["counts"][f"contact-{'abcd' * 16}"] == 1
|
||||||
|
assert result["mentions"][f"contact-{'abcd' * 16}"] is True
|
||||||
|
|
||||||
# Last message times should include all conversations
|
# Last message times should include all conversations
|
||||||
assert "channel-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1" in result["last_message_times"]
|
assert "channel-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1" in result["last_message_times"]
|
||||||
|
|||||||
Reference in New Issue
Block a user