fix: remote actor display names in thought cards — use last URL segment as username, resolve display_name after intern
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m13s
test / unit (pull_request) Successful in 15m56s
test / integration (pull_request) Failing after 17m29s
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m13s
test / unit (pull_request) Successful in 15m56s
test / integration (pull_request) Failing after 17m29s
This commit is contained in:
@@ -154,13 +154,18 @@ impl ActivityPubRepository for PgActivityPubRepository {
|
||||
return Ok(id);
|
||||
}
|
||||
let new_id = uuid::Uuid::new_v4();
|
||||
let raw = actor_ap_url
|
||||
.path()
|
||||
.trim_start_matches('/')
|
||||
.replace('/', "_");
|
||||
// username column is VARCHAR(32); truncate long paths (e.g. UUID-based actor URLs)
|
||||
let handle = if raw.len() <= 32 {
|
||||
raw
|
||||
// Use the last path segment as username (e.g. /users/alice → "alice").
|
||||
// Falls back to a random short id for long segments (e.g. UUID-based actor URLs).
|
||||
// username column is VARCHAR(32).
|
||||
let last_seg = actor_ap_url
|
||||
.path_segments()
|
||||
.and_then(|mut s| s.next_back())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let handle = if last_seg.is_empty() {
|
||||
format!("remote_{}", &new_id.to_string()[..13])
|
||||
} else if last_seg.len() <= 32 {
|
||||
last_seg
|
||||
} else {
|
||||
format!("remote_{}", &new_id.to_string()[..13])
|
||||
};
|
||||
@@ -185,6 +190,25 @@ impl ActivityPubRepository for PgActivityPubRepository {
|
||||
})
|
||||
}
|
||||
|
||||
async fn update_remote_actor_display(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
display_name: Option<&str>,
|
||||
avatar_url: Option<&str>,
|
||||
) -> Result<(), DomainError> {
|
||||
sqlx::query(
|
||||
"UPDATE users SET display_name=$1, avatar_url=$2, updated_at=NOW()
|
||||
WHERE id=$3 AND local=false",
|
||||
)
|
||||
.bind(display_name)
|
||||
.bind(avatar_url)
|
||||
.bind(user_id.as_uuid())
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(|e| DomainError::Internal(e.to_string()))
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
async fn accept_note(
|
||||
&self,
|
||||
ap_id: &Url,
|
||||
|
||||
Reference in New Issue
Block a user