Apply visibility checks to parent notes and renote targets
ci/woodpecker/push/ociImagePush Pipeline is running
Details
ci/woodpecker/push/ociImagePush Pipeline is running
Details
This commit is contained in:
parent
811fecf99a
commit
3b1eab8069
|
@ -10,6 +10,14 @@ pub(crate) trait SelectColumnsExt {
|
||||||
rel: RelationDef,
|
rel: RelationDef,
|
||||||
alias: I,
|
alias: I,
|
||||||
) -> &mut Self;
|
) -> &mut Self;
|
||||||
|
|
||||||
|
fn join_columns_on<I: IntoIden>(
|
||||||
|
&mut self,
|
||||||
|
join: JoinType,
|
||||||
|
rel: RelationDef,
|
||||||
|
alias: I,
|
||||||
|
condition: Condition,
|
||||||
|
) -> &mut Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn join_columns_default(rel: RelationDef) -> Condition {
|
pub(crate) fn join_columns_default(rel: RelationDef) -> Condition {
|
||||||
|
@ -62,6 +70,19 @@ impl SelectColumnsExt for SelectStatement {
|
||||||
self.join(join, rel.to_tbl.clone(), join_columns_default(rel));
|
self.join(join, rel.to_tbl.clone(), join_columns_default(rel));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn join_columns_on<I: IntoIden>(
|
||||||
|
&mut self,
|
||||||
|
join: JoinType,
|
||||||
|
mut rel: RelationDef,
|
||||||
|
alias: I,
|
||||||
|
condition: Condition,
|
||||||
|
) -> &mut Self {
|
||||||
|
let alias = alias.into_iden();
|
||||||
|
rel.to_tbl = rel.to_tbl.alias(alias);
|
||||||
|
self.join(join, rel.to_tbl.clone(), condition);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn joined_prefix_str(prefix: &str, suffix: &str) -> String {
|
pub(crate) fn joined_prefix_str(prefix: &str, suffix: &str) -> String {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use ext_calckey_model_migration::SelectStatement;
|
use ext_calckey_model_migration::SelectStatement;
|
||||||
use sea_orm::sea_query::{Alias, Asterisk, Expr, IntoIden, Query, SelectExpr, SimpleExpr};
|
use sea_orm::sea_query::{Alias, Asterisk, Expr, IntoIden, Query, SelectExpr, SimpleExpr};
|
||||||
use sea_orm::{
|
use sea_orm::{
|
||||||
DbErr, EntityName, EntityTrait, FromQueryResult, Iden, JoinType, QueryFilter, QueryOrder,
|
Condition, DbErr, EntityName, EntityTrait, FromQueryResult, Iden, JoinType, QueryFilter,
|
||||||
QueryResult, QuerySelect, QueryTrait, Select,
|
QueryOrder, QueryResult, QuerySelect, QueryTrait, Select,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ use ck::{note, note_reaction, user, user_note_pining};
|
||||||
use magnetar_sdk::types::SpanFilter;
|
use magnetar_sdk::types::SpanFilter;
|
||||||
|
|
||||||
use crate::model_ext::{
|
use crate::model_ext::{
|
||||||
joined_prefix, joined_prefix_alias, joined_prefix_str, EntityPrefixExt, SelectColumnsExt,
|
join_columns_default, joined_prefix, joined_prefix_alias, joined_prefix_str, EntityPrefixExt,
|
||||||
|
SelectColumnsExt,
|
||||||
};
|
};
|
||||||
use crate::paginated::PaginatedModel;
|
use crate::paginated::PaginatedModel;
|
||||||
use crate::user_model::{UserData, UserResolver};
|
use crate::user_model::{UserData, UserResolver};
|
||||||
|
@ -291,10 +292,19 @@ impl NoteResolver {
|
||||||
|
|
||||||
// Recursively attach reply parents
|
// Recursively attach reply parents
|
||||||
if reply_depth > 0 {
|
if reply_depth > 0 {
|
||||||
q.join_columns(
|
let visibility_filter = options
|
||||||
|
.visibility_filter
|
||||||
|
.with_note_and_user_tables(Some(joined_prefix_alias(prefix, REPLY)));
|
||||||
|
let mut rel = note::Relation::SelfRef2.with_alias(Alias::new(prefix).into_iden());
|
||||||
|
rel.to_tbl = rel.to_tbl.alias(joined_prefix_alias(prefix, REPLY));
|
||||||
|
let condition = Condition::all()
|
||||||
|
.add(join_columns_default(rel))
|
||||||
|
.add(visibility_filter);
|
||||||
|
q.join_columns_on(
|
||||||
JoinType::LeftJoin,
|
JoinType::LeftJoin,
|
||||||
note::Relation::SelfRef2.with_alias(Alias::new(prefix).into_iden()),
|
note::Relation::SelfRef2.with_alias(Alias::new(prefix).into_iden()),
|
||||||
joined_prefix(prefix, REPLY),
|
joined_prefix(prefix, REPLY),
|
||||||
|
condition,
|
||||||
);
|
);
|
||||||
|
|
||||||
self.attach_note(
|
self.attach_note(
|
||||||
|
@ -309,10 +319,19 @@ impl NoteResolver {
|
||||||
|
|
||||||
// Recursively attach renote/quote targets
|
// Recursively attach renote/quote targets
|
||||||
if renote_depth > 0 {
|
if renote_depth > 0 {
|
||||||
q.join_columns(
|
let visibility_filter = options
|
||||||
|
.visibility_filter
|
||||||
|
.with_note_and_user_tables(Some(joined_prefix_alias(prefix, RENOTE)));
|
||||||
|
let mut rel = note::Relation::SelfRef1.with_alias(Alias::new(prefix).into_iden());
|
||||||
|
rel.to_tbl = rel.to_tbl.alias(joined_prefix_alias(prefix, RENOTE));
|
||||||
|
let condition = Condition::all()
|
||||||
|
.add(join_columns_default(rel))
|
||||||
|
.add(visibility_filter);
|
||||||
|
q.join_columns_on(
|
||||||
JoinType::LeftJoin,
|
JoinType::LeftJoin,
|
||||||
note::Relation::SelfRef1.with_alias(Alias::new(prefix).into_iden()),
|
note::Relation::SelfRef1.with_alias(Alias::new(prefix).into_iden()),
|
||||||
joined_prefix(prefix, RENOTE),
|
joined_prefix(prefix, RENOTE),
|
||||||
|
condition,
|
||||||
);
|
);
|
||||||
|
|
||||||
self.attach_note(
|
self.attach_note(
|
||||||
|
|
Loading…
Reference in New Issue