Some progress towards accepting and rejecting follows #3

Merged
steffo merged 22 commits from feature/follows into main 2024-10-23 05:47:18 +00:00
3 changed files with 27 additions and 3 deletions
Showing only changes of commit 42c7f73bf5 - Show all commits

View file

@ -1,6 +1,7 @@
import { getLogger } from "@logtape/logtape" import { getLogger } from "@logtape/logtape"
import { handleHostMeta } from "../dv/hostMeta.ts" import { handleHostMeta } from "../dv/hostMeta.ts"
import { DotinoVeloce } from "../dv/dotinoVeloce.ts" import { DotinoVeloce } from "../dv/dotinoVeloce.ts"
import { handleFavicon } from "../dv/favicon.ts"
const l = getLogger(["dotino-veloce", "deno", "router"]) const l = getLogger(["dotino-veloce", "deno", "router"])
@ -21,15 +22,19 @@ export function createRouter(ap: DotinoVeloce) {
const pathname = url.pathname const pathname = url.pathname
l.debug`Request's pathname is: ${pathname}` l.debug`Request's pathname is: ${pathname}`
if (url.pathname === "/favicon.ico") {
l.debug`Delegating handling to favicon handler...`
return await handleFavicon()
}
if (url.pathname === "/.well-known/host-meta") if (url.pathname === "/.well-known/host-meta")
{ {
l.debug`Delegating handling to host-meta generator...` l.debug`Delegating handling to host-meta generator...`
return handleHostMeta(url.origin) return await handleHostMeta(url.origin)
} }
else else
{ {
l.debug`Delegating request to Fedify...` l.debug`Delegating request to Fedify...`
return ap.federation.fetch( return await ap.federation.fetch(
request, request,
{ {
contextData: undefined, contextData: undefined,

18
src/dv/favicon.ts Normal file
View file

@ -0,0 +1,18 @@
import { getLogger } from "@logtape/logtape"
const l = getLogger(["dotino-veloce", "ap", "favicon"])
export async function handleFavicon(): Promise<Response> {
l.info`Returning favicon...`
return new Response(
await Deno.readFile(".media/icon-128x128_round.png"),
{
headers: {
"Content-Type": "image/png",
},
},
)
}

View file

@ -4,7 +4,8 @@ import { getLogger } from "@logtape/logtape"
const l = getLogger(["dotino-veloce", "ap", "hostMeta"]) const l = getLogger(["dotino-veloce", "ap", "hostMeta"])
export function handleHostMeta(origin: string): Response { // deno-lint-ignore require-await
export async function handleHostMeta(origin: string): Promise<Response> {
l.info`Creating host-meta definition for: ${origin}` l.info`Creating host-meta definition for: ${origin}`
// Akkoma expects host-meta to be correctly setup // Akkoma expects host-meta to be correctly setup