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 activitystreams_kinds::activity::FollowType;
use anyhow::Error;
use serde::{Deserialize, Serialize};
use url::Url;
@ -67,7 +66,7 @@ impl ActivityHandler for Follow {
// send back an accept
let follower = self
.actor
.dereference::<Error>(data, data.local_instance(), request_counter)
.dereference(data, data.local_instance(), request_counter)
.await?;
let id = generate_object_id(data.local_instance().hostname())?;
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 url = Url::parse(&request_url)?;
let user = ObjectId::<MyUser>::new(url)
.dereference_local::<Error>(&data)
.dereference_local(&data)
.await?
.into_apub(&data)
.await?;

View file

@ -5,7 +5,6 @@ use activitypub_federation::{
traits::ApubObject,
};
use activitystreams_kinds::{object::NoteType, public};
use anyhow::Error;
use serde::{Deserialize, Serialize};
use url::Url;
@ -55,7 +54,7 @@ impl ApubObject for MyPost {
}
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 {
kind: Default::default(),
id: self.ap_id,

View file

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

View file

@ -36,7 +36,7 @@ where
let request_counter = &mut 0;
let actor = ObjectId::<Actor>::new(activity.actor().clone())
.dereference::<E>(data, local_instance, request_counter)
.dereference(data, local_instance, request_counter)
.await?;
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.
pub async fn dereference<E>(
pub async fn dereference(
&self,
data: &<Kind as ApubObject>::DataType,
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
/// the object is not found in the database.
pub async fn dereference_local<E>(
pub async fn dereference_local(
&self,
data: &<Kind as ApubObject>::DataType,
) -> Result<Kind, <Kind as ApubObject>::Error>