Compare commits

...

3 commits

Author SHA1 Message Date
8890538c69
chore: stubbed hashtags routes 2024-06-22 04:34:34 +02:00
ee12ef37ad
chore: better comments, unreachable!() 2024-06-22 04:34:22 +02:00
62628ea076
fix: for batch loading use object id 2024-06-22 04:34:00 +02:00
3 changed files with 9 additions and 6 deletions

View file

@ -343,19 +343,19 @@ mod hell {
impl BatchFillableKey for crate::model::attachment::Model { impl BatchFillableKey for crate::model::attachment::Model {
fn key(&self) -> i64 { fn key(&self) -> i64 {
self.internal self.object
} }
} }
impl BatchFillableKey for crate::model::mention::Model { impl BatchFillableKey for crate::model::mention::Model {
fn key(&self) -> i64 { fn key(&self) -> i64 {
self.internal self.object
} }
} }
impl BatchFillableKey for crate::model::hashtag::Model { impl BatchFillableKey for crate::model::hashtag::Model {
fn key(&self) -> i64 { fn key(&self) -> i64 {
self.internal self.object
} }
} }

View file

@ -389,13 +389,13 @@ pub async fn announce(ctx: &crate::Context, activity: impl apb::Activity, tx: &D
} }
} }
} { } {
crate::context::Internal::Activity(_) => unreachable!(),
crate::context::Internal::Actor(_) => Err(ProcessorError::Unprocessable(activity.id()?.to_string())), crate::context::Internal::Actor(_) => Err(ProcessorError::Unprocessable(activity.id()?.to_string())),
crate::context::Internal::Activity(_) => Err(ProcessorError::AlreadyProcessed), // ???
crate::context::Internal::Object(internal) => { crate::context::Internal::Object(internal) => {
let actor = ctx.fetch_user(activity.actor().id()?, tx).await?; let actor = ctx.fetch_user(activity.actor().id()?, tx).await?;
// we only care about "organic" announces, as in those produced by people // we only care about announces produced by "Person" actors, because there's intention
// anything shared by groups, services or applications is just mirroring: fetch it and be done // anything shared by groups, services or applications is automated: fetch it and be done
if actor.actor_type == apb::ActorType::Person { if actor.actor_type == apb::ActorType::Person {
let share = crate::model::announce::ActiveModel { let share = crate::model::announce::ActiveModel {
internal: NotSet, internal: NotSet,

View file

@ -71,6 +71,9 @@ impl ActivityPubRouter for Router<upub::Context> {
//.route("/objects/:id/likes/page", get(ap::object::likes::page)) //.route("/objects/:id/likes/page", get(ap::object::likes::page))
//.route("/objects/:id/shares", get(ap::object::announces::get)) //.route("/objects/:id/shares", get(ap::object::announces::get))
//.route("/objects/:id/shares/page", get(ap::object::announces::page)) //.route("/objects/:id/shares/page", get(ap::object::announces::page))
// hashtags routes
//.route("/hashtags/:name", get(ap::hashtags::get))
//.route("/hashtags/:name/page", get(ap::hashtags::page))
} }
} }