allows public acces to public profiles
This commit is contained in:
@@ -325,6 +325,7 @@ func FetchCollection(actor *core.Record, url string) (*pub.OrderedCollection, er
|
||||
req.Header.Add(k, v)
|
||||
}
|
||||
|
||||
if actor != nil && actor.GetString("private_key") != "" {
|
||||
dbPrivateKey := actor.GetString("private_key")
|
||||
if dbPrivateKey != "" {
|
||||
algs := []httpsig.Algorithm{httpsig.RSA_SHA256}
|
||||
@@ -352,6 +353,7 @@ func FetchCollection(actor *core.Record, url string) (*pub.OrderedCollection, er
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function follows_a_b(a: string, b: string, f: (url: RequestInfo | U
|
||||
|
||||
const response: ListResult<Follow> = await r.json();
|
||||
|
||||
return response.items.at(0);
|
||||
return response.items.at(0) ?? null;
|
||||
}
|
||||
|
||||
export async function follows_create(followee: string) {
|
||||
|
||||
@@ -3,7 +3,6 @@ import { env } from "$env/dynamic/public";
|
||||
const privateRoutes = [
|
||||
"/settings",
|
||||
"/trail/edit/new",
|
||||
"/profile",
|
||||
"/lists/edit/new",
|
||||
]
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function GET(event: RequestEvent) {
|
||||
let followers: APOrderedCollectionPage;
|
||||
|
||||
// fetch followers locally to not run into auth issues with private profiles
|
||||
if (actor.id === event.locals.user.actor) {
|
||||
if (actor.id === event.locals.user?.actor) {
|
||||
const r = await event.fetch(actor[type as "followers" | "following"]! + '?' + new URLSearchParams({ page }))
|
||||
|
||||
if (!r.ok) {
|
||||
|
||||
@@ -12,9 +12,9 @@ export const load: ServerLoad = async ({ params, locals, fetch }) => {
|
||||
try {
|
||||
const { actor, profile } = await profile_show(params.handle, fetch);
|
||||
|
||||
const isOwnProfile = profile.id === locals.user.actor;
|
||||
const isOwnProfile = profile.id === locals.user?.actor;
|
||||
|
||||
const follow = await follows_a_b(locals.user.actor!, profile.id, fetch) ?? null
|
||||
const follow = locals.user?.actor ? await follows_a_b(locals.user.actor!, profile.id, fetch) : null
|
||||
return { profile, isOwnProfile, follow: follow, actor }
|
||||
|
||||
} catch (e) {
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
<p class="font-semibold">{data.profile.following}</p>
|
||||
<p>{$_("following")}</p>
|
||||
</a>
|
||||
{#if !data.isOwnProfile}
|
||||
{#if !data.isOwnProfile && data.user}
|
||||
<div class="px-6 mt-2">
|
||||
<Button
|
||||
loading={followLoading}
|
||||
|
||||
Reference in New Issue
Block a user