From e3ed744a5c63146a14f0a8643d2a47ae6d62dbe1 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 29 Nov 2024 09:49:00 -0800 Subject: [PATCH] posts: add client tag when posting and replying This should help us a bit with seeing notedeck usage. Signed-off-by: William Casarin --- src/post.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/post.rs b/src/post.rs index ea58f54f..a9c519d9 100644 --- a/src/post.rs +++ b/src/post.rs @@ -7,13 +7,20 @@ pub struct NewPost { pub account: FullKeypair, } +fn add_client_tag(builder: NoteBuilder<'_>) -> NoteBuilder<'_> { + builder + .start_tag() + .tag_str("client") + .tag_str("Damus Notedeck") +} + impl NewPost { pub fn new(content: String, account: FullKeypair) -> Self { NewPost { content, account } } pub fn to_note(&self, seckey: &[u8; 32]) -> Note { - NoteBuilder::new() + add_client_tag(NoteBuilder::new()) .kind(1) .content(&self.content) .sign(seckey) @@ -22,7 +29,9 @@ impl NewPost { } pub fn to_reply(&self, seckey: &[u8; 32], replying_to: &Note) -> Note { - let builder = NoteBuilder::new().kind(1).content(&self.content); + let builder = add_client_tag(NoteBuilder::new()) + .kind(1) + .content(&self.content); let nip10 = NoteReply::new(replying_to.tags());