Add actor collections enum
This commit is contained in:
parent
75e4bfaaf7
commit
34ecf56ccd
3 changed files with 25 additions and 2 deletions
|
@ -13,6 +13,7 @@ use crate::models::users::types::User;
|
||||||
use crate::utils::crypto::{deserialize_private_key, get_public_key_pem};
|
use crate::utils::crypto::{deserialize_private_key, get_public_key_pem};
|
||||||
use crate::utils::files::get_file_url;
|
use crate::utils::files::get_file_url;
|
||||||
use super::constants::{ACTOR_KEY_SUFFIX, AP_CONTEXT};
|
use super::constants::{ACTOR_KEY_SUFFIX, AP_CONTEXT};
|
||||||
|
use super::identifiers::LocalActorCollection;
|
||||||
use super::views::{
|
use super::views::{
|
||||||
get_actor_url,
|
get_actor_url,
|
||||||
get_inbox_url,
|
get_inbox_url,
|
||||||
|
@ -339,8 +340,8 @@ pub fn get_instance_actor(
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
) -> Result<Actor, ActorKeyError> {
|
) -> Result<Actor, ActorKeyError> {
|
||||||
let actor_id = instance.actor_id();
|
let actor_id = instance.actor_id();
|
||||||
let actor_inbox = format!("{}/inbox", actor_id);
|
let actor_inbox = LocalActorCollection::Inbox.of(&actor_id);
|
||||||
let actor_outbox = format!("{}/outbox", actor_id);
|
let actor_outbox = LocalActorCollection::Outbox.of(&actor_id);
|
||||||
let public_key_pem = get_public_key_pem(&instance.actor_key)?;
|
let public_key_pem = get_public_key_pem(&instance.actor_key)?;
|
||||||
let public_key = PublicKey {
|
let public_key = PublicKey {
|
||||||
id: instance.actor_key_id(),
|
id: instance.actor_key_id(),
|
||||||
|
|
21
src/activitypub/identifiers.rs
Normal file
21
src/activitypub/identifiers.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub enum LocalActorCollection {
|
||||||
|
Inbox,
|
||||||
|
Outbox,
|
||||||
|
Followers,
|
||||||
|
Following,
|
||||||
|
Subscribers,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LocalActorCollection {
|
||||||
|
pub fn of(&self, actor_id: &str) -> String {
|
||||||
|
let name = match self {
|
||||||
|
Self::Inbox => "inbox",
|
||||||
|
Self::Outbox => "outbox",
|
||||||
|
Self::Followers => "followers",
|
||||||
|
Self::Following => "following",
|
||||||
|
Self::Subscribers => "subscribers",
|
||||||
|
};
|
||||||
|
format!("{}/{}", actor_id, name)
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ pub mod constants;
|
||||||
mod deliverer;
|
mod deliverer;
|
||||||
pub mod fetcher;
|
pub mod fetcher;
|
||||||
pub mod handlers;
|
pub mod handlers;
|
||||||
|
mod identifiers;
|
||||||
mod receiver;
|
mod receiver;
|
||||||
pub mod views;
|
pub mod views;
|
||||||
mod vocabulary;
|
mod vocabulary;
|
||||||
|
|
Loading…
Reference in a new issue