commit c18aa9edc3c78ec11ba14922e6f99c3eccbedadf
parent cd9ba0ea7dfd021f2a3e98aefef87990d161aab3
Author: William Casarin <jb55@jb55.com>
Date: Wed, 23 Oct 2024 13:13:38 -0700
add ndb_subscription_filters
Expose a way to get the set of filters for a subscription. On the rust
side, we should likely ndb_filter_clone each filter asap, because the
result of this function will only be valid up until the subscription
ends.
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/nostrdb.c b/src/nostrdb.c
@@ -6467,6 +6467,20 @@ int ndb_unsubscribe(struct ndb *ndb, uint64_t subid)
return 1;
}
+struct ndb_filter *ndb_subscription_filters(struct ndb *ndb, uint64_t subid, int *filters)
+{
+ struct ndb_subscription *sub;
+
+ sub = ndb_find_subscription(ndb, subid, NULL);
+ if (sub) {
+ *filters = sub->group.num_filters;
+ return sub->group.filters;
+ }
+
+ *filters = 0;
+ return NULL;
+}
+
int ndb_num_subscriptions(struct ndb *ndb)
{
return ndb->monitor.num_subscriptions;
diff --git a/src/nostrdb.h b/src/nostrdb.h
@@ -519,6 +519,7 @@ int ndb_wait_for_notes(struct ndb *, uint64_t subid, uint64_t *note_ids, int not
int ndb_poll_for_notes(struct ndb *, uint64_t subid, uint64_t *note_ids, int note_id_capacity);
int ndb_unsubscribe(struct ndb *, uint64_t subid);
int ndb_num_subscriptions(struct ndb *);
+struct ndb_filter *ndb_subscription_filters(struct ndb *, uint64_t subid, int *filters);
// FULLTEXT SEARCH
int ndb_text_search(struct ndb_txn *txn, const char *query, struct ndb_text_search_results *, struct ndb_text_search_config *);