fix getprofile
This commit is contained in:
@@ -431,17 +431,24 @@ function App() {
|
||||
if (user.did && user.did.includes('-placeholder')) {
|
||||
// Resolving placeholder DID
|
||||
try {
|
||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(user.handle)}`);
|
||||
if (profileResponse.ok) {
|
||||
const profileData = await profileResponse.json();
|
||||
if (profileData.did) {
|
||||
// Resolved DID
|
||||
return {
|
||||
...user,
|
||||
did: profileData.did
|
||||
};
|
||||
let profileData;
|
||||
if (agent) {
|
||||
const profileResponse = await agent.getProfile({ actor: user.handle });
|
||||
profileData = profileResponse.data;
|
||||
} else {
|
||||
// フォールバック:public API
|
||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(user.handle)}`);
|
||||
if (profileResponse.ok) {
|
||||
profileData = await profileResponse.json();
|
||||
}
|
||||
}
|
||||
if (profileData.did) {
|
||||
// Resolved DID
|
||||
return {
|
||||
...user,
|
||||
did: profileData.did
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
// Failed to resolve DID
|
||||
}
|
||||
@@ -580,23 +587,29 @@ function App() {
|
||||
sortedComments.map(async (record) => {
|
||||
if (!record.value.author?.avatar && record.value.author?.handle) {
|
||||
try {
|
||||
// Public API でプロフィール取得
|
||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(record.value.author.handle)}`);
|
||||
|
||||
if (profileResponse.ok) {
|
||||
const profileData = await profileResponse.json();
|
||||
return {
|
||||
...record,
|
||||
value: {
|
||||
...record.value,
|
||||
author: {
|
||||
...record.value.author,
|
||||
avatar: profileData.avatar,
|
||||
displayName: profileData.displayName || record.value.author.handle,
|
||||
}
|
||||
}
|
||||
};
|
||||
let profileData;
|
||||
if (agent) {
|
||||
// 認証されたAPIでプロフィール取得
|
||||
const profileResponse = await agent.getProfile({ actor: record.value.author.handle });
|
||||
profileData = profileResponse.data;
|
||||
} else {
|
||||
// フォールバック:public API
|
||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(record.value.author.handle)}`);
|
||||
if (profileResponse.ok) {
|
||||
profileData = await profileResponse.json();
|
||||
}
|
||||
}
|
||||
return {
|
||||
...record,
|
||||
value: {
|
||||
...record.value,
|
||||
author: {
|
||||
...record.value.author,
|
||||
avatar: profileData.avatar,
|
||||
displayName: profileData.displayName || record.value.author.handle,
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (err) {
|
||||
// Ignore enhancement errors
|
||||
}
|
||||
@@ -796,14 +809,21 @@ function App() {
|
||||
let resolvedDid = `did:plc:${handle.replace(/\./g, '-')}-placeholder`; // フォールバック
|
||||
|
||||
try {
|
||||
// Public APIでプロフィールを取得してDIDを解決
|
||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`);
|
||||
if (profileResponse.ok) {
|
||||
const profileData = await profileResponse.json();
|
||||
if (profileData.did) {
|
||||
resolvedDid = profileData.did;
|
||||
let profileData;
|
||||
if (agent) {
|
||||
// 認証されたAPIでプロフィールを取得してDIDを解決
|
||||
const profileResponse = await agent.getProfile({ actor: handle });
|
||||
profileData = profileResponse.data;
|
||||
} else {
|
||||
// フォールバック:public API
|
||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`);
|
||||
if (profileResponse.ok) {
|
||||
profileData = await profileResponse.json();
|
||||
}
|
||||
}
|
||||
if (profileData.did) {
|
||||
resolvedDid = profileData.did;
|
||||
}
|
||||
} catch (err) {
|
||||
}
|
||||
|
||||
@@ -1534,27 +1554,6 @@ function App() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* User Section - moved from above */}
|
||||
{user && !appConfig.rkey && (
|
||||
<div className="user-section">
|
||||
<div className="user-info">
|
||||
<div className="user-profile">
|
||||
<img
|
||||
src={user.avatar || generatePlaceholderAvatar(user.handle)}
|
||||
alt="User Avatar"
|
||||
className="user-avatar"
|
||||
/>
|
||||
<div className="user-details">
|
||||
<h3>{user.displayName || user.handle}</h3>
|
||||
<p className="user-handle">@{user.handle}</p>
|
||||
<p className="user-did">{user.did}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button onClick={handleLogout} className="logout-button">
|
||||
Logout
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Admin Section - User Management */}
|
||||
{isAdmin(user) && (
|
||||
<div className="admin-section">
|
||||
@@ -1640,9 +1639,6 @@ function App() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
|
Reference in New Issue
Block a user