Forum: every member may upload an own avatar and ask for a conversation
CI / test (push) Successful in 3m9s
CI / build (push) Skipped
CI / deploy (push) Skipped

- Own avatars: no longer from the Kereső rank; before the first nickname
  save the settings page says the upload comes right after it (that is why
  even an admin did not see it).
- Conversation requests: any member from the first day (a newcomers'
  limit may come back later in may_request).
- The terms (8.1, 8.4) and the docs follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-26 17:56:28 +00:00
co-authored by Claude Opus 5.5
parent 178416e069
commit 46a2b6781e
8 changed files with 31 additions and 28 deletions
+1 -6
View File
@@ -1,5 +1,4 @@
//! Own avatars: a member from the Kereső rank may upload a picture instead of
//! a starter avatar. It is cut to a square, made small (256 pixels), stripped
//! Own avatars: any member may upload a picture instead of a starter avatar. It is cut to a square, made small (256 pixels), stripped
//! of its metadata (EXIF: camera, place) and kept in the object storage; the
//! forum serves it. A moderator can put the starter avatar back.
@@ -17,7 +16,6 @@ use image::metadata::Orientation;
use image::{DynamicImage, ImageDecoder, ImageFormat, ImageReader, Limits};
use serde_json::{Value, json};
use sha2::{Digest, Sha256};
use time::OffsetDateTime;
use uuid::Uuid;
use super::St;
@@ -97,9 +95,6 @@ pub async fn forget(state: &crate::AppState, avatar: &str) {
/// `PUT /v1/forum/me/avatar`: the picture's bytes as the body.
pub async fn upload(State(state): St, viewer: Viewer, body: Bytes) -> ApiResult<Json<Value>> {
let member = viewer.require_writer()?.clone();
if member.rank(OffsetDateTime::now_utc()).is_newcomer() && !viewer.is_moderator() {
return Err(ApiError::Forbidden("Saját képet a Kereső rangtól tölthetsz fel.".into()));
}
let Some(storage) = &state.storage else {
return Err(ApiError::Forbidden("A képfeltöltés most nem érhető el.".into()));
};
+2 -2
View File
@@ -61,9 +61,9 @@ pub async fn me(State(state): St, viewer: Viewer) -> ApiResult<Json<Value>> {
},
"listener": m.listener,
"supporter_badge": m.supporter_badge,
// From the Kereső rank: volunteering as a listener, an own picture.
// From the Kereső rank: volunteering as a companion. An own picture: anyone.
"can_listen": viewer.is_moderator() || !rank.is_newcomer(),
"can_upload_avatar": viewer.is_moderator() || !rank.is_newcomer(),
"can_upload_avatar": true,
})
});
let buyer = super::has_purchase(&state.db, user.id).await?;
+6 -6
View File
@@ -82,10 +82,11 @@ fn pair(a: Uuid, b: Uuid) -> (Uuid, Uuid) {
if a < b { (a, b) } else { (b, a) }
}
/// Whether a member may start conversations: from the Kereső rank and after
/// writing in public (moderators always).
fn may_request(viewer: &Viewer, member: &Member) -> bool {
viewer.is_moderator() || (!member.rank(OffsetDateTime::now_utc()).is_newcomer() && member.post_count > 0)
/// Whether a member may start conversations: any member for now, from the
/// first day (the user decided on 2026-11-26; a newcomers' limit, such as the
/// Kereső rank, may come back later here).
fn may_request(_viewer: &Viewer, _member: &Member) -> bool {
true
}
/// The viewer's relation to another member, for the profile page.
@@ -143,8 +144,7 @@ pub async fn request(
let me = viewer.require_writer()?;
if !may_request(&viewer, me) {
return Err(ApiError::Forbidden(
"Beszélgetést a Kereső rangtól kezdeményezhetsz, ha már írtál a fórumba. A neked küldött kéréseket addig is elfogadhatod."
.into(),
"Most nem kezdeményezhetsz beszélgetést. A neked küldött kéréseket elfogadhatod.".into(),
));
}
let other: Uuid = sqlx::query_scalar("SELECT user_id FROM forum.members WHERE nickname_key = $1")