diff --git a/src/server/context.rs b/src/server/context.rs index f300d629..e0ec0c4a 100644 --- a/src/server/context.rs +++ b/src/server/context.rs @@ -117,6 +117,18 @@ impl Context { } } + /// get bare id, usually an uuid but unspecified + pub fn id(&self, uri: &str) -> String { + if uri.starts_with(&self.0.domain) { + uri.split('/').last().unwrap_or("").to_string() + } else { + uri + .replace("https://", "+") + .replace("http://", "+") + .replace('/', "@") + } + } + /// get full user id uri pub fn uid(&self, id: String) -> String { self.uri("users", id) @@ -132,17 +144,6 @@ impl Context { self.uri("activities", id) } - /// get bare id, usually an uuid but unspecified - pub fn id(&self, uri: &str) -> String { - if uri.starts_with(&self.0.domain) { - uri.split('/').last().unwrap_or("").to_string() - } else { - uri - .replace("https://", "+") - .replace("http://", "+") - .replace('/', "@") - } - } pub fn server(id: &str) -> String { id diff --git a/src/server/inbox.rs b/src/server/inbox.rs index 81b13157..10171266 100644 --- a/src/server/inbox.rs +++ b/src/server/inbox.rs @@ -319,7 +319,7 @@ impl apb::server::Inbox for Context { // TODO in theory we could work with just object_id but right now only accept embedded let undone_activity = activity.object().extract().ok_or_else(UpubError::bad_request)?; let undone_aid = undone_activity.id().ok_or_else(UpubError::bad_request)?; - let undone_object_id = undone_activity.object().id().ok_or_else(UpubError::bad_request)?; + let undone_object_uri = undone_activity.object().id().ok_or_else(UpubError::bad_request)?; let activity_type = undone_activity.activity_type().ok_or_else(UpubError::bad_request)?; let undone_activity_author = undone_activity.actor().id().ok_or_else(UpubError::bad_request)?;