Resolve avatar and banner separately
ci/woodpecker/push/ociImagePush Pipeline is running
Details
ci/woodpecker/push/ociImagePush Pipeline is running
Details
This commit is contained in:
parent
185262eb05
commit
b9f0f33b3c
|
@ -6,8 +6,9 @@ use sea_orm::{
|
||||||
Condition, EntityTrait, Iden, JoinType, QueryFilter, QueryOrder, QuerySelect, QueryTrait,
|
Condition, EntityTrait, Iden, JoinType, QueryFilter, QueryOrder, QuerySelect, QueryTrait,
|
||||||
Select,
|
Select,
|
||||||
};
|
};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ck::{note, note_reaction, user, user_note_pining};
|
use ck::{note, note_reaction, user_note_pining};
|
||||||
use data::{sub_interaction_reaction, sub_interaction_renote, NoteData};
|
use data::{sub_interaction_reaction, sub_interaction_renote, NoteData};
|
||||||
use magnetar_sdk::types::SpanFilter;
|
use magnetar_sdk::types::SpanFilter;
|
||||||
|
|
||||||
|
@ -35,9 +36,10 @@ pub trait NoteVisibilityFilterFactory: Send + Sync {
|
||||||
fn with_note_and_user_tables(&self, note: &dyn Iden) -> SimpleExpr;
|
fn with_note_and_user_tables(&self, note: &dyn Iden) -> SimpleExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct NoteResolveOptions {
|
pub struct NoteResolveOptions {
|
||||||
pub ids: Option<Vec<String>>,
|
pub ids: Option<Vec<String>>,
|
||||||
pub visibility_filter: Box<dyn NoteVisibilityFilterFactory>,
|
pub visibility_filter: Arc<dyn NoteVisibilityFilterFactory>,
|
||||||
pub time_range: Option<SpanFilter>,
|
pub time_range: Option<SpanFilter>,
|
||||||
pub limit: Option<u64>,
|
pub limit: Option<u64>,
|
||||||
pub with_reply_target: bool,
|
pub with_reply_target: bool,
|
||||||
|
@ -221,7 +223,6 @@ impl NoteResolver {
|
||||||
|
|
||||||
// Add the note's author
|
// Add the note's author
|
||||||
let user_tbl = note_tbl.join_str(USER);
|
let user_tbl = note_tbl.join_str(USER);
|
||||||
q.add_aliased_columns::<user::Entity>(&user_tbl);
|
|
||||||
q.join_columns(
|
q.join_columns(
|
||||||
JoinType::LeftJoin,
|
JoinType::LeftJoin,
|
||||||
note::Relation::User.with_from_alias(note_tbl),
|
note::Relation::User.with_from_alias(note_tbl),
|
||||||
|
|
|
@ -106,8 +106,10 @@ impl ModelPagination for UserFollowRequestData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct UserResolveOptions {
|
pub struct UserResolveOptions {
|
||||||
pub with_avatar_and_banner: bool,
|
pub with_avatar: bool,
|
||||||
|
pub with_banner: bool,
|
||||||
pub with_profile: bool,
|
pub with_profile: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +132,8 @@ impl UserResolver {
|
||||||
q: &mut SelectStatement,
|
q: &mut SelectStatement,
|
||||||
user_tbl: &MagIden,
|
user_tbl: &MagIden,
|
||||||
UserResolveOptions {
|
UserResolveOptions {
|
||||||
with_avatar_and_banner,
|
with_avatar,
|
||||||
|
with_banner,
|
||||||
with_profile,
|
with_profile,
|
||||||
}: &UserResolveOptions,
|
}: &UserResolveOptions,
|
||||||
) {
|
) {
|
||||||
|
@ -148,19 +151,24 @@ impl UserResolver {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if *with_avatar_and_banner {
|
if *with_avatar {
|
||||||
let avatar_tbl = user_tbl.join_str(AVATAR);
|
let avatar_tbl = user_tbl.join_str(AVATAR);
|
||||||
let banner_tbl = user_tbl.join_str(BANNER);
|
|
||||||
|
|
||||||
q.add_aliased_columns::<drive_file::Entity>(&avatar_tbl)
|
q.add_aliased_columns::<drive_file::Entity>(&avatar_tbl);
|
||||||
.add_aliased_columns::<drive_file::Entity>(&banner_tbl);
|
|
||||||
|
|
||||||
q.join_columns(
|
q.join_columns(
|
||||||
JoinType::LeftJoin,
|
JoinType::LeftJoin,
|
||||||
user::Relation::DriveFile2.with_from_alias(user_tbl),
|
user::Relation::DriveFile2.with_from_alias(user_tbl),
|
||||||
&avatar_tbl,
|
&avatar_tbl,
|
||||||
)
|
);
|
||||||
.join_columns(
|
}
|
||||||
|
|
||||||
|
if *with_banner {
|
||||||
|
let banner_tbl = user_tbl.join_str(BANNER);
|
||||||
|
|
||||||
|
q.add_aliased_columns::<drive_file::Entity>(&banner_tbl);
|
||||||
|
|
||||||
|
q.join_columns(
|
||||||
JoinType::LeftJoin,
|
JoinType::LeftJoin,
|
||||||
user::Relation::DriveFile1.with_from_alias(user_tbl),
|
user::Relation::DriveFile1.with_from_alias(user_tbl),
|
||||||
&banner_tbl,
|
&banner_tbl,
|
||||||
|
|
|
@ -574,13 +574,14 @@ impl NoteModel {
|
||||||
let Some(note) = note_resolver
|
let Some(note) = note_resolver
|
||||||
.get_one(&NoteResolveOptions {
|
.get_one(&NoteResolveOptions {
|
||||||
ids: Some(vec![id.to_owned()]),
|
ids: Some(vec![id.to_owned()]),
|
||||||
visibility_filter: Box::new(NoteVisibilityFilterModel.new_note_visibility_filter(
|
visibility_filter: Arc::new(NoteVisibilityFilterModel.new_note_visibility_filter(
|
||||||
ctx.self_user.as_deref().map(ck::user::Model::get_id),
|
ctx.self_user.as_deref().map(ck::user::Model::get_id),
|
||||||
)),
|
)),
|
||||||
time_range: None,
|
time_range: None,
|
||||||
limit: None,
|
limit: None,
|
||||||
user_options: UserResolveOptions {
|
user_options: UserResolveOptions {
|
||||||
with_avatar_and_banner: self.with_context,
|
with_avatar: self.with_context,
|
||||||
|
with_banner: false,
|
||||||
with_profile: false,
|
with_profile: false,
|
||||||
},
|
},
|
||||||
with_reply_target: self.with_context,
|
with_reply_target: self.with_context,
|
||||||
|
@ -613,13 +614,14 @@ impl NoteModel {
|
||||||
let notes = note_resolver
|
let notes = note_resolver
|
||||||
.get_many(&NoteResolveOptions {
|
.get_many(&NoteResolveOptions {
|
||||||
ids: None,
|
ids: None,
|
||||||
visibility_filter: Box::new(NoteVisibilityFilterModel.new_note_visibility_filter(
|
visibility_filter: Arc::new(NoteVisibilityFilterModel.new_note_visibility_filter(
|
||||||
ctx.self_user.as_deref().map(ck::user::Model::get_id),
|
ctx.self_user.as_deref().map(ck::user::Model::get_id),
|
||||||
)),
|
)),
|
||||||
time_range: None,
|
time_range: None,
|
||||||
limit: None,
|
limit: None,
|
||||||
user_options: UserResolveOptions {
|
user_options: UserResolveOptions {
|
||||||
with_avatar_and_banner: self.with_context,
|
with_avatar: self.with_context,
|
||||||
|
with_banner: false,
|
||||||
with_profile: false,
|
with_profile: false,
|
||||||
},
|
},
|
||||||
with_reply_target: self.with_context,
|
with_reply_target: self.with_context,
|
||||||
|
|
|
@ -596,7 +596,8 @@ impl UserModel {
|
||||||
.get_user_resolver()
|
.get_user_resolver()
|
||||||
.get_followers(
|
.get_followers(
|
||||||
&UserResolveOptions {
|
&UserResolveOptions {
|
||||||
with_avatar_and_banner: true,
|
with_avatar: true,
|
||||||
|
with_banner: true,
|
||||||
with_profile: true,
|
with_profile: true,
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -641,7 +642,8 @@ impl UserModel {
|
||||||
.get_user_resolver()
|
.get_user_resolver()
|
||||||
.get_followees(
|
.get_followees(
|
||||||
&UserResolveOptions {
|
&UserResolveOptions {
|
||||||
with_avatar_and_banner: true,
|
with_avatar: true,
|
||||||
|
with_banner: true,
|
||||||
with_profile: true,
|
with_profile: true,
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -684,7 +686,8 @@ impl UserModel {
|
||||||
.get_user_resolver()
|
.get_user_resolver()
|
||||||
.get_follow_requests(
|
.get_follow_requests(
|
||||||
&UserResolveOptions {
|
&UserResolveOptions {
|
||||||
with_avatar_and_banner: true,
|
with_avatar: true,
|
||||||
|
with_banner: true,
|
||||||
with_profile: true,
|
with_profile: true,
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use either::Either;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use magnetar_calckey_model::sea_orm::prelude::async_trait::async_trait;
|
use magnetar_calckey_model::sea_orm::prelude::async_trait::async_trait;
|
||||||
use magnetar_core::web_model::rel::{RelNext, RelPrev};
|
use magnetar_core::web_model::rel::{RelNext, RelPrev};
|
||||||
use magnetar_sdk::types::{NoFilter, PaginationShape, SpanFilter};
|
use magnetar_sdk::types::{PaginationShape, SpanFilter};
|
||||||
use magnetar_sdk::util_types::U64Range;
|
use magnetar_sdk::util_types::U64Range;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
Loading…
Reference in New Issue