Compare commits
No commits in common. "baaaa55e9dfceee162f972b053156459bf36a259" and "f5d794824e7629d416a2dd92339cb66cd4ddc6f7" have entirely different histories.
baaaa55e9d
...
f5d794824e
6 changed files with 7 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
||||||
use apb::{BaseMut, CollectionMut, DocumentMut, ObjectMut, ObjectType};
|
use apb::{BaseMut, CollectionMut, DocumentMut, Object, ObjectMut, ObjectType};
|
||||||
use sea_orm::{entity::prelude::*, QuerySelect, SelectColumns};
|
use sea_orm::{entity::prelude::*, QuerySelect, SelectColumns};
|
||||||
|
|
||||||
use crate::ext::JsonVec;
|
use crate::ext::JsonVec;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use axum::{http::StatusCode, extract::{Path, Query, State}, Json};
|
use axum::{http::StatusCode, extract::{Path, Query, State}, Json};
|
||||||
use sea_orm::{ColumnTrait, Condition};
|
use sea_orm::{sea_query::IntoCondition, ColumnTrait};
|
||||||
|
|
||||||
use upub::Context;
|
use upub::Context;
|
||||||
|
|
||||||
|
@ -37,10 +37,7 @@ pub async fn page(
|
||||||
|
|
||||||
crate::builders::paginate_feed(
|
crate::builders::paginate_feed(
|
||||||
upub::url!(ctx, "/actors/{id}/inbox/page"),
|
upub::url!(ctx, "/actors/{id}/inbox/page"),
|
||||||
Condition::any()
|
upub::model::addressing::Column::Actor.eq(*internal).into_condition(),
|
||||||
.add(upub::model::addressing::Column::Actor.eq(*internal))
|
|
||||||
.add(upub::model::activity::Column::Actor.eq(uid))
|
|
||||||
.add(upub::model::object::Column::AttributedTo.eq(uid)),
|
|
||||||
ctx.db(),
|
ctx.db(),
|
||||||
page,
|
page,
|
||||||
auth.my_id(),
|
auth.my_id(),
|
||||||
|
|
|
@ -4,7 +4,7 @@ use reqwest::Method;
|
||||||
use sea_orm::{Condition, ColumnTrait};
|
use sea_orm::{Condition, ColumnTrait};
|
||||||
use upub::{traits::{Cloaker, Fetcher}, Context};
|
use upub::{traits::{Cloaker, Fetcher}, Context};
|
||||||
|
|
||||||
use crate::{builders::JsonLD, ApiError, AuthIdentity};
|
use crate::{builders::JsonLD, ApiError, AuthIdentity, Identity};
|
||||||
|
|
||||||
use super::{PaginatedSearch, Pagination};
|
use super::{PaginatedSearch, Pagination};
|
||||||
|
|
||||||
|
@ -56,11 +56,9 @@ pub async fn search(
|
||||||
.add(upub::model::object::Column::Content.like(format!("%{}%", page.q)));
|
.add(upub::model::object::Column::Content.like(format!("%{}%", page.q)));
|
||||||
|
|
||||||
// TODO lmao rethink this all
|
// TODO lmao rethink this all
|
||||||
// still haven't redone this gg me
|
|
||||||
let page = Pagination {
|
let page = Pagination {
|
||||||
offset: page.offset,
|
offset: page.offset,
|
||||||
batch: page.batch,
|
batch: page.batch,
|
||||||
replies: Some(true),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
crate::builders::paginate_feed(
|
crate::builders::paginate_feed(
|
||||||
|
|
|
@ -90,7 +90,6 @@ pub struct TryFetch {
|
||||||
pub struct Pagination {
|
pub struct Pagination {
|
||||||
pub offset: Option<u64>,
|
pub offset: Option<u64>,
|
||||||
pub batch: Option<u64>,
|
pub batch: Option<u64>,
|
||||||
pub replies: Option<bool>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
|
|
|
@ -38,15 +38,12 @@ pub async fn get(
|
||||||
pub async fn page(
|
pub async fn page(
|
||||||
State(ctx): State<Context>,
|
State(ctx): State<Context>,
|
||||||
Path(id): Path<String>,
|
Path(id): Path<String>,
|
||||||
Query(mut page): Query<Pagination>,
|
Query(page): Query<Pagination>,
|
||||||
AuthIdentity(auth): AuthIdentity,
|
AuthIdentity(auth): AuthIdentity,
|
||||||
) -> crate::ApiResult<JsonLD<serde_json::Value>> {
|
) -> crate::ApiResult<JsonLD<serde_json::Value>> {
|
||||||
let page_id = upub::url!(ctx, "/objects/{id}/replies/page");
|
let page_id = upub::url!(ctx, "/objects/{id}/replies/page");
|
||||||
let oid = ctx.oid(&id);
|
let oid = ctx.oid(&id);
|
||||||
|
|
||||||
// TODO kinda weird ignoring this but its weirder to exclude replies from replies view...
|
|
||||||
page.replies = Some(true);
|
|
||||||
|
|
||||||
crate::builders::paginate_feed(
|
crate::builders::paginate_feed(
|
||||||
page_id,
|
page_id,
|
||||||
Condition::all()
|
Condition::all()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use apb::{BaseMut, CollectionMut, CollectionPageMut, LD};
|
use apb::{BaseMut, CollectionMut, CollectionPageMut, LD};
|
||||||
use sea_orm::{Condition, ConnectionTrait, QueryFilter, QuerySelect, RelationTrait, ColumnTrait};
|
use sea_orm::{Condition, ConnectionTrait, QueryFilter, QuerySelect, RelationTrait};
|
||||||
use axum::response::{IntoResponse, Response};
|
use axum::response::{IntoResponse, Response};
|
||||||
use upub::selector::{BatchFillable, RichActivity};
|
use upub::selector::{BatchFillable, RichActivity};
|
||||||
|
|
||||||
|
@ -17,14 +17,6 @@ pub async fn paginate_feed(
|
||||||
let limit = page.batch.unwrap_or(20).min(50);
|
let limit = page.batch.unwrap_or(20).min(50);
|
||||||
let offset = page.offset.unwrap_or(0);
|
let offset = page.offset.unwrap_or(0);
|
||||||
|
|
||||||
let mut conditions = Condition::all()
|
|
||||||
.add(filter);
|
|
||||||
|
|
||||||
// by default we want replies because servers don't know about our api and want everything
|
|
||||||
if !page.replies.unwrap_or(true) {
|
|
||||||
conditions = conditions.add(upub::model::object::Column::InReplyTo.is_null());
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut select = upub::Query::feed(my_id);
|
let mut select = upub::Query::feed(my_id);
|
||||||
|
|
||||||
if with_users {
|
if with_users {
|
||||||
|
@ -33,7 +25,7 @@ pub async fn paginate_feed(
|
||||||
}
|
}
|
||||||
|
|
||||||
let items = select
|
let items = select
|
||||||
.filter(conditions)
|
.filter(filter)
|
||||||
// TODO also limit to only local activities
|
// TODO also limit to only local activities
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
|
|
Loading…
Reference in a new issue