chore: removed filter_objects

This commit is contained in:
əlemi 2024-07-02 01:54:07 +02:00
parent 056be56843
commit 781619a899
Signed by: alemi
GPG key ID: A4895B84D311642C
5 changed files with 5 additions and 17 deletions

View file

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

View file

@ -26,7 +26,7 @@ pub async fn page(
.add(model::object::Column::AttributedTo.eq(&uid))
);
if !auth.is(&uid) {
filter = filter.add(auth.filter_activities());
filter = filter.add(auth.filter());
}
crate::builders::paginate_feed(
upub::url!(ctx, "/actors/{id}/outbox/page"),

View file

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

View file

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

View file

@ -20,7 +20,7 @@ pub enum 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());
match self {
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> {
match self {
Identity::Local { internal, .. } => Some(*internal),