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