fix: respect likes privacy, default to show remote
we don't get likes we're not supposed to know of anyway, so we can assume remote users are ok with us showing these things they liked?
This commit is contained in:
parent
b1cf349805
commit
7befb83dcd
1 changed files with 8 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
use axum::extract::{Path, Query, State};
|
||||
use sea_orm::{ColumnTrait, QueryFilter, QueryOrder, QuerySelect, RelationTrait};
|
||||
|
||||
use upub::{model, selector::{RichObject, BatchFillable}, Context};
|
||||
use upub::{model, selector::{RichFillable, RichObject}, Context};
|
||||
|
||||
use crate::{activitypub::Pagination, builders::JsonLD, ApiError, AuthIdentity};
|
||||
|
||||
|
@ -9,7 +9,7 @@ pub async fn get(
|
|||
State(ctx): State<Context>,
|
||||
Path(id): Path<String>,
|
||||
) -> crate::ApiResult<JsonLD<serde_json::Value>> {
|
||||
crate::builders::collection(upub::url!(ctx, "/actors/{id}/liked"), None)
|
||||
crate::builders::collection(upub::url!(ctx, "/actors/{id}/likes"), None)
|
||||
}
|
||||
|
||||
pub async fn page(
|
||||
|
@ -25,15 +25,16 @@ pub async fn page(
|
|||
.await?
|
||||
.ok_or_else(ApiError::not_found)?;
|
||||
|
||||
if !auth.is(&uid) && !config.map_or(false, |x| x.show_liked_objects) {
|
||||
if !auth.is(&uid) && !config.map_or(true, |x| x.show_liked_objects) {
|
||||
return Err(ApiError::forbidden());
|
||||
}
|
||||
|
||||
let (limit, offset) = page.pagination();
|
||||
|
||||
let items : Vec<serde_json::Value> = upub::Query::objects(auth.my_id(), true)
|
||||
.join(sea_orm::JoinType::InnerJoin, upub::model::object::Relation::Likes.def())
|
||||
.filter(auth.filter_objects())
|
||||
.join(sea_orm::JoinType::InnerJoin, upub::model::like::Relation::Objects.def())
|
||||
.join(sea_orm::JoinType::InnerJoin, upub::model::activity::Relation::Likes.def())
|
||||
.filter(auth.filter_activities())
|
||||
.filter(upub::model::like::Column::Actor.eq(user.internal))
|
||||
.order_by_desc(upub::model::like::Column::Published)
|
||||
.limit(limit)
|
||||
|
@ -41,15 +42,11 @@ pub async fn page(
|
|||
.into_model::<RichObject>()
|
||||
.all(ctx.db())
|
||||
.await?
|
||||
.with_batched::<upub::model::attachment::Entity>(ctx.db())
|
||||
.await?
|
||||
.with_batched::<upub::model::mention::Entity>(ctx.db())
|
||||
.await?
|
||||
.with_batched::<upub::model::hashtag::Entity>(ctx.db())
|
||||
.load_batched_models(ctx.db())
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|x| ctx.ap(x))
|
||||
.collect();
|
||||
|
||||
crate::builders::collection_page(&upub::url!(ctx, "/actors/{id}/outbox/page"), page, apb::Node::array(items))
|
||||
crate::builders::collection_page(&upub::url!(ctx, "/actors/{id}/likes/page"), page, apb::Node::array(items))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue