.set_outbox(self.get_outbox_url())?
.set_followers(self.get_followers_url())?;
- let public_key = PublicKey {
- id: format!("{}#main-key", self.actor_id),
- owner: self.actor_id.to_owned(),
- public_key_pem: self.public_key.to_owned().unwrap(),
- };
-
- Ok(group.extend(actor_props).extend(public_key.to_ext()))
+ Ok(group.extend(actor_props).extend(self.get_public_key_ext()))
}
}
fn actor_id(&self) -> String {
self.actor_id.to_owned()
}
+
+ fn public_key(&self) -> String {
+ self.public_key.to_owned().unwrap()
+ }
}
impl FromApub for CommunityForm {
user_id: user.id,
};
- // This will fail if they're already a follower
- CommunityFollower::follow(&conn, &community_follower_form)?;
+ // This will fail if they're already a follower, but ignore the error.
+ CommunityFollower::follow(&conn, &community_follower_form).ok();
accept_follow(&follow, &conn)?;
Ok(HttpResponse::Ok().finish())
pub trait ActorType {
fn actor_id(&self) -> String;
+ fn public_key(&self) -> String;
+
fn get_inbox_url(&self) -> String {
format!("{}/inbox", &self.actor_id())
}
fn get_liked_url(&self) -> String {
format!("{}/liked", &self.actor_id())
}
+
+ fn get_public_key_ext(&self) -> PublicKeyExtension {
+ PublicKey {
+ id: format!("{}#main-key", self.actor_id()),
+ owner: self.actor_id(),
+ public_key_pem: self.public_key(),
+ }
+ .to_ext()
+ }
}
.set_following(self.get_following_url())?
.set_liked(self.get_liked_url())?;
- let public_key = PublicKey {
- id: format!("{}#main-key", self.actor_id),
- owner: self.actor_id.to_owned(),
- public_key_pem: self.public_key.to_owned().unwrap(),
- };
-
- Ok(person.extend(actor_props).extend(public_key.to_ext()))
+ Ok(person.extend(actor_props).extend(self.get_public_key_ext()))
}
}
fn actor_id(&self) -> String {
self.actor_id.to_owned()
}
+
+ fn public_key(&self) -> String {
+ self.public_key.to_owned().unwrap()
+ }
}
impl FromApub for UserForm {