Fixed user relation packing
ci/woodpecker/push/ociImagePush Pipeline was successful
Details
ci/woodpecker/push/ociImagePush Pipeline was successful
Details
This commit is contained in:
parent
81d0c678d8
commit
79660fb816
|
@ -96,8 +96,8 @@ pub struct UserProfilePinsEx {
|
||||||
pub struct UserRelationExt {
|
pub struct UserRelationExt {
|
||||||
pub follows_you: bool,
|
pub follows_you: bool,
|
||||||
pub you_follow: bool,
|
pub you_follow: bool,
|
||||||
pub you_request_follow: bool,
|
|
||||||
pub they_request_follow: bool,
|
pub they_request_follow: bool,
|
||||||
|
pub you_request_follow: bool,
|
||||||
pub blocks_you: bool,
|
pub blocks_you: bool,
|
||||||
pub you_block: bool,
|
pub you_block: bool,
|
||||||
pub mute: bool,
|
pub mute: bool,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
|
||||||
|
@ -84,7 +83,7 @@ pub(crate) fn deserialize_array_urlenc<'de, D, T: Eq + Hash>(
|
||||||
deserializer: D,
|
deserializer: D,
|
||||||
) -> Result<Vec<T>, D::Error>
|
) -> Result<Vec<T>, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
T: DeserializeOwned,
|
T: DeserializeOwned,
|
||||||
{
|
{
|
||||||
let str_raw = String::deserialize(deserializer)?;
|
let str_raw = String::deserialize(deserializer)?;
|
||||||
|
|
|
@ -137,76 +137,40 @@ impl PackType<&ck::user::Model> for UserDetailExt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UserRelationExtSource<'a> {
|
pub struct UserRelationExtSource {
|
||||||
pub follow_out: Option<&'a ck::following::Model>,
|
pub follow_out: bool,
|
||||||
pub follow_in: Option<&'a ck::following::Model>,
|
pub follow_in: bool,
|
||||||
pub block_out: Option<&'a ck::blocking::Model>,
|
pub follow_request_in: bool,
|
||||||
pub block_in: Option<&'a ck::blocking::Model>,
|
pub follow_request_out: bool,
|
||||||
pub mute: Option<&'a ck::muting::Model>,
|
pub block_out: bool,
|
||||||
pub renote_mute: Option<&'a ck::renote_muting::Model>,
|
pub block_in: bool,
|
||||||
pub follow_request_out: Option<&'a ck::follow_request::Model>,
|
pub mute: bool,
|
||||||
pub follow_request_in: Option<&'a ck::follow_request::Model>,
|
pub renote_mute: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PackType<UserRelationExtSource<'_>> for UserRelationExt {
|
impl PackType<UserRelationExtSource> for UserRelationExt {
|
||||||
fn extract(
|
fn extract(
|
||||||
context: &PackingContext,
|
_context: &PackingContext,
|
||||||
UserRelationExtSource {
|
UserRelationExtSource {
|
||||||
follow_out,
|
follow_out,
|
||||||
follow_in,
|
follow_in,
|
||||||
|
follow_request_in,
|
||||||
|
follow_request_out,
|
||||||
block_out,
|
block_out,
|
||||||
block_in,
|
block_in,
|
||||||
mute,
|
mute,
|
||||||
renote_mute,
|
renote_mute,
|
||||||
follow_request_in,
|
|
||||||
follow_request_out,
|
|
||||||
}: UserRelationExtSource,
|
}: UserRelationExtSource,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let self_user = context.self_user();
|
|
||||||
|
|
||||||
UserRelationExt {
|
UserRelationExt {
|
||||||
follows_you: self_user.is_some_and(|self_user| {
|
follows_you: follow_in,
|
||||||
follow_in.is_some_and(|follow_in| {
|
you_follow: follow_out,
|
||||||
self_user.id == follow_in.followee_id && self_user.id != follow_in.follower_id
|
they_request_follow: follow_request_in,
|
||||||
})
|
you_request_follow: follow_request_out,
|
||||||
}),
|
blocks_you: block_in,
|
||||||
you_follow: self_user.is_some_and(|self_user| {
|
you_block: block_out,
|
||||||
follow_out.is_some_and(|follow_out| {
|
mute,
|
||||||
self_user.id == follow_out.follower_id && self_user.id != follow_out.followee_id
|
mute_renotes: renote_mute,
|
||||||
})
|
|
||||||
}),
|
|
||||||
blocks_you: self_user.is_some_and(|self_user| {
|
|
||||||
block_in.is_some_and(|block_in| {
|
|
||||||
self_user.id == block_in.blockee_id && self_user.id != block_in.blocker_id
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
you_block: self_user.is_some_and(|self_user| {
|
|
||||||
block_out.is_some_and(|block_out| {
|
|
||||||
self_user.id == block_out.blocker_id && self_user.id != block_out.blockee_id
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
mute: self_user.is_some_and(|self_user| {
|
|
||||||
mute.is_some_and(|mute| {
|
|
||||||
self_user.id == mute.muter_id && self_user.id != mute.mutee_id
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
mute_renotes: self_user.is_some_and(|self_user| {
|
|
||||||
renote_mute.is_some_and(|renote_mute| {
|
|
||||||
self_user.id == renote_mute.muter_id && self_user.id != renote_mute.mutee_id
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
you_request_follow: self_user.is_some_and(|self_user| {
|
|
||||||
follow_request_in.is_some_and(|follow_req_in| {
|
|
||||||
self_user.id == follow_req_in.followee_id
|
|
||||||
&& self_user.id != follow_req_in.follower_id
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
they_request_follow: self_user.is_some_and(|self_user| {
|
|
||||||
follow_request_out.is_some_and(|follow_req_out| {
|
|
||||||
self_user.id == follow_req_out.follower_id
|
|
||||||
&& self_user.id != follow_req_out.followee_id
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::model::data::user::{UserBaseSource, UserProfileExtSource};
|
use crate::model::data::user::{UserBaseSource, UserProfileExtSource, UserRelationExtSource};
|
||||||
use crate::model::processing::drive::DriveModel;
|
use crate::model::processing::drive::DriveModel;
|
||||||
use crate::model::processing::emoji::EmojiModel;
|
use crate::model::processing::emoji::EmojiModel;
|
||||||
use crate::model::processing::note::NoteModel;
|
use crate::model::processing::note::NoteModel;
|
||||||
|
@ -300,8 +300,8 @@ impl UserModel {
|
||||||
return Ok(UserRelationExt {
|
return Ok(UserRelationExt {
|
||||||
follows_you: false,
|
follows_you: false,
|
||||||
you_follow: false,
|
you_follow: false,
|
||||||
you_request_follow: false,
|
|
||||||
they_request_follow: false,
|
they_request_follow: false,
|
||||||
|
you_request_follow: false,
|
||||||
blocks_you: false,
|
blocks_you: false,
|
||||||
you_block: false,
|
you_block: false,
|
||||||
mute: false,
|
mute: false,
|
||||||
|
@ -313,14 +313,14 @@ impl UserModel {
|
||||||
let them = Either::Right(user);
|
let them = Either::Right(user);
|
||||||
|
|
||||||
let (
|
let (
|
||||||
follows_you,
|
follow_in,
|
||||||
you_follow,
|
follow_out,
|
||||||
you_request_follow,
|
follow_request_in,
|
||||||
they_request_follow,
|
follow_request_out,
|
||||||
blocks_you,
|
block_in,
|
||||||
you_block,
|
block_out,
|
||||||
mute,
|
mute,
|
||||||
mute_renotes,
|
renote_mute,
|
||||||
) = try_join!(
|
) = try_join!(
|
||||||
ctx.is_relationship_between(them, me, UserRelationship::Follow),
|
ctx.is_relationship_between(them, me, UserRelationship::Follow),
|
||||||
ctx.is_relationship_between(me, them, UserRelationship::Follow),
|
ctx.is_relationship_between(me, them, UserRelationship::Follow),
|
||||||
|
@ -332,16 +332,19 @@ impl UserModel {
|
||||||
ctx.is_relationship_between(me, them, UserRelationship::RenoteMute)
|
ctx.is_relationship_between(me, them, UserRelationship::RenoteMute)
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(UserRelationExt {
|
Ok(UserRelationExt::extract(
|
||||||
follows_you,
|
ctx,
|
||||||
you_follow,
|
UserRelationExtSource {
|
||||||
you_request_follow,
|
follow_in,
|
||||||
they_request_follow,
|
follow_out,
|
||||||
blocks_you,
|
follow_request_in,
|
||||||
you_block,
|
follow_request_out,
|
||||||
mute,
|
block_in,
|
||||||
mute_renotes,
|
block_out,
|
||||||
})
|
mute,
|
||||||
|
renote_mute,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn auth_overview_from_profile(
|
pub fn auth_overview_from_profile(
|
||||||
|
|
Loading…
Reference in New Issue