mirror of
https://github.com/turbomaster95/coderrrrr.git
synced 2025-08-02 10:42:24 +00:00
Compare commits
No commits in common. "025fa5cef57924d4588bcaa5679509559d4f2907" and "1b51bafee16f261ca1d7fd7fc2694fb1ddb54268" have entirely different histories.
025fa5cef5
...
1b51bafee1
@ -11,53 +11,48 @@ export default async function (req: VercelRequest, res: VercelResponse) {
|
|||||||
res.status(200).setHeader("Content-Type", "application/activity+json").json({
|
res.status(200).setHeader("Content-Type", "application/activity+json").json({
|
||||||
"@context": ["https://www.w3.org/ns/activitystreams", { "@language": "en-US" }],
|
"@context": ["https://www.w3.org/ns/activitystreams", { "@language": "en-US" }],
|
||||||
"type": "Person",
|
"type": "Person",
|
||||||
"id": "https://coderrrrr.site/@blog",
|
"id": "https://coderrrrr.site/blog",
|
||||||
"outbox": "https://coderrrrr.site/api/activitypub/outbox",
|
"outbox": "https://coderrrrr.site/api/activitypub/outbox",
|
||||||
"following": "https://coderrrrr.site/api/activitypub/following",
|
"following": "https://coderrrrr.site/api/activitypub/following",
|
||||||
"followers": "https://coderrrrr.site/api/activitypub/followers",
|
"followers": "https://coderrrrr.site/api/activitypub/followers",
|
||||||
"sharedInbox": "https://coderrrrr.site/api/activitypub/sharedInbox",
|
"sharedInbox": "https://coderrrrr.site/api/activitypub/sharedInbox",
|
||||||
"inbox": "https://coderrrrr.site/api/activitypub/inbox",
|
"inbox": "https://coderrrrr.site/api/activitypub/inbox",
|
||||||
"url": "https://coderrrrr.site/@blog"
|
|
||||||
"published": "2024-05-02T15:25:40Z",
|
|
||||||
"preferredUsername": "blog",
|
"preferredUsername": "blog",
|
||||||
"name": "Deva Midhun's blog",
|
"name": "Deva Midhun's blog",
|
||||||
"manuallyApprovesFollowers": false,
|
|
||||||
"discoverable": true,
|
"discoverable": true,
|
||||||
"indexable": true,
|
"indexable": true,
|
||||||
"memorial": false,
|
"summary": "Software developer & self-hosting enthusiast.",
|
||||||
"summary": "Software developer & self-hosting enthusiast. This is a bridge between my blog and the fediverse!",
|
|
||||||
"tag": [],
|
|
||||||
"icon": {
|
"icon": {
|
||||||
"type": "Image",
|
"type": "Image",
|
||||||
"mediaType": "image/png",
|
"mediaType": "image/png",
|
||||||
"url": "https://i.ibb.co/N6J5b8WS/download20250102015611.png"
|
"url": "https://i.ibb.co/N6J5b8WS/download20250102015611.png"
|
||||||
},
|
},
|
||||||
"publicKey": {
|
"url": [
|
||||||
"id": "https://coderrrrr.site/@blog#main-key",
|
|
||||||
"owner": "https://coderrrrr.site/@blog",
|
|
||||||
"publicKeyPem": process.env.ACTIVITYPUB_PUBLIC_KEY || "MISSING_PUBLIC_KEY"
|
|
||||||
},
|
|
||||||
"attachment": [
|
|
||||||
{
|
{
|
||||||
"type": "PropertyValue",
|
"type": "Link",
|
||||||
"value": "<a href=\"https://coderrrrr.site\" target=\"_blank\" rel=\"nofollow noopener me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">coderrrrr.site</span><span class=\"invisible\"></span></a>",
|
"mediaType": "text/html",
|
||||||
|
"href": "https://coderrrrr.site",
|
||||||
"name": "Website"
|
"name": "Website"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "PropertyValue",
|
"type": "Link",
|
||||||
"value": "<a href=\"https://github.com/turbomaster95\" target=\"_blank\" rel=\"nofollow noopener me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">github.com/turbomaster95</span><span class=\"invisible\"></span></a>",
|
"mediaType": "text/html",
|
||||||
|
"href": "https://github.com/turbomaster95",
|
||||||
"name": "GitHub"
|
"name": "GitHub"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "PropertyValue",
|
"type": "Link",
|
||||||
"value": "<a href=\"https://usr.cloud/@coder\" target=\"_blank\" rel=\"nofollow noopener me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">usr.cloud/@coder</span><span class=\"invisible\"></span></a>",
|
"mediaType": "text/html",
|
||||||
|
"href": "https://usr.cloud/@coder",
|
||||||
"name": "Owner"
|
"name": "Owner"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "PropertyValue",
|
|
||||||
"value": "<a href=\"https://keyoxide.org/6389542B98CB868DAC73A373ED1190B780583CF6\" target=\"_blank\" rel=\"nofollow noopener me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">keyoxide.org/6389542B98CB868DA</span><span class=\"invisible\">C73A373ED1190B780583CF6</span></a>",
|
|
||||||
"name": "Keyoxide"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"publicKey": {
|
||||||
|
"@context": "https://w3id.org/security/v1",
|
||||||
|
"@type": "Key",
|
||||||
|
"id": "https://coderrrrr.site/blog#main-key",
|
||||||
|
"owner": "https://coderrrrr.site/blog",
|
||||||
|
"publicKeyPem": process.env.ACTIVITYPUB_PUBLIC_KEY || "MISSING_PUBLIC_KEY"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import type { VercelRequest, VercelResponse } from "@vercel/node";
|
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
||||||
import admin from "firebase-admin";
|
import admin from 'firebase-admin';
|
||||||
|
|
||||||
// Initialize Firebase Admin if not already initialized.
|
|
||||||
if (!admin.apps.length) {
|
if (!admin.apps.length) {
|
||||||
admin.initializeApp({
|
admin.initializeApp({
|
||||||
credential: admin.credential.cert({
|
credential: admin.credential.cert({
|
||||||
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
||||||
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
||||||
privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, "\n")
|
privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, '\n')
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -16,25 +15,18 @@ const db = admin.firestore();
|
|||||||
|
|
||||||
export default async function (req: VercelRequest, res: VercelResponse) {
|
export default async function (req: VercelRequest, res: VercelResponse) {
|
||||||
try {
|
try {
|
||||||
const collection = db.collection("followers");
|
const collection = db.collection('followers');
|
||||||
const snapshot = await collection.select("actor").get();
|
const actors = await collection.select("actor").get();
|
||||||
|
|
||||||
// Map each document's "actor" field and filter out any null values.
|
|
||||||
const actors = snapshot.docs
|
|
||||||
.map(doc => doc.get("actor"))
|
|
||||||
.filter(actor => actor != null);
|
|
||||||
|
|
||||||
const output = {
|
const output = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
"id": "https://coderrrrr.site/api/activitypub/followers",
|
"id": "https://coderrrrr.site/api/activitypub/followers",
|
||||||
"type": "OrderedCollection",
|
"type": "OrderedCollection",
|
||||||
"totalItems": actors.length,
|
"totalItems": actors.docs.length,
|
||||||
"orderedItems": actors
|
"orderedItems": actors.docs.map(item => item.get("actor"))
|
||||||
};
|
};
|
||||||
|
|
||||||
res.status(200)
|
res.status(200).setHeader("Content-Type", "application/activity+json").json(output);
|
||||||
.setHeader("Content-Type", "application/activity+json")
|
|
||||||
.json(output);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching followers:", error);
|
console.error("Error fetching followers:", error);
|
||||||
res.status(500).json({ error: "Internal Server Error" });
|
res.status(500).json({ error: "Internal Server Error" });
|
||||||
|
@ -161,13 +161,13 @@ async function removeLike(message: AP.Like) {
|
|||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: 'https://coderrrrr.site/@blog#likes/854/undo',
|
id: 'https://coderrrrr.site/coder#likes/854/undo',
|
||||||
type: 'Undo',
|
type: 'Undo',
|
||||||
actor: 'https://coderrrrr.site/@blog',
|
actor: 'https://coderrrrr.site/coder',
|
||||||
object: {
|
object: {
|
||||||
id: 'https://coderrrrr.site/@blog#likes/854',
|
id: 'https://coderrrrr.site/coder#likes/854',
|
||||||
type: 'Like',
|
type: 'Like',
|
||||||
actor: 'https://coderrrrr.site/@blog',
|
actor: 'https://coderrrrr.site/coder',
|
||||||
object: 'https://coderrrrr.site/thoughts-on-web-follow/'
|
object: 'https://coderrrrr.site/thoughts-on-web-follow/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ async function saveFollow(message: AP.Follow, actorInformation: AP.Actor) {
|
|||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'id': `https://${domain}/${guid}`,
|
'id': `https://${domain}/${guid}`,
|
||||||
'type': 'Accept',
|
'type': 'Accept',
|
||||||
'actor': "https://coderrrrr.site/@blog",
|
'actor': "https://coderrrrr.site/coder",
|
||||||
'object': (message.actor as CoreObject).id
|
'object': (message.actor as CoreObject).id
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@ export default function (req: VercelRequest, res: VercelResponse) {
|
|||||||
{
|
{
|
||||||
"rel": "http://webfinger.net/rel/profile-page",
|
"rel": "http://webfinger.net/rel/profile-page",
|
||||||
"type": "text/html",
|
"type": "text/html",
|
||||||
"href": "https://coderrrrr.site/@blog"
|
"href": "https://coderrrrr.site/blog"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rel": "self",
|
"rel": "self",
|
||||||
"type": "application/activity+json",
|
"type": "application/activity+json",
|
||||||
"href": "https://coderrrrr.site/@blog"
|
"href": "https://coderrrrr.site/blog"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rel": "http://ostatus.org/schema/1.0/subscribe",
|
"rel": "http://ostatus.org/schema/1.0/subscribe",
|
||||||
|
@ -3,7 +3,7 @@ import { Sha256Signer } from '../../http-signature/index.js';
|
|||||||
import { createHash } from 'crypto';
|
import { createHash } from 'crypto';
|
||||||
|
|
||||||
export async function sendSignedRequest(endpoint: URL, object: AP.Activity): Promise<Response> {
|
export async function sendSignedRequest(endpoint: URL, object: AP.Activity): Promise<Response> {
|
||||||
const publicKeyId = "https://coderrrrr.site/@blog#main-key";
|
const publicKeyId = "https://coderrrrr.site/coder#main-key";
|
||||||
const privateKey = process.env.ACTIVITYPUB_PRIVATE_KEY;
|
const privateKey = process.env.ACTIVITYPUB_PRIVATE_KEY;
|
||||||
|
|
||||||
const signer = new Sha256Signer({ publicKeyId, privateKey, headerNames: ["host", "date", "digest"] });
|
const signer = new Sha256Signer({ publicKeyId, privateKey, headerNames: ["host", "date", "digest"] });
|
||||||
|
@ -24,8 +24,5 @@
|
|||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"uuid": "^11.0.5",
|
"uuid": "^11.0.5",
|
||||||
"vercel": "^41.0.2"
|
"vercel": "^41.0.2"
|
||||||
},
|
}
|
||||||
"trustedDependencies": [
|
|
||||||
"protobufjs"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
"destination": "/api/activitypub/authorize_interaction.ts"
|
"destination": "/api/activitypub/authorize_interaction.ts"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/@blog",
|
"source": "/blog",
|
||||||
"destination": "/api/activitypub/actor.ts"
|
"destination": "/api/activitypub/actor.ts"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user