commit e3ed744a5c63146a14f0a8643d2a47ae6d62dbe1
parent c2bdae1dcb9b55d340394dc40652e85a369f464c
Author: William Casarin <jb55@jb55.com>
Date: Fri, 29 Nov 2024 09:49:00 -0800
posts: add client tag when posting and replying
This should help us a bit with seeing notedeck usage.
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git 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());