完善账号html
This commit is contained in:
+15
-1
@@ -88,6 +88,7 @@ import {
|
||||
verifyCredentials
|
||||
} from "./mastodon";
|
||||
import { processOutgoingDeliveries } from "./federation";
|
||||
import { profilePage } from "./profile";
|
||||
|
||||
export default {
|
||||
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
||||
@@ -212,7 +213,15 @@ async function route(request: Request, env: Env): Promise<Response> {
|
||||
|
||||
if (method === "GET" && (m = path.match(/^\/media\/(.+)$/))) return serveMedia(env, m[1]);
|
||||
|
||||
if (method === "GET" && (m = path.match(/^\/users\/([^/]+)$/))) return actor(env, decodeURIComponent(m[1]));
|
||||
if (method === "GET" && (m = path.match(/^\/@([^/]+)$/))) return profilePage(env, decodeURIComponent(m[1]));
|
||||
if (method === "GET" && (m = path.match(/^\/web\/@([^/]+)$/))) return profilePage(env, decodeURIComponent(m[1]));
|
||||
if (method === "GET" && (m = path.match(/^\/web\/accounts\/([^/]+)$/))) return profilePage(env, decodeURIComponent(m[1]));
|
||||
|
||||
if (method === "GET" && (m = path.match(/^\/users\/([^/]+)$/))) {
|
||||
const username = decodeURIComponent(m[1]);
|
||||
if (wantsProfileHtml(request)) return profilePage(env, username);
|
||||
return actor(env, username);
|
||||
}
|
||||
if (method === "GET" && (m = path.match(/^\/users\/([^/]+)\/outbox$/))) return outbox(request, env, decodeURIComponent(m[1]));
|
||||
if (method === "POST" && (m = path.match(/^\/users\/([^/]+)\/inbox$/))) return inboxHandler(request, env, decodeURIComponent(m[1]));
|
||||
if (method === "POST" && path === "/inbox") return inboxHandler(request, env, null);
|
||||
@@ -222,3 +231,8 @@ async function route(request: Request, env: Env): Promise<Response> {
|
||||
|
||||
return json({ error: "not_found" }, 404);
|
||||
}
|
||||
|
||||
function wantsProfileHtml(request: Request): boolean {
|
||||
const accept = request.headers.get("accept") ?? "";
|
||||
return /\btext\/html\b/i.test(accept) && !/(application\/activity\+json|application\/ld\+json)/i.test(accept);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user