Remove generic Error param from ObjectId functions

This commit is contained in:
Felix Ableitner 2022-06-02 14:42:29 +02:00
parent 73d34d8011
commit 5ba09005af
6 changed files with 7 additions and 9 deletions

View file

@ -6,7 +6,6 @@ use crate::{
}; };
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler}; use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
use activitystreams_kinds::activity::FollowType; use activitystreams_kinds::activity::FollowType;
use anyhow::Error;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
@ -67,7 +66,7 @@ impl ActivityHandler for Follow {
// send back an accept // send back an accept
let follower = self let follower = self
.actor .actor
.dereference::<Error>(data, data.local_instance(), request_counter) .dereference(data, data.local_instance(), request_counter)
.await?; .await?;
let id = generate_object_id(data.local_instance().hostname())?; let id = generate_object_id(data.local_instance().hostname())?;
let accept = Accept::new(local_user.ap_id.clone(), self, id.clone()); let accept = Accept::new(local_user.ap_id.clone(), self, id.clone());

View file

@ -97,7 +97,7 @@ async fn http_get_user(
let request_url = format!("http://{}{}", hostname, &request.uri().to_string()); let request_url = format!("http://{}{}", hostname, &request.uri().to_string());
let url = Url::parse(&request_url)?; let url = Url::parse(&request_url)?;
let user = ObjectId::<MyUser>::new(url) let user = ObjectId::<MyUser>::new(url)
.dereference_local::<Error>(&data) .dereference_local(&data)
.await? .await?
.into_apub(&data) .into_apub(&data)
.await?; .await?;

View file

@ -5,7 +5,6 @@ use activitypub_federation::{
traits::ApubObject, traits::ApubObject,
}; };
use activitystreams_kinds::{object::NoteType, public}; use activitystreams_kinds::{object::NoteType, public};
use anyhow::Error;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
@ -55,7 +54,7 @@ impl ApubObject for MyPost {
} }
async fn into_apub(self, data: &Self::DataType) -> Result<Self::ApubType, Self::Error> { async fn into_apub(self, data: &Self::DataType) -> Result<Self::ApubType, Self::Error> {
let creator = self.creator.dereference_local::<Error>(data).await?; let creator = self.creator.dereference_local(data).await?;
Ok(Note { Ok(Note {
kind: Default::default(), kind: Default::default(),
id: self.ap_id, id: self.ap_id,

View file

@ -102,7 +102,7 @@ impl MyUser {
let mut inboxes = vec![]; let mut inboxes = vec![];
for f in self.followers.clone() { for f in self.followers.clone() {
let user: MyUser = ObjectId::new(f) let user: MyUser = ObjectId::new(f)
.dereference::<Error>(instance, instance.local_instance(), &mut 0) .dereference(instance, instance.local_instance(), &mut 0)
.await?; .await?;
inboxes.push(user.inbox); inboxes.push(user.inbox);
} }

View file

@ -36,7 +36,7 @@ where
let request_counter = &mut 0; let request_counter = &mut 0;
let actor = ObjectId::<Actor>::new(activity.actor().clone()) let actor = ObjectId::<Actor>::new(activity.actor().clone())
.dereference::<E>(data, local_instance, request_counter) .dereference(data, local_instance, request_counter)
.await?; .await?;
verify_signature(&request, actor.public_key())?; verify_signature(&request, actor.public_key())?;

View file

@ -37,7 +37,7 @@ where
} }
/// Fetches an activitypub object, either from local database (if possible), or over http. /// Fetches an activitypub object, either from local database (if possible), or over http.
pub async fn dereference<E>( pub async fn dereference(
&self, &self,
data: &<Kind as ApubObject>::DataType, data: &<Kind as ApubObject>::DataType,
instance: &LocalInstance, instance: &LocalInstance,
@ -77,7 +77,7 @@ where
/// Fetch an object from the local db. Instead of falling back to http, this throws an error if /// Fetch an object from the local db. Instead of falling back to http, this throws an error if
/// the object is not found in the database. /// the object is not found in the database.
pub async fn dereference_local<E>( pub async fn dereference_local(
&self, &self,
data: &<Kind as ApubObject>::DataType, data: &<Kind as ApubObject>::DataType,
) -> Result<Kind, <Kind as ApubObject>::Error> ) -> Result<Kind, <Kind as ApubObject>::Error>