shadowfacts.net/lib/activitypub/followers.ts

22 lines
624 B
TypeScript
Raw Normal View History

import express, { Router } from "express";
2019-08-18 22:28:08 +00:00
import {getConnection} from "typeorm";
import Actor from "../entity/Actor";
const domain = process.env.DOMAIN;
2019-02-20 23:07:29 +00:00
export default function followers(router: Router) {
2019-08-18 22:28:08 +00:00
router.get("/ap/actor/followers", async (req, res) => {
const followers = await getConnection().getRepository(Actor).find({where: {isFollower: true}});
res.json({
"@context": [
"https://www.w3.org/ns/activitystreams"
],
"type": "OrderedCollection",
"id": `https://${domain}/ap/actor/followers`,
"totalItems": followers.length,
"items": followers.map(it => it.id)
});
2019-08-18 22:28:08 +00:00
res.end();
});
2019-08-18 22:28:08 +00:00
}