forked from alemi/upub
feat: outbox shows only local posts
hopefully?
This commit is contained in:
parent
3e7d6adeb8
commit
b097e4a725
7 changed files with 20 additions and 3 deletions
|
@ -36,6 +36,7 @@ pub async fn page(
|
|||
ctx.db(),
|
||||
page,
|
||||
auth.my_id(),
|
||||
false,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ pub async fn page(
|
|||
ctx.db(),
|
||||
page,
|
||||
auth.my_id(),
|
||||
false,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ pub async fn page(
|
|||
ctx.db(),
|
||||
page,
|
||||
auth.my_id(),
|
||||
false,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use axum::{extract::{Query, State}, http::StatusCode, Json};
|
||||
use sea_orm::{ColumnTrait, Condition};
|
||||
|
||||
use crate::{errors::UpubError, routes::activitypub::{CreationResult, JsonLD, Pagination}, server::{auth::AuthIdentity, Context}, url};
|
||||
|
||||
|
@ -13,10 +14,13 @@ pub async fn page(
|
|||
) -> crate::Result<JsonLD<serde_json::Value>> {
|
||||
crate::server::builders::paginate(
|
||||
url!(ctx, "/outbox/page"),
|
||||
auth.filter_condition(), // TODO filter local only stuff
|
||||
Condition::all()
|
||||
.add(auth.filter_condition())
|
||||
.add(crate::model::actor::Column::Domain.eq(ctx.domain().to_string())),
|
||||
ctx.db(),
|
||||
page,
|
||||
auth.my_id(),
|
||||
true,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ pub async fn page(
|
|||
ctx.db(),
|
||||
page,
|
||||
auth.my_id(),
|
||||
false,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ pub async fn page(
|
|||
ctx.db(),
|
||||
page,
|
||||
auth.my_id(),
|
||||
false,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use apb::{BaseMut, CollectionMut, CollectionPageMut};
|
||||
use sea_orm::{Condition, DatabaseConnection, QueryFilter, QuerySelect};
|
||||
use sea_orm::{Condition, DatabaseConnection, QueryFilter, QuerySelect, RelationTrait};
|
||||
|
||||
use crate::{model::{addressing::Event, attachment::BatchFillable}, routes::activitypub::{jsonld::LD, JsonLD, Pagination}};
|
||||
|
||||
|
@ -9,11 +9,19 @@ pub async fn paginate(
|
|||
db: &DatabaseConnection,
|
||||
page: Pagination,
|
||||
my_id: Option<i64>,
|
||||
with_users: bool, // TODO ewww too many arguments for this weird function...
|
||||
) -> crate::Result<JsonLD<serde_json::Value>> {
|
||||
let limit = page.batch.unwrap_or(20).min(50);
|
||||
let offset = page.offset.unwrap_or(0);
|
||||
|
||||
let items = crate::model::addressing::Entity::find_addressed(my_id)
|
||||
let mut select = crate::model::addressing::Entity::find_addressed(my_id);
|
||||
|
||||
if with_users {
|
||||
select = select
|
||||
.join(sea_orm::JoinType::InnerJoin, crate::model::activity::Relation::Actors.def());
|
||||
}
|
||||
|
||||
let items = select
|
||||
.filter(filter)
|
||||
// TODO also limit to only local activities
|
||||
.limit(limit)
|
||||
|
|
Loading…
Reference in a new issue