fix: use default (non-member) membership when membership doesn't exist

This commit is contained in:
trisua 2025-04-09 21:39:30 -04:00
parent 0615f44bfa
commit 8c43f62545
3 changed files with 9 additions and 4 deletions

View file

@ -470,7 +470,7 @@ user.settings.theme_hue %}
{% if user.settings.theme_preference %} {% if user.settings.theme_preference %}
<script> <script>
function match_user_theme() { function match_user_theme() {
const pref = "{{ profile.settings.theme_preference }}".toLowercase(); const pref = "{{ profile.settings.theme_preference }}".toLowerCase();
if (pref === "auto") { if (pref === "auto") {
return; return;

View file

@ -9,7 +9,7 @@ use axum_extra::extract::CookieJar;
use tera::Context; use tera::Context;
use tetratto_core::model::{ use tetratto_core::model::{
auth::User, auth::User,
communities::{Community, CommunityMembership, CommunityReadAccess}, communities::{Community, CommunityReadAccess},
communities_permissions::CommunityPermission, communities_permissions::CommunityPermission,
permissions::FinePermission, permissions::FinePermission,
Error, Error,
@ -304,7 +304,7 @@ pub async fn settings_request(
.await .await
{ {
Ok(m) => m, Ok(m) => m,
Err(_) => CommunityMembership::new(user.id, community.id, CommunityPermission::DEFAULT), Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
}; };
if user.id != community.owner if user.id != community.owner

View file

@ -75,7 +75,12 @@ impl DataManager {
); );
if res.is_err() { if res.is_err() {
return Err(Error::GeneralNotFound("community membership".to_string())); // return Err(Error::GeneralNotFound("community membership".to_string()));
return Ok(CommunityMembership::new(
owner,
community,
CommunityPermission::DEFAULT,
));
} }
Ok(res.unwrap()) Ok(res.unwrap())