Skip to content

Commit ebb44e5

Browse files
committed
feat: Extend DidDocument with useful methods
New methods: * get_feed_gen_endpoint * get_notif_endpoint * get_signing_key
1 parent 7a1c92d commit ebb44e5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

atrium-api/src/did_doc.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ impl DidDocument {
3939
pub fn get_pds_endpoint(&self) -> Option<String> {
4040
self.get_service_endpoint("#atproto_pds", "AtprotoPersonalDataServer")
4141
}
42+
pub fn get_feed_gen_endpoint(&self) -> Option<String> {
43+
self.get_service_endpoint("#bsky_fg", "BskyFeedGenerator")
44+
}
45+
pub fn get_notif_endpoint(&self) -> Option<String> {
46+
self.get_service_endpoint("#bsky_notif", "BskyNotificationService")
47+
}
4248
fn get_service_endpoint(&self, id: &str, r#type: &str) -> Option<String> {
4349
let full_id = self.id.to_string() + id;
4450
if let Some(services) = &self.service {
@@ -62,4 +68,11 @@ impl DidDocument {
6268
})
6369
.unwrap_or_default()
6470
}
71+
pub fn get_signing_key(&self) -> Option<&VerificationMethod> {
72+
self.verification_method.as_ref().and_then(|methods| {
73+
methods.iter().find(|method| {
74+
method.id == "#atproto" || method.id == format!("{}#atproto", self.id)
75+
})
76+
})
77+
}
6578
}

0 commit comments

Comments
 (0)