Compare commits

..

2 commits

Author SHA1 Message Date
781619a899
chore: removed filter_objects 2024-07-02 01:55:37 +02:00
056be56843
feat: logged in users can see their full outbox 2024-07-02 01:51:58 +02:00
5 changed files with 14 additions and 22 deletions

View file

@ -25,7 +25,7 @@ pub async fn view(
let row = upub::Query::feed(auth.my_id()) let row = upub::Query::feed(auth.my_id())
.filter(model::activity::Column::Id.eq(&aid)) .filter(model::activity::Column::Id.eq(&aid))
.filter(auth.filter_activities()) .filter(auth.filter())
.into_model::<RichActivity>() .into_model::<RichActivity>()
.one(ctx.db()) .one(ctx.db())
.await? .await?

View file

@ -19,14 +19,18 @@ pub async fn page(
AuthIdentity(auth): AuthIdentity, AuthIdentity(auth): AuthIdentity,
) -> crate::ApiResult<JsonLD<serde_json::Value>> { ) -> crate::ApiResult<JsonLD<serde_json::Value>> {
let uid = ctx.uid(&id); let uid = ctx.uid(&id);
crate::builders::paginate_feed( let mut filter = Condition::all()
upub::url!(ctx, "/actors/{id}/outbox/page"), .add(
Condition::all() Condition::any()
.add(auth.filter_activities())
.add(Condition::any()
.add(model::activity::Column::Actor.eq(&uid)) .add(model::activity::Column::Actor.eq(&uid))
.add(model::object::Column::AttributedTo.eq(&uid)) .add(model::object::Column::AttributedTo.eq(&uid))
), );
if !auth.is(&uid) {
filter = filter.add(auth.filter());
}
crate::builders::paginate_feed(
upub::url!(ctx, "/actors/{id}/outbox/page"),
filter,
ctx.db(), ctx.db(),
page, page,
auth.my_id(), auth.my_id(),

View file

@ -21,7 +21,7 @@ pub async fn page(
) -> crate::ApiResult<JsonLD<serde_json::Value>> { ) -> crate::ApiResult<JsonLD<serde_json::Value>> {
crate::builders::paginate_feed( crate::builders::paginate_feed(
upub::url!(ctx, "/inbox/page"), upub::url!(ctx, "/inbox/page"),
auth.filter_activities(), auth.filter(),
ctx.db(), ctx.db(),
page, page,
auth.my_id(), auth.my_id(),

View file

@ -16,7 +16,7 @@ pub async fn page(
crate::builders::paginate_feed( crate::builders::paginate_feed(
upub::url!(ctx, "/outbox/page"), upub::url!(ctx, "/outbox/page"),
Condition::all() Condition::all()
.add(auth.filter_activities()) .add(auth.filter())
.add(upub::model::actor::Column::Domain.eq(ctx.domain().to_string())), .add(upub::model::actor::Column::Domain.eq(ctx.domain().to_string())),
ctx.db(), ctx.db(),
page, page,

View file

@ -20,7 +20,7 @@ pub enum Identity {
} }
impl Identity { impl Identity {
pub fn filter_activities(&self) -> Condition { pub fn filter(&self) -> Condition {
let base_cond = Condition::any().add(upub::model::addressing::Column::Actor.is_null()); let base_cond = Condition::any().add(upub::model::addressing::Column::Actor.is_null());
match self { match self {
Identity::Anonymous => base_cond, Identity::Anonymous => base_cond,
@ -29,18 +29,6 @@ impl Identity {
} }
} }
pub fn filter_objects(&self) -> Condition {
let base_cond = Condition::any().add(upub::model::addressing::Column::Actor.is_null());
match self {
Identity::Anonymous => base_cond,
Identity::Remote { internal, .. } => base_cond.add(upub::model::addressing::Column::Instance.eq(*internal)),
// TODO should we allow all users on same server to see? or just specific user??
Identity::Local { id, internal } => base_cond
.add(upub::model::addressing::Column::Actor.eq(*internal))
.add(upub::model::object::Column::AttributedTo.eq(id)),
}
}
pub fn my_id(&self) -> Option<i64> { pub fn my_id(&self) -> Option<i64> {
match self { match self {
Identity::Local { internal, .. } => Some(*internal), Identity::Local { internal, .. } => Some(*internal),