Compare commits

...

2 commits

Author SHA1 Message Date
b097e4a725
feat: outbox shows only local posts
hopefully?
2024-05-29 04:56:10 +02:00
3e7d6adeb8
feat(web): added local timeline 2024-05-29 04:47:26 +02:00
9 changed files with 23 additions and 3 deletions

View file

@ -36,6 +36,7 @@ pub async fn page(
ctx.db(), ctx.db(),
page, page,
auth.my_id(), auth.my_id(),
false,
) )
.await .await
} }

View file

@ -25,6 +25,7 @@ pub async fn page(
ctx.db(), ctx.db(),
page, page,
auth.my_id(), auth.my_id(),
false,
) )
.await .await
} }

View file

@ -42,6 +42,7 @@ pub async fn page(
ctx.db(), ctx.db(),
page, page,
auth.my_id(), auth.my_id(),
false,
) )
.await .await
} }

View file

@ -1,4 +1,5 @@
use axum::{extract::{Query, State}, http::StatusCode, Json}; 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}; 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::Result<JsonLD<serde_json::Value>> {
crate::server::builders::paginate( crate::server::builders::paginate(
url!(ctx, "/outbox/page"), 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(), ctx.db(),
page, page,
auth.my_id(), auth.my_id(),
true,
) )
.await .await
} }

View file

@ -42,6 +42,7 @@ pub async fn page(
ctx.db(), ctx.db(),
page, page,
auth.my_id(), auth.my_id(),
false,
) )
.await .await
} }

View file

@ -30,6 +30,7 @@ pub async fn page(
ctx.db(), ctx.db(),
page, page,
auth.my_id(), auth.my_id(),
false,
) )
.await .await
} }

View file

@ -1,5 +1,5 @@
use apb::{BaseMut, CollectionMut, CollectionPageMut}; 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}}; use crate::{model::{addressing::Event, attachment::BatchFillable}, routes::activitypub::{jsonld::LD, JsonLD, Pagination}};
@ -9,11 +9,19 @@ pub async fn paginate(
db: &DatabaseConnection, db: &DatabaseConnection,
page: Pagination, page: Pagination,
my_id: Option<i64>, my_id: Option<i64>,
with_users: bool, // TODO ewww too many arguments for this weird function...
) -> crate::Result<JsonLD<serde_json::Value>> { ) -> crate::Result<JsonLD<serde_json::Value>> {
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 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) .filter(filter)
// TODO also limit to only local activities // TODO also limit to only local activities
.limit(limit) .limit(limit)

View file

@ -21,6 +21,7 @@ pub fn App() -> impl IntoView {
.unwrap_or_default(); .unwrap_or_default();
let home_tl = Timeline::new(format!("{URL_BASE}/users/{username}/inbox/page")); let home_tl = Timeline::new(format!("{URL_BASE}/users/{username}/inbox/page"));
let server_tl = Timeline::new(format!("{URL_BASE}/inbox/page")); let server_tl = Timeline::new(format!("{URL_BASE}/inbox/page"));
let local_tl = Timeline::new(format!("{URL_BASE}/outbox/page"));
let user_tl = Timeline::new(format!("{URL_BASE}/users/{username}/outbox/page")); let user_tl = Timeline::new(format!("{URL_BASE}/users/{username}/outbox/page"));
let context_tl = Timeline::new(format!("{URL_BASE}/outbox/page")); let context_tl = Timeline::new(format!("{URL_BASE}/outbox/page"));
@ -120,6 +121,7 @@ pub fn App() -> impl IntoView {
<Route path="/web/home" view=move || view! { <TimelinePage name="home" tl=home_tl /> } /> <Route path="/web/home" view=move || view! { <TimelinePage name="home" tl=home_tl /> } />
<Route path="/web/server" view=move || view! { <TimelinePage name="server" tl=server_tl /> } /> <Route path="/web/server" view=move || view! { <TimelinePage name="server" tl=server_tl /> } />
<Route path="/web/local" view=move || view! { <TimelinePage name="server" tl=local_tl /> } />
<Route path="/web/about" view=AboutPage /> <Route path="/web/about" view=AboutPage />
<Route path="/web/config" view=move || view! { <ConfigPage setter=set_config /> } /> <Route path="/web/config" view=move || view! { <ConfigPage setter=set_config /> } />

View file

@ -39,6 +39,7 @@ pub fn Navigator() -> impl IntoView {
<table class="align w-100"> <table class="align w-100">
<tr><td colspan="2"><a href="/web/home"><input class="w-100" type="submit" class:hidden=move || !auth.present() value="home timeline" /></a></td></tr> <tr><td colspan="2"><a href="/web/home"><input class="w-100" type="submit" class:hidden=move || !auth.present() value="home timeline" /></a></td></tr>
<tr><td colspan="2"><a href="/web/server"><input class="w-100" type="submit" value="server timeline" /></a></td></tr> <tr><td colspan="2"><a href="/web/server"><input class="w-100" type="submit" value="server timeline" /></a></td></tr>
<tr><td colspan="2"><a href="/web/local"><input class="w-100" type="submit" value="local timeline" /></a></td></tr>
<tr> <tr>
<td class="w-50"><a href="/web/about"><input class="w-100" type="submit" value="about" /></a></td> <td class="w-50"><a href="/web/about"><input class="w-100" type="submit" value="about" /></a></td>
<td class="w-50"><a href="/web/config"><input class="w-100" type="submit" value="config" /></a></td> <td class="w-50"><a href="/web/config"><input class="w-100" type="submit" value="config" /></a></td>