Some progress towards accepting and rejecting follows #3
7 changed files with 45 additions and 11 deletions
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
|
@ -29,6 +29,7 @@
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"envFile": "${workspaceFolder}/local.env",
|
"envFile": "${workspaceFolder}/local.env",
|
||||||
"runtimeExecutable": "/usr/bin/deno",
|
"runtimeExecutable": "/usr/bin/deno",
|
||||||
|
"restart": true,
|
||||||
"runtimeArgs": [
|
"runtimeArgs": [
|
||||||
"run",
|
"run",
|
||||||
"--watch",
|
"--watch",
|
||||||
|
|
|
@ -10,7 +10,7 @@ export async function initLogging() {
|
||||||
filters: {},
|
filters: {},
|
||||||
loggers: [
|
loggers: [
|
||||||
{ category: ["logtape", "meta"], sinks: ["console"], level: "warning" },
|
{ category: ["logtape", "meta"], sinks: ["console"], level: "warning" },
|
||||||
{ category: ["fedify"], sinks: ["console"], level: "info" },
|
{ category: ["fedify"], sinks: ["console"], level: "debug" },
|
||||||
{ category: ["dotino-veloce"], sinks: ["console"], level: "debug" },
|
{ category: ["dotino-veloce"], sinks: ["console"], level: "debug" },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
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/index.ts"
|
||||||
import { handleFavicon } from "../dv/favicon.ts"
|
import { handleFavicon } from "../dv/favicon.ts"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { getLogger } from "@logtape/logtape"
|
import { getLogger } from "@logtape/logtape"
|
||||||
|
|
||||||
|
|
||||||
const l = getLogger(["dotino-veloce", "ap", "favicon"])
|
const l = getLogger(["dotino-veloce", "dv", "favicon"])
|
||||||
|
|
||||||
|
|
||||||
export async function handleFavicon(): Promise<Response> {
|
export async function handleFavicon(): Promise<Response> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { getLogger } from "@logtape/logtape"
|
import { getLogger } from "@logtape/logtape"
|
||||||
|
|
||||||
|
|
||||||
const l = getLogger(["dotino-veloce", "ap", "hostMeta"])
|
const l = getLogger(["dotino-veloce", "dv", "hostMeta"])
|
||||||
|
|
||||||
|
|
||||||
// deno-lint-ignore require-await
|
// deno-lint-ignore require-await
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// deno-lint-ignore-file require-await
|
// deno-lint-ignore-file require-await
|
||||||
import { createFederation, Person, Application, Image, PropertyValue, Organization, Federation, KvStore, Context, Actor, Follow, Endpoints, importSpki, importJwk } from "@fedify/fedify"
|
import { createFederation, Person, Application, Image, PropertyValue, Organization, Federation, KvStore, Context, Actor, Follow, Endpoints, importSpki, importJwk, NodeInfo } from "@fedify/fedify"
|
||||||
import { getLogger } from "https://jsr.io/@logtape/logtape/0.6.3/logtape/logger.ts"
|
import { getLogger } from "https://jsr.io/@logtape/logtape/0.6.3/logtape/logger.ts"
|
||||||
import { escapeHtml } from "@@x/escape"
|
import { escapeHtml } from "@@x/escape"
|
||||||
import { StratzAPI } from "../stratz/api.ts"
|
import { StratzAPI } from "../stratz/api.ts"
|
||||||
import { Database } from "../database/index.ts"
|
import { Database } from "../database/index.ts"
|
||||||
|
|
||||||
|
|
||||||
const l = getLogger(["dotino-veloce", "ap", "federation"])
|
const l = getLogger(["dotino-veloce", "dv", "index"])
|
||||||
|
|
||||||
|
|
||||||
type ContextData = undefined
|
type ContextData = undefined
|
||||||
|
@ -21,17 +21,50 @@ export class DotinoVeloce {
|
||||||
this.db = db
|
this.db = db
|
||||||
this.stratz = stratz
|
this.stratz = stratz
|
||||||
|
|
||||||
this.federation = createFederation<ContextData>({ kv: db.useAsKvStore() })
|
this.federation = createFederation<ContextData>({
|
||||||
|
kv: db.useAsKvStore(),
|
||||||
|
})
|
||||||
|
|
||||||
this.federation
|
this.federation
|
||||||
.setActorDispatcher("/users/{identifier}", this.#actorHandler.bind(this))
|
.setActorDispatcher("/users/{identifier}", this.#actorHandler.bind(this))
|
||||||
.setKeyPairsDispatcher(this.#actorKeys.bind(this))
|
.setKeyPairsDispatcher(this.#actorKeys.bind(this))
|
||||||
.mapHandle(this.#actorMapper.bind(this))
|
.mapHandle(this.#actorMapper.bind(this))
|
||||||
.authorize(this.#authorizationHandler.bind(this))
|
|
||||||
|
|
||||||
this.federation
|
this.federation
|
||||||
.setInboxListeners("/inbox/{identifier}", "/inbox")
|
.setInboxListeners("/inbox/{identifier}", "/inbox")
|
||||||
|
// Akkoma with Authorized Fetch requires this to be set
|
||||||
|
// https://p.junimo.party/#/junimo.party/s/AnFW6s3OURPMY04LKq?view=full
|
||||||
|
.setSharedKeyDispatcher((_ctx: Context<ContextData>) => ({ identifier: "service" }))
|
||||||
.on(Follow, this.#followHandler.bind(this))
|
.on(Follow, this.#followHandler.bind(this))
|
||||||
|
|
||||||
|
this.federation
|
||||||
|
.setNodeInfoDispatcher("/nodeinfo/2.1", this.#nodeInfoHandler.bind(this))
|
||||||
|
|
||||||
|
// TODO: Setup a message queue
|
||||||
|
}
|
||||||
|
|
||||||
|
async #nodeInfoHandler(ctx: Context<ContextData>): Promise<NodeInfo> {
|
||||||
|
return {
|
||||||
|
software: {
|
||||||
|
name: "dotino-veloce",
|
||||||
|
version: {
|
||||||
|
major: 0,
|
||||||
|
minor: 1,
|
||||||
|
patch: 0,
|
||||||
|
},
|
||||||
|
repository: new URL("https://forge.steffo.eu/steffo/dotino-veloce"),
|
||||||
|
},
|
||||||
|
protocols: ["activitypub"],
|
||||||
|
usage: {
|
||||||
|
users: {
|
||||||
|
total: 0,
|
||||||
|
activeHalfyear: 0,
|
||||||
|
activeMonth: 0,
|
||||||
|
},
|
||||||
|
localPosts: 0,
|
||||||
|
localComments: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async #commonActorProperties(ctx: Context<ContextData>, handle: string): Promise<Partial<Actor>> {
|
async #commonActorProperties(ctx: Context<ContextData>, handle: string): Promise<Partial<Actor>> {
|
||||||
|
@ -67,7 +100,7 @@ export class DotinoVeloce {
|
||||||
l.debug`Handle ${handle}'s SteamID seems to be: ${steamId}`
|
l.debug`Handle ${handle}'s SteamID seems to be: ${steamId}`
|
||||||
|
|
||||||
l.debug`Making sure the SteamID parsing didn't explode...`
|
l.debug`Making sure the SteamID parsing didn't explode...`
|
||||||
if(Number.isFinite(steamId)) {
|
if(!Number.isFinite(steamId)) {
|
||||||
l.error`SteamID parsing for ${handle} exploded with ${steamId}, returning null.`
|
l.error`SteamID parsing for ${handle} exploded with ${steamId}, returning null.`
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -105,7 +138,7 @@ export class DotinoVeloce {
|
||||||
name: "DOTABUFF",
|
name: "DOTABUFF",
|
||||||
value: `<a href="https://www.dotabuff.com/players/${player.id}">https://www.dotabuff.com/players/${player.id}</a>`,
|
value: `<a href="https://www.dotabuff.com/players/${player.id}">https://www.dotabuff.com/players/${player.id}</a>`,
|
||||||
}),
|
}),
|
||||||
]
|
],
|
||||||
})
|
})
|
||||||
l.debug`Generated ActivityPub actor for player ${steamId}: ${actor}`
|
l.debug`Generated ActivityPub actor for player ${steamId}: ${actor}`
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { initLogging } from "../deno/logging.ts"
|
||||||
import { StratzAPI } from "../stratz/api.ts"
|
import { StratzAPI } from "../stratz/api.ts"
|
||||||
import { behindProxy, Fetch } from "@hongminhee/x-forwarded-fetch"
|
import { behindProxy, Fetch } from "@hongminhee/x-forwarded-fetch"
|
||||||
import { createRouter } from "../deno/router.ts"
|
import { createRouter } from "../deno/router.ts"
|
||||||
import { DotinoVeloce } from "../dv/dotinoVeloce.ts"
|
import { DotinoVeloce } from "../dv/index.ts"
|
||||||
import { Database } from "../database/index.ts"
|
import { Database } from "../database/index.ts"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue