2025-04-11 18:08:51 -04:00
|
|
|
use super::{render_error, PaginatedQuery, ProfileQuery};
|
2025-04-24 16:40:03 -04:00
|
|
|
use crate::{
|
|
|
|
assets::initial_context, check_user_blocked_or_private, get_lang, get_user_from_token,
|
|
|
|
sanitize::clean_settings, State,
|
|
|
|
};
|
2025-03-25 23:58:27 -04:00
|
|
|
use axum::{
|
|
|
|
Extension,
|
2025-03-26 21:46:21 -04:00
|
|
|
extract::{Path, Query},
|
2025-03-25 23:58:27 -04:00
|
|
|
response::{Html, IntoResponse},
|
|
|
|
};
|
|
|
|
use axum_extra::extract::CookieJar;
|
2025-04-01 16:12:13 -04:00
|
|
|
use serde::Deserialize;
|
2025-03-27 18:10:47 -04:00
|
|
|
use tera::Context;
|
2025-04-06 13:43:12 -04:00
|
|
|
use tetratto_core::model::{Error, auth::User, communities::Community, permissions::FinePermission};
|
2025-04-11 18:08:51 -04:00
|
|
|
use tetratto_shared::hash::hash;
|
2025-04-22 19:46:08 -04:00
|
|
|
use contrasted::{Color, MINIMUM_CONTRAST_THRESHOLD};
|
2025-04-01 16:12:13 -04:00
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
pub struct SettingsProps {
|
|
|
|
#[serde(default)]
|
|
|
|
pub username: String,
|
|
|
|
}
|
2025-03-27 18:10:47 -04:00
|
|
|
|
2025-03-31 11:45:34 -04:00
|
|
|
/// `/settings`
|
|
|
|
pub async fn settings_request(
|
|
|
|
jar: CookieJar,
|
|
|
|
Extension(data): Extension<State>,
|
2025-04-01 16:12:13 -04:00
|
|
|
Query(req): Query<SettingsProps>,
|
2025-03-31 11:45:34 -04:00
|
|
|
) -> impl IntoResponse {
|
|
|
|
let data = data.read().await;
|
|
|
|
let user = match get_user_from_token!(jar, data.0) {
|
|
|
|
Some(ua) => ua,
|
|
|
|
None => {
|
|
|
|
return Err(Html(
|
|
|
|
render_error(Error::NotAllowed, &jar, &data, &None).await,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2025-04-01 16:12:13 -04:00
|
|
|
let profile = if req.username.is_empty() | !user.permissions.check(FinePermission::MANAGE_USERS)
|
|
|
|
{
|
|
|
|
user.clone()
|
|
|
|
} else {
|
|
|
|
match data.0.get_user_by_username(&req.username).await {
|
|
|
|
Ok(ua) => ua,
|
|
|
|
Err(e) => {
|
|
|
|
return Err(Html(render_error(e, &jar, &data, &None).await));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let tokens = profile.tokens.clone();
|
2025-03-31 11:45:34 -04:00
|
|
|
|
|
|
|
let lang = get_lang!(jar, data.0);
|
|
|
|
let mut context = initial_context(&data.0.0, lang, &Some(user)).await;
|
|
|
|
|
2025-04-01 16:12:13 -04:00
|
|
|
context.insert("profile", &profile);
|
2025-04-10 18:16:52 -04:00
|
|
|
context.insert("user_settings_serde", &clean_settings(&profile.settings));
|
2025-03-31 11:45:34 -04:00
|
|
|
context.insert(
|
|
|
|
"user_tokens_serde",
|
|
|
|
&serde_json::to_string(&tokens)
|
|
|
|
.unwrap()
|
|
|
|
.replace("\"", "\\\""),
|
|
|
|
);
|
|
|
|
|
2025-04-22 19:46:08 -04:00
|
|
|
// check color contrasts
|
|
|
|
let mut failing_color_keys: Vec<(&str, f64)> = Vec::new();
|
|
|
|
let settings_map = serde_json::from_str::<serde_json::Map<String, serde_json::Value>>(
|
|
|
|
&serde_json::to_string(&profile.settings).unwrap(),
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let light = serde_json::Value::from("Light");
|
|
|
|
let mut profile_theme = settings_map
|
|
|
|
.get("profile_theme")
|
|
|
|
.unwrap_or(&light)
|
|
|
|
.as_str()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
if profile_theme.is_empty() | (profile_theme == "Auto") {
|
|
|
|
profile_theme = "Light";
|
|
|
|
}
|
|
|
|
|
|
|
|
let default_surface = serde_json::Value::from(if profile_theme == "Light" {
|
|
|
|
"#f3f2f1"
|
|
|
|
} else {
|
|
|
|
"#19171c"
|
|
|
|
});
|
|
|
|
|
|
|
|
let mut color_surface = settings_map
|
|
|
|
.get("theme_color_surface")
|
|
|
|
.unwrap_or(&default_surface)
|
|
|
|
.as_str()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
if color_surface.is_empty() {
|
|
|
|
color_surface = default_surface.as_str().unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
for setting in &settings_map {
|
2025-04-22 19:49:58 -04:00
|
|
|
if !setting.0.starts_with("theme_color_text")
|
|
|
|
| (setting.0 == "theme_color_text_primary")
|
|
|
|
| (setting.0 == "theme_color_text_secondary")
|
|
|
|
{
|
2025-04-22 19:46:08 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = setting.1.as_str().unwrap();
|
|
|
|
|
|
|
|
if !value.starts_with("#") {
|
|
|
|
// we can only parse hex right now
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
let c1 = Color::from_hex(&color_surface);
|
|
|
|
let c2 = Color::from_hex(&value);
|
|
|
|
let contrast = c1.contrast(&c2);
|
|
|
|
|
|
|
|
if contrast < MINIMUM_CONTRAST_THRESHOLD {
|
|
|
|
failing_color_keys.push((setting.0, contrast));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
context.insert("failing_color_keys", &failing_color_keys);
|
|
|
|
|
2025-03-31 11:45:34 -04:00
|
|
|
// return
|
|
|
|
Ok(Html(
|
2025-03-31 15:39:49 -04:00
|
|
|
data.1.render("profile/settings.html", &context).unwrap(),
|
2025-03-31 11:45:34 -04:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2025-03-29 00:26:56 -04:00
|
|
|
pub fn profile_context(
|
|
|
|
context: &mut Context,
|
2025-04-08 15:49:41 -04:00
|
|
|
user: &Option<User>,
|
2025-03-29 00:26:56 -04:00
|
|
|
profile: &User,
|
|
|
|
communities: &Vec<Community>,
|
|
|
|
is_self: bool,
|
|
|
|
is_following: bool,
|
2025-03-31 20:02:09 -04:00
|
|
|
is_following_you: bool,
|
|
|
|
is_blocking: bool,
|
2025-03-29 00:26:56 -04:00
|
|
|
) {
|
2025-03-27 18:10:47 -04:00
|
|
|
context.insert("profile", &profile);
|
2025-03-29 00:26:56 -04:00
|
|
|
context.insert("communities", &communities);
|
2025-03-27 18:10:47 -04:00
|
|
|
context.insert("is_self", &is_self);
|
|
|
|
context.insert("is_following", &is_following);
|
2025-03-31 20:02:09 -04:00
|
|
|
context.insert("is_following_you", &is_following_you);
|
|
|
|
context.insert("is_blocking", &is_blocking);
|
2025-04-11 18:08:51 -04:00
|
|
|
context.insert("warning_hash", &hash(profile.settings.warning.clone()));
|
2025-04-06 13:43:12 -04:00
|
|
|
|
|
|
|
context.insert(
|
|
|
|
"is_supporter",
|
|
|
|
&profile.permissions.check(FinePermission::SUPPORTER),
|
|
|
|
);
|
2025-04-08 15:49:41 -04:00
|
|
|
|
|
|
|
if let Some(ua) = user {
|
|
|
|
if !ua.settings.disable_other_themes | is_self {
|
|
|
|
context.insert("use_user_theme", &false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
context.insert("use_user_theme", &false);
|
|
|
|
}
|
2025-03-27 18:10:47 -04:00
|
|
|
}
|
2025-03-25 23:58:27 -04:00
|
|
|
|
2025-03-31 22:35:11 -04:00
|
|
|
/// `/@{username}`
|
2025-03-25 23:58:27 -04:00
|
|
|
pub async fn posts_request(
|
|
|
|
jar: CookieJar,
|
|
|
|
Path(username): Path<String>,
|
2025-04-11 18:08:51 -04:00
|
|
|
Query(props): Query<ProfileQuery>,
|
2025-03-25 23:58:27 -04:00
|
|
|
Extension(data): Extension<State>,
|
|
|
|
) -> impl IntoResponse {
|
|
|
|
let data = data.read().await;
|
|
|
|
let user = get_user_from_token!(jar, data.0);
|
|
|
|
|
|
|
|
let other_user = match data.0.get_user_by_username(&username).await {
|
|
|
|
Ok(ua) => ua,
|
2025-03-27 18:10:47 -04:00
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
2025-03-26 21:46:21 -04:00
|
|
|
};
|
|
|
|
|
2025-04-24 16:40:03 -04:00
|
|
|
check_user_blocked_or_private!(user, other_user, data, jar);
|
2025-03-31 19:31:36 -04:00
|
|
|
|
2025-04-11 18:08:51 -04:00
|
|
|
// check for warning
|
|
|
|
if props.warning {
|
|
|
|
let lang = get_lang!(jar, data.0);
|
|
|
|
let mut context = initial_context(&data.0.0, lang, &user).await;
|
|
|
|
|
|
|
|
context.insert("profile", &other_user);
|
|
|
|
context.insert("warning_hash", &hash(other_user.settings.warning.clone()));
|
|
|
|
|
|
|
|
return Ok(Html(
|
|
|
|
data.1.render("profile/warning.html", &context).unwrap(),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2025-03-29 00:26:56 -04:00
|
|
|
// fetch data
|
2025-04-23 16:46:13 -04:00
|
|
|
let ignore_users = if let Some(ref ua) = user {
|
|
|
|
data.0.get_userblocks_receivers(ua.id).await
|
|
|
|
} else {
|
|
|
|
Vec::new()
|
|
|
|
};
|
|
|
|
|
2025-03-29 00:26:56 -04:00
|
|
|
let posts = match data
|
|
|
|
.0
|
|
|
|
.get_posts_by_user(other_user.id, 12, props.page)
|
|
|
|
.await
|
|
|
|
{
|
2025-04-10 18:16:52 -04:00
|
|
|
Ok(p) => match data
|
|
|
|
.0
|
2025-04-23 16:46:13 -04:00
|
|
|
.fill_posts_with_community(
|
|
|
|
p,
|
|
|
|
if let Some(ref ua) = user { ua.id } else { 0 },
|
|
|
|
&ignore_users,
|
|
|
|
)
|
2025-04-10 18:16:52 -04:00
|
|
|
.await
|
|
|
|
{
|
2025-03-29 00:26:56 -04:00
|
|
|
Ok(p) => p,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
},
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
2025-04-07 16:07:01 -04:00
|
|
|
let pinned = match data.0.get_pinned_posts_by_user(other_user.id).await {
|
2025-04-10 18:16:52 -04:00
|
|
|
Ok(p) => match data
|
|
|
|
.0
|
2025-04-23 16:46:13 -04:00
|
|
|
.fill_posts_with_community(
|
|
|
|
p,
|
|
|
|
if let Some(ref ua) = user { ua.id } else { 0 },
|
|
|
|
&ignore_users,
|
|
|
|
)
|
2025-04-10 18:16:52 -04:00
|
|
|
.await
|
|
|
|
{
|
2025-04-07 16:07:01 -04:00
|
|
|
Ok(p) => p,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
},
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
2025-03-29 00:26:56 -04:00
|
|
|
let communities = match data.0.get_memberships_by_owner(other_user.id).await {
|
|
|
|
Ok(m) => match data.0.fill_communities(m).await {
|
|
|
|
Ok(m) => m,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
},
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
2025-03-27 18:10:47 -04:00
|
|
|
// init context
|
2025-03-25 23:58:27 -04:00
|
|
|
let lang = get_lang!(jar, data.0);
|
2025-03-27 18:10:47 -04:00
|
|
|
let mut context = initial_context(&data.0.0, lang, &user).await;
|
|
|
|
|
|
|
|
let is_self = if let Some(ref ua) = user {
|
|
|
|
ua.id == other_user.id
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
let is_following = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userfollow_by_initiator_receiver(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
2025-03-26 21:46:21 -04:00
|
|
|
|
2025-03-31 20:02:09 -04:00
|
|
|
let is_following_you = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userfollow_by_receiver_initiator(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
let is_blocking = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userblock_by_initiator_receiver(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
2025-03-26 21:46:21 -04:00
|
|
|
context.insert("posts", &posts);
|
2025-04-07 16:07:01 -04:00
|
|
|
context.insert("pinned", &pinned);
|
2025-04-10 18:16:52 -04:00
|
|
|
context.insert("page", &props.page);
|
2025-03-29 00:26:56 -04:00
|
|
|
profile_context(
|
|
|
|
&mut context,
|
2025-04-08 15:49:41 -04:00
|
|
|
&user,
|
2025-03-29 00:26:56 -04:00
|
|
|
&other_user,
|
|
|
|
&communities,
|
|
|
|
is_self,
|
|
|
|
is_following,
|
2025-03-31 20:02:09 -04:00
|
|
|
is_following_you,
|
|
|
|
is_blocking,
|
2025-03-29 00:26:56 -04:00
|
|
|
);
|
2025-03-25 23:58:27 -04:00
|
|
|
|
2025-03-27 18:10:47 -04:00
|
|
|
// return
|
2025-03-31 15:39:49 -04:00
|
|
|
Ok(Html(data.1.render("profile/posts.html", &context).unwrap()))
|
2025-03-25 23:58:27 -04:00
|
|
|
}
|
2025-03-31 22:35:11 -04:00
|
|
|
|
|
|
|
/// `/@{username}/following`
|
|
|
|
pub async fn following_request(
|
|
|
|
jar: CookieJar,
|
|
|
|
Path(username): Path<String>,
|
|
|
|
Query(props): Query<PaginatedQuery>,
|
|
|
|
Extension(data): Extension<State>,
|
|
|
|
) -> impl IntoResponse {
|
|
|
|
let data = data.read().await;
|
|
|
|
let user = get_user_from_token!(jar, data.0);
|
|
|
|
|
|
|
|
let other_user = match data.0.get_user_by_username(&username).await {
|
|
|
|
Ok(ua) => ua,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
2025-04-24 16:40:03 -04:00
|
|
|
check_user_blocked_or_private!(user, other_user, data, jar);
|
2025-03-31 22:35:11 -04:00
|
|
|
|
|
|
|
// check for private profile
|
|
|
|
if other_user.settings.private_profile {
|
|
|
|
if let Some(ref ua) = user {
|
2025-04-06 13:43:12 -04:00
|
|
|
if ua.id != other_user.id
|
|
|
|
&& data
|
2025-03-31 22:35:11 -04:00
|
|
|
.0
|
|
|
|
.get_userfollow_by_initiator_receiver(other_user.id, ua.id)
|
|
|
|
.await
|
2025-04-06 13:43:12 -04:00
|
|
|
.is_err()
|
|
|
|
{
|
2025-04-02 18:44:31 -04:00
|
|
|
return Err(Html(
|
|
|
|
render_error(Error::NotAllowed, &jar, &data, &user).await,
|
|
|
|
));
|
2025-03-31 22:35:11 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return Err(Html(
|
|
|
|
render_error(Error::NotAllowed, &jar, &data, &user).await,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// fetch data
|
|
|
|
let list = match data
|
|
|
|
.0
|
|
|
|
.get_userfollows_by_initiator(other_user.id, 12, props.page)
|
|
|
|
.await
|
|
|
|
{
|
|
|
|
Ok(l) => match data.0.fill_userfollows_with_receiver(l).await {
|
|
|
|
Ok(l) => l,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
},
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
|
|
|
let communities = match data.0.get_memberships_by_owner(other_user.id).await {
|
|
|
|
Ok(m) => match data.0.fill_communities(m).await {
|
|
|
|
Ok(m) => m,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
},
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
|
|
|
// init context
|
|
|
|
let lang = get_lang!(jar, data.0);
|
|
|
|
let mut context = initial_context(&data.0.0, lang, &user).await;
|
|
|
|
|
|
|
|
let is_self = if let Some(ref ua) = user {
|
|
|
|
ua.id == other_user.id
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
let is_following = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userfollow_by_initiator_receiver(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
let is_following_you = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userfollow_by_receiver_initiator(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
let is_blocking = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userblock_by_initiator_receiver(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
context.insert("list", &list);
|
2025-04-02 14:19:37 -04:00
|
|
|
context.insert("page", &props.page);
|
2025-03-31 22:35:11 -04:00
|
|
|
profile_context(
|
|
|
|
&mut context,
|
2025-04-08 15:49:41 -04:00
|
|
|
&user,
|
2025-03-31 22:35:11 -04:00
|
|
|
&other_user,
|
|
|
|
&communities,
|
|
|
|
is_self,
|
|
|
|
is_following,
|
|
|
|
is_following_you,
|
|
|
|
is_blocking,
|
|
|
|
);
|
|
|
|
|
|
|
|
// return
|
|
|
|
Ok(Html(
|
|
|
|
data.1.render("profile/following.html", &context).unwrap(),
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
/// `/@{username}/followers`
|
|
|
|
pub async fn followers_request(
|
|
|
|
jar: CookieJar,
|
|
|
|
Path(username): Path<String>,
|
|
|
|
Query(props): Query<PaginatedQuery>,
|
|
|
|
Extension(data): Extension<State>,
|
|
|
|
) -> impl IntoResponse {
|
|
|
|
let data = data.read().await;
|
|
|
|
let user = get_user_from_token!(jar, data.0);
|
|
|
|
|
|
|
|
let other_user = match data.0.get_user_by_username(&username).await {
|
|
|
|
Ok(ua) => ua,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
2025-04-24 16:40:03 -04:00
|
|
|
check_user_blocked_or_private!(user, other_user, data, jar);
|
2025-03-31 22:35:11 -04:00
|
|
|
|
|
|
|
// fetch data
|
|
|
|
let list = match data
|
|
|
|
.0
|
|
|
|
.get_userfollows_by_receiver(other_user.id, 12, props.page)
|
|
|
|
.await
|
|
|
|
{
|
|
|
|
Ok(l) => match data.0.fill_userfollows_with_initiator(l).await {
|
|
|
|
Ok(l) => l,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
},
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
|
|
|
let communities = match data.0.get_memberships_by_owner(other_user.id).await {
|
|
|
|
Ok(m) => match data.0.fill_communities(m).await {
|
|
|
|
Ok(m) => m,
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
},
|
|
|
|
Err(e) => return Err(Html(render_error(e, &jar, &data, &user).await)),
|
|
|
|
};
|
|
|
|
|
|
|
|
// init context
|
|
|
|
let lang = get_lang!(jar, data.0);
|
|
|
|
let mut context = initial_context(&data.0.0, lang, &user).await;
|
|
|
|
|
|
|
|
let is_self = if let Some(ref ua) = user {
|
|
|
|
ua.id == other_user.id
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
let is_following = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userfollow_by_initiator_receiver(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
let is_following_you = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userfollow_by_receiver_initiator(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
let is_blocking = if let Some(ref ua) = user {
|
|
|
|
data.0
|
|
|
|
.get_userblock_by_initiator_receiver(ua.id, other_user.id)
|
|
|
|
.await
|
|
|
|
.is_ok()
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
context.insert("list", &list);
|
2025-04-02 14:19:37 -04:00
|
|
|
context.insert("page", &props.page);
|
2025-03-31 22:35:11 -04:00
|
|
|
profile_context(
|
|
|
|
&mut context,
|
2025-04-08 15:49:41 -04:00
|
|
|
&user,
|
2025-03-31 22:35:11 -04:00
|
|
|
&other_user,
|
|
|
|
&communities,
|
|
|
|
is_self,
|
|
|
|
is_following,
|
|
|
|
is_following_you,
|
|
|
|
is_blocking,
|
|
|
|
);
|
|
|
|
|
|
|
|
// return
|
|
|
|
Ok(Html(
|
|
|
|
data.1.render("profile/followers.html", &context).unwrap(),
|
|
|
|
))
|
|
|
|
}
|