This commit is contained in:
+4
-12
@@ -44,18 +44,10 @@ impl FilterExt for Filter {
|
||||
// 作者过滤 (NIP-01 支持前缀匹配)
|
||||
if let Some(authors) = &self.authors {
|
||||
if !authors.is_empty() {
|
||||
sql.push(" AND (");
|
||||
let mut separated = sql.separated(" OR ");
|
||||
for author_prefix in authors {
|
||||
if author_prefix.len() < 64 {
|
||||
// 如果是公钥前缀,使用 LIKE
|
||||
separated
|
||||
.push("pubkey LIKE ")
|
||||
.push_bind(format!("{}%", author_prefix));
|
||||
} else {
|
||||
// 否则进行精确匹配
|
||||
separated.push("pubkey = ").push_bind(author_prefix);
|
||||
}
|
||||
sql.push(" AND pubkey IN (");
|
||||
let mut separated = sql.separated(",");
|
||||
for author in authors {
|
||||
separated.push_bind(author);
|
||||
}
|
||||
separated.push_unseparated(")");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user