From 64d7f25aa28daa18585d29e2c282a4e21e4e90b4 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 2 May 2024 15:29:42 +0200 Subject: [PATCH] fix: mastodon doesn't tell who likes are intended why cant you fill your to fields???????? mastodon is a joke --- src/server/inbox.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/server/inbox.rs b/src/server/inbox.rs index 54644c35..84eb03e1 100644 --- a/src/server/inbox.rs +++ b/src/server/inbox.rs @@ -1,6 +1,6 @@ use apb::{target::Addressed, Activity, Base, Object}; use reqwest::StatusCode; -use sea_orm::{sea_query::Expr, ActiveModelTrait, ColumnTrait, Condition, EntityTrait, IntoActiveModel, QueryFilter, Set}; +use sea_orm::{sea_query::Expr, ActiveModelTrait, ColumnTrait, Condition, EntityTrait, IntoActiveModel, QueryFilter, QuerySelect, SelectColumns, Set}; use crate::{errors::{LoggableError, UpubError}, model::{self, FieldError}}; @@ -98,7 +98,18 @@ impl apb::server::Inbox for Context { model::activity::Entity::insert(activity_model) .exec(self.db()) .await?; - let expanded_addressing = self.expand_addressing(activity.addressed()).await?; + let mut expanded_addressing = self.expand_addressing(activity.addressed()).await?; + if expanded_addressing.is_empty() { // WHY MASTODON!!!!!!! + expanded_addressing.push( + model::object::Entity::find_by_id(&oid) + .select_only() + .select_column(model::object::Column::AttributedTo) + .into_tuple::() + .one(self.db()) + .await? + .ok_or_else(UpubError::not_found)? + ); + } self.address_to(Some(aid), None, &expanded_addressing).await?; model::object::Entity::update_many() .col_expr(model::object::Column::Likes, Expr::col(model::object::Column::Likes).add(1))