fix atproto web link

This commit is contained in:
2025-06-17 11:00:09 +09:00
parent fccf75949c
commit 4dac4a83e0

View File

@ -550,6 +550,13 @@ function App() {
const profileResponse = await fetch(`${apiEndpoint}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`); const profileResponse = await fetch(`${apiEndpoint}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`);
if (profileResponse.ok) { if (profileResponse.ok) {
const profileData = await profileResponse.json(); const profileData = await profileResponse.json();
// Determine correct web URL based on avatar source
let webUrl = config.webUrl; // Default from handle-based detection
if (profileData.avatar && profileData.avatar.includes('cdn.bsky.app')) {
webUrl = 'https://bsky.app'; // Override to Bluesky if avatar is from Bluesky
}
return { return {
...record, ...record,
value: { value: {
@ -559,7 +566,7 @@ function App() {
avatar: profileData.avatar, avatar: profileData.avatar,
displayName: profileData.displayName || handle, displayName: profileData.displayName || handle,
_pdsEndpoint: `https://${pds}`, // Store PDS info for later use _pdsEndpoint: `https://${pds}`, // Store PDS info for later use
_webUrl: config.webUrl, // Store web URL for profile links _webUrl: webUrl, // Store corrected web URL for profile links
} }
} }
}; };
@ -810,6 +817,14 @@ function App() {
const profile = await import('./utils/pds-detection').then(m => m.getProfileForUser(record.value.author.handle)); const profile = await import('./utils/pds-detection').then(m => m.getProfileForUser(record.value.author.handle));
if (profile) { if (profile) {
// Determine network config based on profile data
let webUrl = 'https://bsky.app'; // Default to Bluesky
if (profile.avatar && profile.avatar.includes('cdn.bsky.app')) {
webUrl = 'https://bsky.app';
} else if (profile.avatar && profile.avatar.includes('bsky.syu.is')) {
webUrl = 'https://web.syu.is';
}
return { return {
...record, ...record,
value: { value: {
@ -818,6 +833,7 @@ function App() {
...record.value.author, ...record.value.author,
avatar: profile.avatar, avatar: profile.avatar,
displayName: profile.displayName || record.value.author.handle, displayName: profile.displayName || record.value.author.handle,
_webUrl: webUrl, // Store network config for profile URL generation
} }
} }
}; };
@ -1146,7 +1162,18 @@ function App() {
return `${config.webUrl}/profile/${author.did}`; return `${config.webUrl}/profile/${author.did}`;
} }
// Get PDS from handle for other users // For other users, detect network based on avatar URL or stored network info
if (author.avatar && author.avatar.includes('cdn.bsky.app')) {
// User has Bluesky avatar, use Bluesky web interface
return `https://bsky.app/profile/${author.did}`;
}
// Check if we have stored network config from profile fetching
if (author._webUrl) {
return `${author._webUrl}/profile/${author.did}`;
}
// Fallback: Get PDS from handle for other users
const pds = detectPdsFromHandle(author.handle); const pds = detectPdsFromHandle(author.handle);
const config = getNetworkConfig(pds); const config = getNetworkConfig(pds);