use NdbQueryPackage to call ndb::query multiple times
necessary to ensure we can retrieve reposts from ndb Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
filter::{self, HybridFilter},
|
||||
filter::{self, HybridFilter, ValidKind},
|
||||
Error,
|
||||
};
|
||||
use nostrdb::{Filter, Note};
|
||||
@@ -15,8 +15,14 @@ pub fn hybrid_contacts_filter(
|
||||
add_pk: Option<&[u8; 32]>,
|
||||
with_hashtags: bool,
|
||||
) -> Result<HybridFilter, Error> {
|
||||
let local = filter::filter_from_tags(note, add_pk, with_hashtags)?
|
||||
.into_filter(vec![1], filter::default_limit());
|
||||
let local = vec![
|
||||
filter::filter_from_tags(note, add_pk, with_hashtags)?
|
||||
.into_query_package(ValidKind::One, filter::default_limit()),
|
||||
filter::filter_from_tags(note, add_pk, with_hashtags)?
|
||||
.into_query_package(ValidKind::Six, filter::default_limit()),
|
||||
filter::filter_from_tags(note, add_pk, with_hashtags)?
|
||||
.into_query_package(ValidKind::Zero, filter::default_limit()),
|
||||
];
|
||||
let remote = filter::filter_from_tags(note, add_pk, with_hashtags)?
|
||||
.into_filter(vec![1, 0], filter::default_remote_limit());
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ pub struct FilteredTags {
|
||||
/// The local and remote filter are related but slightly different
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SplitFilter {
|
||||
pub local: Vec<Filter>,
|
||||
pub local: Vec<NdbQueryPackage>,
|
||||
pub remote: Vec<Filter>,
|
||||
}
|
||||
|
||||
@@ -230,16 +230,23 @@ impl HybridFilter {
|
||||
HybridFilter::Unsplit(filter)
|
||||
}
|
||||
|
||||
pub fn split(local: Vec<Filter>, remote: Vec<Filter>) -> Self {
|
||||
pub fn split(local: Vec<NdbQueryPackage>, remote: Vec<Filter>) -> Self {
|
||||
HybridFilter::Split(SplitFilter { local, remote })
|
||||
}
|
||||
|
||||
pub fn local(&self) -> &[Filter] {
|
||||
pub fn local(&self) -> NdbQueryPackages {
|
||||
match self {
|
||||
Self::Split(split) => &split.local,
|
||||
Self::Split(split) => NdbQueryPackages {
|
||||
packages: split.local.iter().map(NdbQueryPackage::borrow).collect(),
|
||||
},
|
||||
|
||||
// local as the same as remote in unsplit
|
||||
Self::Unsplit(local) => local,
|
||||
Self::Unsplit(local) => NdbQueryPackages {
|
||||
packages: vec![NdbQueryPackageUnowned {
|
||||
filters: local,
|
||||
kind: None,
|
||||
}],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user