feat: allow paginating content by actor audience
basically to browse lemmy communities
This commit is contained in:
parent
45da3a1684
commit
e707bf7344
3 changed files with 40 additions and 0 deletions
37
upub/routes/src/activitypub/actor/audience.rs
Normal file
37
upub/routes/src/activitypub/actor/audience.rs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
use axum::extract::{Path, Query, State};
|
||||||
|
use sea_orm::{Condition, ColumnTrait};
|
||||||
|
|
||||||
|
use upub::Context;
|
||||||
|
|
||||||
|
use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity, Identity};
|
||||||
|
|
||||||
|
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}/audience"),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn page(
|
||||||
|
State(ctx): State<Context>,
|
||||||
|
Path(id): Path<String>,
|
||||||
|
AuthIdentity(auth): AuthIdentity,
|
||||||
|
Query(page): Query<Pagination>,
|
||||||
|
) -> crate::ApiResult<JsonLD<serde_json::Value>> {
|
||||||
|
let filter = Condition::all()
|
||||||
|
.add(auth.filter())
|
||||||
|
.add(upub::model::object::Column::Audience.eq(ctx.uid(&id)));
|
||||||
|
|
||||||
|
crate::builders::paginate_feed(
|
||||||
|
upub::url!(ctx, "/actors/{id}/audience/page"),
|
||||||
|
filter,
|
||||||
|
ctx.db(),
|
||||||
|
page,
|
||||||
|
auth.my_id(),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ pub mod inbox;
|
||||||
pub mod outbox;
|
pub mod outbox;
|
||||||
pub mod following;
|
pub mod following;
|
||||||
pub mod notifications;
|
pub mod notifications;
|
||||||
|
pub mod audience;
|
||||||
|
|
||||||
use axum::extract::{Path, Query, State};
|
use axum::extract::{Path, Query, State};
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ impl ActivityPubRouter for Router<upub::Context> {
|
||||||
.route("/actors/:id/followers/page", get(ap::actor::following::page::<false>))
|
.route("/actors/:id/followers/page", get(ap::actor::following::page::<false>))
|
||||||
.route("/actors/:id/following", get(ap::actor::following::get::<true>))
|
.route("/actors/:id/following", get(ap::actor::following::get::<true>))
|
||||||
.route("/actors/:id/following/page", get(ap::actor::following::page::<true>))
|
.route("/actors/:id/following/page", get(ap::actor::following::page::<true>))
|
||||||
|
.route("/actors/:id/audience", get(ap::actor::audience::get))
|
||||||
|
.route("/actors/:id/audience/page", get(ap::actor::audience::page))
|
||||||
// activities
|
// activities
|
||||||
.route("/activities/:id", get(ap::activity::view))
|
.route("/activities/:id", get(ap::activity::view))
|
||||||
// specific object routes
|
// specific object routes
|
||||||
|
|
Loading…
Reference in a new issue