mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-25 16:24:45 +00:00
more fuckery
This commit is contained in:
@@ -8,7 +8,8 @@ import {
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Server, ServerOptions } from "lambert-server";
|
||||
import path from "path";
|
||||
import webfinger from "./webfinger";
|
||||
import hostMeta from "./well-known/host-meta";
|
||||
import webfinger from "./well-known/webfinger";
|
||||
|
||||
export class APServer extends Server {
|
||||
public declare options: ServerOptions;
|
||||
@@ -63,6 +64,7 @@ export class APServer extends Server {
|
||||
});
|
||||
|
||||
this.app.use("/.well-known/webfinger", webfinger);
|
||||
this.app.use("/.well-known/host-meta", hostMeta);
|
||||
|
||||
this.app.use(ErrorHandler);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { route } from "@spacebar/api";
|
||||
import { Config, User } from "@spacebar/util";
|
||||
import { APPerson } from "activitypub-types";
|
||||
import { User } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
const router = Router();
|
||||
@@ -11,29 +10,5 @@ router.get("/:id", route({}), async (req: Request, res: Response) => {
|
||||
|
||||
const user = await User.findOneOrFail({ where: { id } });
|
||||
|
||||
const { webDomain } = Config.get().federation;
|
||||
|
||||
const ret: APPerson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
type: "Person",
|
||||
id: `https://${webDomain}/fed/user/${user.id}`,
|
||||
name: user.username,
|
||||
preferredUsername: user.username,
|
||||
summary: user.bio,
|
||||
icon: user.avatar
|
||||
? [
|
||||
`${Config.get().cdn.endpointPublic}/avatars/${user.id}/${
|
||||
user.avatar
|
||||
}`,
|
||||
]
|
||||
: undefined,
|
||||
|
||||
inbox: `https://${webDomain}/fed/user/${user.id}/inbox`,
|
||||
outbox: `https://${webDomain}/fed/user/${user.id}/outbox`,
|
||||
followers: `https://${webDomain}/fed/user/${user.id}/followers`,
|
||||
following: `https://${webDomain}/fed/user/${user.id}/following`,
|
||||
liked: `https://${webDomain}/fed/user/${user.id}/likeds`,
|
||||
};
|
||||
|
||||
return res.json(ret);
|
||||
return res.json(user.toAP());
|
||||
});
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { route } from "@spacebar/api";
|
||||
import { Config } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
const router = Router();
|
||||
export default router;
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
res.setHeader("Content-Type", "application/xrd+xml");
|
||||
|
||||
const { webDomain } = Config.get().federation;
|
||||
|
||||
const ret = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD
|
||||
xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" type="application/xrd+xml" template="https://${webDomain}/.well-known/webfinger?resource={uri}"/>
|
||||
</XRD>`;
|
||||
|
||||
return res.send(ret);
|
||||
});
|
||||
@@ -58,6 +58,10 @@ router.get(
|
||||
type: "application/activity+json",
|
||||
href: `https://${webDomain}/fed/${type}/${resourceId}`,
|
||||
},
|
||||
// {
|
||||
// rel: "http://ostatus.org/schema/1.0/subscribe",
|
||||
// href: `"https://${webDomain}/fed/authorize-follow?acct={uri}"`,
|
||||
// },
|
||||
],
|
||||
});
|
||||
},
|
||||
@@ -500,8 +500,6 @@ export class Channel extends BaseClass {
|
||||
inbox: `https://${webDomain}/fed/channel/${this.id}/inbox`,
|
||||
outbox: `https://${webDomain}/fed/channel/${this.id}/outbox`,
|
||||
followers: `https://${webDomain}/fed/channel/${this.id}/followers`,
|
||||
following: `https://${webDomain}/fed/channel/${this.id}/following`,
|
||||
liked: `https://${webDomain}/fed/channel/${this.id}/likeds`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { APPerson } from "activitypub-types";
|
||||
import { Request } from "express";
|
||||
import {
|
||||
Column,
|
||||
@@ -271,6 +272,30 @@ export class User extends BaseClass {
|
||||
return user as UserPrivate;
|
||||
}
|
||||
|
||||
toAP(): APPerson {
|
||||
const { webDomain } = Config.get().federation;
|
||||
|
||||
return {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
type: "Person",
|
||||
id: `https://${webDomain}/fed/user/${user.id}`,
|
||||
name: this.username,
|
||||
preferredUsername: this.username,
|
||||
summary: this.bio,
|
||||
icon: this.avatar
|
||||
? [
|
||||
`${Config.get().cdn.endpointPublic}/avatars/${
|
||||
this.id
|
||||
}/${this.avatar}`,
|
||||
]
|
||||
: undefined,
|
||||
|
||||
inbox: `https://${webDomain}/fed/user/${this.id}/inbox`,
|
||||
outbox: `https://${webDomain}/fed/user/${this.id}/outbox`,
|
||||
followers: `https://${webDomain}/fed/user/${this.id}/followers`,
|
||||
};
|
||||
}
|
||||
|
||||
static async getPublicUser(user_id: string, opts?: FindOneOptions<User>) {
|
||||
return await User.findOneOrFail({
|
||||
where: { id: user_id },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
interface WebfingerLink {
|
||||
rel: string;
|
||||
type: string;
|
||||
type?: string;
|
||||
href: string;
|
||||
template?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user