fix(mcp): filter out chat room members from contact list

_load_contacts_from() loaded all rows from the contact table without
filtering, causing ~8000+ chat room member records (local_type=3) to
appear as contacts. This inflated the contact count and polluted search
results. Add WHERE local_type != 3 to exclude chat room members.
This commit is contained in:
wingIsCrazy
2026-05-19 03:19:11 +08:00
committed by ylytdeng
parent 87b0b419d6
commit 7ab90dcd20

View File

@@ -269,10 +269,15 @@ def _load_contacts_from(db_path):
col for col in optional_columns col for col in optional_columns
if col in columns and col not in select_columns if col in columns and col not in select_columns
) )
rows = conn.execute( # 过滤群成员 (local_type=3, 每个群每个成员一条 → 数量爆炸 → 共 9416 假联系人)
# 仅在 local_type 列存在时加 WHERE, 兼容老版本 schema (#117 fix)
sql = (
"SELECT " + ", ".join(f"[{col}]" for col in select_columns) "SELECT " + ", ".join(f"[{col}]" for col in select_columns)
+ " FROM contact" + " FROM contact"
).fetchall() )
if "local_type" in columns:
sql += " WHERE local_type != 3"
rows = conn.execute(sql).fetchall()
for r in rows: for r in rows:
data = dict(zip(select_columns, r)) data = dict(zip(select_columns, r))
uname = data.get("username") uname = data.get("username")