What is Nostr?
Kind 1617
git patch: nostr: add coordinate refs filter method
Author Public Key
npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr
Published at
2024-07-11 10:51:22
Kind type
1617
Event JSON
{ "id": "f2f2899ea251d9603db3f26f789916352dd0e9fb4b02efdce4ac0ef51468cdee", "pubkey": "a008def15796fba9a0d6fab04e8fd57089285d9fd505da5a83fe8aad57a3564d", "created_at": 1720695082, "kind": 1617, "tags": [ [ "a", "30617:68d81165918100b7da43fc28f7d1fc12554466e1115886b9e7bb326f65ec4272:rust-nostr" ], [ "r", "73f7c34fd424cae57a0da1be1f5fd31d9b8075c0" ], [ "r", "129a19720d2ecf05987e3da7552c63fc33811bda" ], [ "alt", "git patch: nostr: add coordinate refs filter method" ], [ "t", "root" ], [ "p", "68d81165918100b7da43fc28f7d1fc12554466e1115886b9e7bb326f65ec4272" ], [ "commit", "129a19720d2ecf05987e3da7552c63fc33811bda" ], [ "parent-commit", "d244d10f53bf0ad2a1e84fffdf658c84d7bcce0c" ], [ "commit-pgp-sig", "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEsRaN4Kb3mvfPwNXpaOFUhtc/deEFAmaPtwcACgkQaOFUhtc/\ndeFm2Q/9G6KAUkBv2YpybM1xsYsRVnnKLJpyjO0V2WHltzMG+ZI7d1wNQb9XfxJ3\n3ibuKGI8J6n/KPr3G0ggGk3oXeouvEs89p9Sr9UcwFp4uq81IJyki6hMdUot9zyo\n1egfN3sR9FzJ2zeXXhY3BBfFJ2sp5m/sfmxVuG5XOA78M9tbeLjUnsekIzBxt63/\n85wOItDDdxlu7LuguH6mTymVMO5uW8kv8qe+dy8C7HwI5tgFQOp77UTdt9pckNcW\nHRkzJyGkY72NiLXLKTpPOn4BqNKYTNuXo1OkTIsWsMy9nqJSOmhPJ/IjI5xp7OKY\nVQMuoLAKxLB5QU77FUhJVVwrnZRo4SsF16GZpq/9Px9Bz50uNfhMosHOPYhiAuYp\ngva6NPjo0rV2UGy0UXvUS429JvQsl0KZCXvayF6NbTJiVEVhn89kx7wqoRPkclsT\njpIZY77dI5ibvUvMyIoZIgw1cNbRUBIIM+57zlN5EdeZqhhsIou2XA2iY5ZtCdub\nFDe2WDEICoUlIN5HN0myI88n4lMeP3WzM9jBYjT6N9y8hTKi1Qq0kFf4Djjba7EO\nZN6QNJnYObsjOCZEPw4OsKcgiDf6y+bIQw8fOhhkPqgOwx2MSnP0KdY+x7f8Uxv1\n4NpTsTaSx/qDHyOtwhTUrDjYooDl0e+nf4VYQ+Chbiw+FeFwOfg=\n=Qla/\n-----END PGP SIGNATURE-----" ], [ "description", "nostr: add coordinate refs filter method\n\nto move smoothly filter for events that tag replacable events\n" ], [ "author", "DanConwayDev", "DanConwayDev@protonmail.com", "1720694507", "60" ], [ "committer", "DanConwayDev", "DanConwayDev@protonmail.com", "1720694507", "60" ] ], "content": "From 129a19720d2ecf05987e3da7552c63fc33811bda Mon Sep 17 00:00:00 2001\nFrom: DanConwayDev \u003cDanConwayDev@protonmail.com\u003e\nDate: Thu, 11 Jul 2024 11:41:47 +0100\nSubject: [PATCH] nostr: add coordinate refs filter method\n\nto move smoothly filter for events that tag replacable events\n---\n crates/nostr/src/types/filter.rs | 40 ++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 40 insertions(+)\n\ndiff --git a/crates/nostr/src/types/filter.rs b/crates/nostr/src/types/filter.rs\nindex 1584563..0565295 100644\n--- a/crates/nostr/src/types/filter.rs\n+++ b/crates/nostr/src/types/filter.rs\n@@ -19,6 +19,7 @@ use serde::ser::{SerializeMap, Serializer};\n use serde::{Deserialize, Serialize};\n \n use crate::event::TagsIndexes;\n+use crate::nips::nip01::Coordinate;\n use crate::{Event, EventId, JsonUtil, Kind, PublicKey, Timestamp};\n \n type GenericTags = AllocMap\u003cSingleLetterTag, AllocSet\u003cString\u003e\u003e;\n@@ -551,6 +552,45 @@ impl Filter {\n )\n }\n \n+ /// Add coordinate reference\n+ ///\n+ /// \u003chttps://github.com/nostr-protocol/nips/blob/master/33.md\u003e\n+ #[inline]\n+ pub fn coordinate_ref\u003cC\u003e(self, coordinate: C) -\u003e Self\n+ where\n+ C: Into\u003cCoordinate\u003e,\n+ {\n+ self.custom_tag(SingleLetterTag::lowercase(Alphabet::A), [coordinate.into()])\n+ }\n+\n+ /// Add coordinate references\n+ ///\n+ /// \u003chttps://github.com/nostr-protocol/nips/blob/master/33.md\u003e\n+ #[inline]\n+ pub fn coordinate_refs\u003cI, C\u003e(self, coordinates: I) -\u003e Self\n+ where\n+ I: IntoIterator\u003cItem = C\u003e,\n+ C: Into\u003cCoordinate\u003e,\n+ {\n+ self.custom_tag(\n+ SingleLetterTag::lowercase(Alphabet::A),\n+ coordinates.into_iter().map(|c| c.into()),\n+ )\n+ }\n+\n+ /// Remove coordinate references\n+ #[inline]\n+ pub fn remove_coordinate_refs\u003cI, C\u003e(self, coordinates: I) -\u003e Self\n+ where\n+ I: IntoIterator\u003cItem = C\u003e,\n+ C: Into\u003cCoordinate\u003e,\n+ {\n+ self.remove_custom_tag(\n+ SingleLetterTag::lowercase(Alphabet::A),\n+ coordinates.into_iter().map(|s| s.into()),\n+ )\n+ }\n+\n /// Add search field\n #[inline]\n pub fn search\u003cS\u003e(mut self, value: S) -\u003e Self\n--\nlibgit2 1.7.2\n\n", "sig": "6869b868b10c7c8a4236604ad316167e2244ad09966406023bc49cb665b827efac331e5e7e1a7a0069132bcfed9b448f2d4645ab285646daf5ece55b113a5fd8" }