1
0
Fork 0
forked from alemi/upub

fix: Node::id() returns owned value, imports fix

This commit is contained in:
əlemi 2024-03-27 03:23:54 +01:00
parent b37d799f59
commit f83103ba72
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 5 additions and 20 deletions

View file

@ -8,7 +8,7 @@ pub use following::follow___;
use axum::{extract::{Path, State}, http::StatusCode}; use axum::{extract::{Path, State}, http::StatusCode};
use sea_orm::EntityTrait; 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}; 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_inbox(Node::maybe_link(user.inbox))
.set_outbox(Node::maybe_link(user.outbox)) .set_outbox(Node::maybe_link(user.outbox))
.set_following(Node::maybe_link(user.following)) .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::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( .set_public_key(Node::object(
serde_json::Value::new_object() serde_json::Value::new_object()
.set_id(Some(&format!("{}#main-key", user.id))) .set_id(Some(&format!("{}#main-key", user.id)))

View file

@ -91,12 +91,12 @@ impl<T : super::Base> Node<T> {
} }
} }
pub fn id(&self) -> Option<&str> { pub fn id(&self) -> Option<String> {
match self { match self {
Node::Empty => None, Node::Empty => None,
Node::Link(uri) => Some(uri.href()), Node::Link(uri) => Some(uri.href().to_string()),
Node::Object(obj) => obj.id(), Node::Object(obj) => obj.id().map(|x| x.to_string()),
Node::Array(arr) => arr.first()?.id(), Node::Array(arr) => arr.first()?.id().map(|x| x.to_string()),
} }
} }
} }

View file

@ -1,7 +1,4 @@
use std::collections::BTreeMap;
use base64::Engine; use base64::Engine;
use http_signature_normalization::Config;
use openssl::{hash::MessageDigest, pkey::{PKey, Private}, sign::Signer}; use openssl::{hash::MessageDigest, pkey::{PKey, Private}, sign::Signer};
use reqwest::header::{CONTENT_TYPE, USER_AGENT}; use reqwest::header::{CONTENT_TYPE, USER_AGENT};
use sea_orm::{ColumnTrait, Condition, DatabaseConnection, EntityTrait, Order, QueryFilter, QueryOrder}; use sea_orm::{ColumnTrait, Condition, DatabaseConnection, EntityTrait, Order, QueryFilter, QueryOrder};