minor fix

This commit is contained in:
phiresky 2023-07-24 14:02:15 +00:00
parent bfa1e57f71
commit 3f511687d1
9 changed files with 20 additions and 30 deletions

View file

@ -8,7 +8,7 @@ use crate::{
},
activity_lists::AnnouncableActivities,
insert_received_activity,
objects::{instance::remote_instance_inboxes, person::ApubPerson},
objects::person::ApubPerson,
protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
};
use activitypub_federation::{

View file

@ -42,8 +42,8 @@ impl Object for SiteOrCommunityOrUser {
#[tracing::instrument(skip_all)]
async fn read_from_id(
object_id: Url,
data: &Data<Self::DataType>,
_object_id: Url,
_data: &Data<Self::DataType>,
) -> Result<Option<Self>, LemmyError> {
unimplemented!();
}
@ -75,7 +75,7 @@ impl Object for SiteOrCommunityOrUser {
}
#[tracing::instrument(skip_all)]
async fn from_json(apub: Self::Kind, data: &Data<Self::DataType>) -> Result<Self, LemmyError> {
async fn from_json(_apub: Self::Kind, _data: &Data<Self::DataType>) -> Result<Self, LemmyError> {
unimplemented!();
}
}

View file

@ -27,7 +27,7 @@ use lemmy_db_schema::{
site::{Site, SiteInsertForm},
},
traits::Crud,
utils::{naive_now, DbPool},
utils::naive_now,
};
use lemmy_utils::{
error::LemmyError,
@ -201,16 +201,6 @@ pub(in crate::objects) async fn fetch_instance_actor_for_object<T: Into<Url> + C
}
}
pub(crate) async fn remote_instance_inboxes(pool: &mut DbPool<'_>) -> Result<Vec<Url>, LemmyError> {
Ok(
Site::read_remote_sites(pool)
.await?
.into_iter()
.map(|s| ApubSite::from(s).shared_inbox_or_inbox())
.collect(),
)
}
#[cfg(test)]
pub(crate) mod tests {
#![allow(clippy::unwrap_used)]

View file

@ -113,7 +113,9 @@ mod tests {
ap_id: ap_id.clone(),
data: data.clone(),
sensitive,
actor_apub_id: Url::parse("http://example.com/u/exampleuser").unwrap(),
actor_apub_id: Url::parse("http://example.com/u/exampleuser")
.unwrap()
.into(),
actor_type: ActorType::Person,
send_targets: ActivitySendTargets::empty(),
};

View file

@ -803,7 +803,7 @@ diesel::table! {
published -> Timestamp,
send_targets -> Jsonb,
actor_type -> ActorTypeEnum,
actor_apub_id -> Text,
actor_apub_id -> Nullable<Text>,
}
}

View file

@ -74,7 +74,7 @@ pub struct SentActivity {
pub published: chrono::NaiveDateTime,
pub send_targets: ActivitySendTargets,
pub actor_type: ActorType,
pub actor_apub_id: DbUrl,
pub actor_apub_id: Option<DbUrl>,
}
#[derive(Insertable)]
#[diesel(table_name = sent_activity)]

View file

@ -103,7 +103,7 @@ pub async fn get_actor_cached(
Result::<_, anyhow::Error>::Ok(Arc::new(person))
})
.await
.map_err(|e| anyhow::anyhow!("err getting actor: {e}"))
.map_err(|e| anyhow::anyhow!("err getting actor: {e:?}"))
}
/// intern urls to reduce memory usage
@ -149,7 +149,7 @@ pub async fn get_activity_cached(
Ok(Some(Arc::new((row, activity_actual))))
})
.await
.map_err(|e| anyhow::anyhow!("err getting activity: {e}"))
.map_err(|e| anyhow::anyhow!("err getting activity: {e:?}"))
}
/// return the most current activity id (with 1 second cache)
@ -170,7 +170,7 @@ pub async fn get_latest_activity_id(pool: &mut DbPool<'_>) -> Result<ActivityId>
anyhow::Result::<_, anyhow::Error>::Ok(latest_id as ActivityId)
})
.await
.map_err(|e| anyhow::anyhow!("err getting id: {e}"))
.map_err(|e| anyhow::anyhow!("err getting id: {e:?}"))
}
/// how long to sleep based on how many retries have already happened

View file

@ -93,12 +93,10 @@ pub async fn instance_worker(
state.last_successful_id = id;
continue;
}
let actor = get_actor_cached(
&mut pool,
activity.actor_type,
activity.actor_apub_id.deref(),
)
.await?;
let Some(actor_apub_id) = &activity.actor_apub_id else {
continue; // activity was inserted before persistent queue was activated
};
let actor = get_actor_cached(&mut pool, activity.actor_type, actor_apub_id).await?;
let inbox_urls = inbox_urls.into_iter().map(|e| (*e).clone()).collect();
let requests = prepare_raw(object, actor.as_ref(), inbox_urls, &data)

View file

@ -4,15 +4,15 @@ CREATE TYPE actor_type_enum AS enum(
'person'
);
-- actor_apub_id only null for old entries
ALTER TABLE sent_activity
ADD COLUMN send_targets jsonb NOT NULL DEFAULT '{"inboxes": [], "community_followers_of": [], "all_instances": false}',
ADD COLUMN actor_type actor_type_enum NOT NULL DEFAULT 'person',
ADD COLUMN actor_apub_id text NOT NULL DEFAULT '';
ADD COLUMN actor_apub_id text DEFAULT NULL;
ALTER TABLE sent_activity
ALTER COLUMN send_targets DROP DEFAULT,
ALTER COLUMN actor_type DROP DEFAULT,
ALTER COLUMN actor_apub_id DROP DEFAULT;
ALTER COLUMN actor_type DROP DEFAULT;
CREATE TABLE federation_queue_state(
domain text PRIMARY KEY,