Compare commits
No commits in common. "f4db94db27e68f091dcf05334506f7a341849642" and "39f6ff24b3b918a58d37f8e38e9f7a10f6703366" have entirely different histories.
f4db94db27
...
39f6ff24b3
6 changed files with 15 additions and 38 deletions
|
@ -24,14 +24,13 @@ sea-orm = { version = "0.12", optional = true }
|
||||||
reqwest = { version = "0.12", features = ["json"], optional = true }
|
reqwest = { version = "0.12", features = ["json"], optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["activitypub-miscellaneous-terms", "send"]
|
default = ["activitypub-miscellaneous-terms"]
|
||||||
# extensions
|
# extensions
|
||||||
activitypub-miscellaneous-terms = [] # https://swicg.github.io/miscellany/
|
activitypub-miscellaneous-terms = [] # https://swicg.github.io/miscellany/
|
||||||
activitypub-counters = [] # https://ns.alemi.dev/as/counters/#
|
activitypub-counters = [] # https://ns.alemi.dev/as/counters/#
|
||||||
activitypub-fe = [] # https://ns.alemi.dev/as/fe/#
|
activitypub-fe = [] # https://ns.alemi.dev/as/fe/#
|
||||||
litepub = [] # incomplete, https://litepub.social/
|
litepub = [] # incomplete, https://litepub.social/
|
||||||
# builtin utils
|
# builtin utils
|
||||||
send = []
|
|
||||||
orm = ["dep:sea-orm"]
|
orm = ["dep:sea-orm"]
|
||||||
fetch = ["dep:reqwest"]
|
fetch = ["dep:reqwest"]
|
||||||
# providers
|
# providers
|
||||||
|
|
|
@ -1,15 +1,3 @@
|
||||||
#[cfg(feature = "send")]
|
|
||||||
pub trait MaybeSend : Send {}
|
|
||||||
#[cfg(feature = "send")]
|
|
||||||
impl<T : Send> MaybeSend for T {}
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(not(feature = "send"))]
|
|
||||||
pub trait MaybeSend {}
|
|
||||||
#[cfg(not(feature = "send"))]
|
|
||||||
impl<T> MaybeSend for T {}
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
#[error("invalid type value")]
|
#[error("invalid type value")]
|
||||||
pub struct TypeValueError;
|
pub struct TypeValueError;
|
||||||
|
|
|
@ -116,15 +116,6 @@ impl<T : super::Base> Node<T> {
|
||||||
Node::Array(x) => x.iter().filter_map(Self::id).collect()
|
Node::Array(x) => x.iter().filter_map(Self::id).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flat(self) -> Vec<Node<T>> {
|
|
||||||
match self {
|
|
||||||
Node::Empty => vec![],
|
|
||||||
Node::Link(_) | Node::Object(_) => vec![self],
|
|
||||||
// i think AP disallows array of arrays so no need to make this recursive
|
|
||||||
Node::Array(arr) => arr.into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstructured")]
|
#[cfg(feature = "unstructured")]
|
||||||
|
|
|
@ -8,13 +8,13 @@ crate::strenum! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Base : crate::macros::MaybeSend {
|
pub trait Base {
|
||||||
fn id(&self) -> Option<&str> { None }
|
fn id(&self) -> Option<&str> { None }
|
||||||
fn base_type(&self) -> Option<BaseType> { None }
|
fn base_type(&self) -> Option<BaseType> { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub trait BaseMut : crate::macros::MaybeSend {
|
pub trait BaseMut {
|
||||||
fn set_id(self, val: Option<&str>) -> Self;
|
fn set_id(self, val: Option<&str>) -> Self;
|
||||||
fn set_base_type(self, val: Option<BaseType>) -> Self;
|
fn set_base_type(self, val: Option<BaseType>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,18 +117,6 @@ 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
|
/// get full user id uri
|
||||||
pub fn uid(&self, id: String) -> String {
|
pub fn uid(&self, id: String) -> String {
|
||||||
self.uri("users", id)
|
self.uri("users", id)
|
||||||
|
@ -144,6 +132,17 @@ impl Context {
|
||||||
self.uri("activities", id)
|
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 {
|
pub fn server(id: &str) -> String {
|
||||||
id
|
id
|
||||||
|
|
|
@ -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
|
// 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_activity = activity.object().extract().ok_or_else(UpubError::bad_request)?;
|
||||||
let undone_aid = undone_activity.id().ok_or_else(UpubError::bad_request)?;
|
let undone_aid = undone_activity.id().ok_or_else(UpubError::bad_request)?;
|
||||||
let undone_object_uri = undone_activity.object().id().ok_or_else(UpubError::bad_request)?;
|
let undone_object_id = undone_activity.object().id().ok_or_else(UpubError::bad_request)?;
|
||||||
let activity_type = undone_activity.activity_type().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)?;
|
let undone_activity_author = undone_activity.actor().id().ok_or_else(UpubError::bad_request)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue