switches username and preferred_username

This commit is contained in:
Christian Beutel
2025-06-24 17:55:59 +02:00
parent cb4f4f8125
commit 8bf8642703
39 changed files with 175 additions and 70 deletions

View File

@@ -34,11 +34,11 @@
const actors = await searchActors(q);
searchDropdownItems = actors.map((a) => ({
text: a.username,
description: `@${a.username}${a.isLocal ? "" : "@" + a.domain}`,
description: `@${a.preferred_username}${a.isLocal ? "" : "@" + a.domain}`,
value: a,
icon:
a.icon ||
`https://api.dicebear.com/7.x/initials/svg?seed=${a.username}&backgroundType=gradientLinear`,
`https://api.dicebear.com/7.x/initials/svg?seed=${a.preferred_username}&backgroundType=gradientLinear`,
}));
} else {
const r = await searchMulti({
@@ -89,9 +89,9 @@
goto(`/trail/view/${item.value}`);
} else if (item.icon == "layer-group") {
goto(`/lists/${item.value}`);
} else if (item.value.username) {
} else if (item.value.preferred_username) {
goto(
`/profile/@${item.value.username}${item.value.isLocal ? "" : "@" + item.value.domain}`,
`/profile/@${item.value.preferred_username}${item.value.isLocal ? "" : "@" + item.value.domain}`,
);
} else {
goto(`/map/?lat=${item.value.lat}&lon=${item.value.lon}`);

View File

@@ -36,7 +36,7 @@ export async function GET(event: RequestEvent) {
outbox: id + '/outbox',
summary: user.bio,
name: actor.username,
preferredUsername: user.username,
preferredUsername: actor.preferred_username,
followers: id + '/followers',
following: id + '/following',
url: `${env.ORIGIN}/profile/@${username}`,

View File

@@ -41,15 +41,21 @@ export async function GET(event: RequestEvent) {
remoteComments.items = remoteComments.items.filter(c => {
const iriId = c.iri?.substring(c.iri.length - 15) ?? ""
if (deduplicationMap[c.id!] != undefined) {
deduplicationMap[c.id!] = {...c, author: deduplicationMap[c.id!].author}
deduplicationMap[c.id!] = { ...c, author: deduplicationMap[c.id!].author }
return false
} else if (deduplicationMap[iriId] != undefined) {
deduplicationMap[iriId] = {...c, author: deduplicationMap[iriId].author}
deduplicationMap[iriId] = { ...c, author: deduplicationMap[iriId].author }
return false
}
return true
})
remoteComments.items.forEach(c => {
if (!c.iri?.length) {
c.iri = `${url}/${c.id}`
}
})
const allCommentItems = <ListResult<Comment>>{
items: localComments.items.concat(remoteComments.items),
page: localComments.page,

View File

@@ -21,7 +21,7 @@ export async function POST(event: RequestEvent) {
r = await event.locals.ms.index("lists").search(data.q, { ...data.options, filter: `author = ${actor.id}` });
} else {
const origin = new URL(actor.iri).origin
const url = `${origin}/api/v1/profile/${actor.username}/lists?` + event.url.searchParams
const url = `${origin}/api/v1/profile/${actor.preferred_username}/lists?` + event.url.searchParams
const response = await event.fetch(url, { method: 'POST', body: JSON.stringify(data) })
if (!response.ok) {

View File

@@ -22,7 +22,7 @@ export async function GET(event: RequestEvent) {
.getList<SummitLog>(safeSearchParams.page, safeSearchParams.perPage, { ...safeSearchParams, filter: `author='${actor.id}'` })
} else {
const origin = new URL(actor.iri).origin
const summitLogURL = `${origin}/api/v1/profile/${actor.username}/stats?` + event.url.searchParams
const summitLogURL = `${origin}/api/v1/profile/${actor.preferred_username}/stats?` + event.url.searchParams
const response = await event.fetch(summitLogURL, { method: 'GET' })
if (!response.ok) {
const errorResponse = await response.json()

View File

@@ -23,7 +23,7 @@ export async function GET(event: RequestEvent) {
.getList<TimelineItem>(safeSearchParams.page, safeSearchParams.perPage, { ...safeSearchParams, filter: `author='${actor.iri}'` })
} else {
const origin = new URL(actor.iri).origin
const timelineURL = `${origin}/api/v1/profile/${actor.username}/timeline?` + event.url.searchParams
const timelineURL = `${origin}/api/v1/profile/${actor.preferred_username}/timeline?` + event.url.searchParams
const response = await event.fetch(timelineURL, { method: 'GET' })
if (!response.ok) {

View File

@@ -20,7 +20,7 @@ export async function POST(event: RequestEvent) {
r = await event.locals.ms.index("trails").search(data.q, { ...data.options, filter: `author = ${actor.id}` });
} else {
const origin = new URL(actor.iri).origin
const url = `${origin}/api/v1/profile/${actor.username}/trails?` + event.url.searchParams
const url = `${origin}/api/v1/profile/${actor.preferred_username}/trails?` + event.url.searchParams
const response = await event.fetch(url, { method: 'POST', body: JSON.stringify(data) })
if (!response.ok) {

View File

@@ -32,7 +32,8 @@ export async function GET(event: RequestEvent) {
}
t = {
iri: iri,
author: actor.id
author: actor.id,
like_count: 0
} as Trail
}

View File

@@ -64,13 +64,13 @@
<img
class="rounded-full w-16 aspect-square overflow-hidden shrink-0"
src={data.profile.icon ||
`https://api.dicebear.com/7.x/initials/svg?seed=${data.profile.username}&backgroundType=gradientLinear`}
`https://api.dicebear.com/7.x/initials/svg?seed=${data.profile.preferredUsername}&backgroundType=gradientLinear`}
alt="avatar"
/>
<div>
<h4 class="text-2xl font-semibold col-start-2">
{data.profile.preferredUsername ??
data.profile.username}
{data.profile.username ??
"?"}
</h4>
<p class="text-sm text-gray-500 mb-4 break-all">
{data.profile.acct}

View File

@@ -69,7 +69,7 @@
<div class="space-y-4">
<h4 class="text-xl font-semibold">
{$_("about")}
{data.profile.preferredUsername}
{data.profile.username}
{#if data.isOwnProfile && data.profile.bio.length}
<a aria-label="Edit bio" class="ml-4" href="/settings/profile"
><i class="fa fa-pen text-base"></i></a

View File

@@ -64,7 +64,7 @@
<ul class="space-y-4">
{#each follows.items as follow}
<a
href="/profile/@{follow.username}{follow.isLocal
href="/profile/@{follow.preferred_username}{follow.isLocal
? ''
: '@' + follow.domain}"
>
@@ -74,15 +74,15 @@
<img
class="rounded-full w-10 aspect-square overflow-hidden"
src={follow.icon ||
`https://api.dicebear.com/7.x/initials/svg?seed=${follow.username}&backgroundType=gradientLinear`}
`https://api.dicebear.com/7.x/initials/svg?seed=${follow.preferred_username}&backgroundType=gradientLinear`}
alt="avatar"
/>
<div>
<p class="text-lg font-medium">
{follow.preferred_username}
{follow.username}
</p>
<p class="text-sm text-gray-500 break-all">
@{follow.username}@{follow.domain}
@{follow.preferred_username}@{follow.domain}
</p>
</div>
</li>