From f83103ba72c1e42d22d2c7a94eef856c6261a49b Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 27 Mar 2024 03:23:54 +0100 Subject: [PATCH] fix: Node::id() returns owned value, imports fix --- src/activitypub/user/mod.rs | 14 +------------- src/activitystream/node.rs | 8 ++++---- src/dispatcher.rs | 3 --- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/activitypub/user/mod.rs b/src/activitypub/user/mod.rs index c3c3c34b..ea3b3e51 100644 --- a/src/activitypub/user/mod.rs +++ b/src/activitypub/user/mod.rs @@ -8,7 +8,7 @@ pub use following::follow___; use axum::{extract::{Path, State}, http::StatusCode}; use sea_orm::EntityTrait; -use crate::{activitystream::{key::PublicKeyMut, object::{actor::ActorMut, collection::{CollectionMut, CollectionType}, document::{DocumentMut, DocumentType}, ObjectMut}, BaseMut, Node}, model::{self, user}, server::Context, url}; +use crate::{activitystream::{key::PublicKeyMut, object::{actor::ActorMut, document::{DocumentMut, DocumentType}, ObjectMut}, BaseMut, Node}, model::{self, user}, server::Context, url}; use super::{jsonld::LD, JsonLD}; @@ -33,19 +33,7 @@ pub fn ap_user(user: model::user::Model) -> serde_json::Value { .set_inbox(Node::maybe_link(user.inbox)) .set_outbox(Node::maybe_link(user.outbox)) .set_following(Node::maybe_link(user.following)) - // .set_following(Node::object( - // serde_json::Value::new_object() - // .set_id(user.following.as_deref()) - // .set_collection_type(Some(CollectionType::OrderedCollection)) - // .set_total_items(Some(user.following_count as u64)) - // )) .set_followers(Node::maybe_link(user.followers)) - // .set_followers(Node::object( - // serde_json::Value::new_object() - // .set_id(user.followers.as_deref()) - // .set_collection_type(Some(CollectionType::OrderedCollection)) - // .set_total_items(Some(user.followers_count as u64)) - // )) .set_public_key(Node::object( serde_json::Value::new_object() .set_id(Some(&format!("{}#main-key", user.id))) diff --git a/src/activitystream/node.rs b/src/activitystream/node.rs index 05cf7c1b..79b87e35 100644 --- a/src/activitystream/node.rs +++ b/src/activitystream/node.rs @@ -91,12 +91,12 @@ impl Node { } } - pub fn id(&self) -> Option<&str> { + pub fn id(&self) -> Option { match self { Node::Empty => None, - Node::Link(uri) => Some(uri.href()), - Node::Object(obj) => obj.id(), - Node::Array(arr) => arr.first()?.id(), + Node::Link(uri) => Some(uri.href().to_string()), + Node::Object(obj) => obj.id().map(|x| x.to_string()), + Node::Array(arr) => arr.first()?.id().map(|x| x.to_string()), } } } diff --git a/src/dispatcher.rs b/src/dispatcher.rs index 57581a68..907d480b 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -1,7 +1,4 @@ -use std::collections::BTreeMap; - use base64::Engine; -use http_signature_normalization::Config; use openssl::{hash::MessageDigest, pkey::{PKey, Private}, sign::Signer}; use reqwest::header::{CONTENT_TYPE, USER_AGENT}; use sea_orm::{ColumnTrait, Condition, DatabaseConnection, EntityTrait, Order, QueryFilter, QueryOrder};