-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f95538f
Showing
28 changed files
with
3,937 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.hbs] | ||
insert_final_newline = false | ||
|
||
[*.json] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
layout node | ||
use flake ./.nix/flakes/nodejs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Test, Build and Push to Artifact Registry | ||
|
||
on: | ||
push: | ||
|
||
env: | ||
IMAGE_NAME: europe-west4-docker.pkg.dev/ghost-activitypub/main/test-image | ||
|
||
jobs: | ||
build-push-artifact: | ||
environment: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v3" | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
europe-west4-docker.pkg.dev/ghost-activitypub/main/test-image | ||
tags: | | ||
type=edge,branch=main | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha,priority=1100 | ||
- name: "Build docker image" | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: "{{defaultContext}}" | ||
load: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: "Create ci docker compose file" | ||
run: | | ||
echo " | ||
services: | ||
activitypub: | ||
image: $IMAGE_NAME:$DOCKER_METADATA_OUTPUT_VERSION" > docker-compose.ci.yml | ||
- name: "Run tests" | ||
run: | | ||
docker compose -f docker-compose.testing.yml -f docker-compose.ci.yml up --abort-on-container-exit --exit-code-from activitypub | ||
- name: Login to GAR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: europe-west4-docker.pkg.dev | ||
username: _json_key | ||
password: ${{ secrets.SERVICE_ACCOUNT_KEY }} | ||
|
||
- name: "Push docker image" | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: "{{defaultContext}}" | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: "Auth with gcloud" | ||
uses: 'google-github-actions/auth@v2' | ||
with: | ||
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }} | ||
|
||
- name: "Deploy to Cloud Run" | ||
uses: 'google-github-actions/deploy-cloudrun@v2' | ||
with: | ||
image: europe-west4-docker.pkg.dev/ghost-activitypub/main/test-image:edge | ||
region: europe-west4 | ||
service: activitypub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Node template | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# IDE | ||
.idea/* | ||
*.iml | ||
*.sublime-* | ||
.vscode/* | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# Activitypub V 3 Final Custom | ||
.direnv |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
systems.url = "github:nix-systems/default"; | ||
}; | ||
|
||
outputs = { | ||
systems, | ||
nixpkgs, | ||
... | ||
} @ inputs: let | ||
yarn_overlay = final: prev: { | ||
yarn = prev.yarn.overrideAttrs(finalAttrs: prevAttrs: { | ||
# This is to make sure that yarn runs the correct node version | ||
# https://github.com/NixOS/nixpkgs/issues/145634#issuecomment-1627476963 | ||
installPhase = prevAttrs.installPhase + '' | ||
ln -fs $out/libexec/yarn/bin/yarn $out/bin/yarn | ||
ln -fs $out/libexec/yarn/bin/yarn.js $out/bin/yarn.js | ||
ln -fs $out/libexec/yarn/bin/yarn $out/bin/yarnpkg | ||
''; | ||
}); | ||
}; | ||
|
||
# This gives us a central place to set the node version | ||
node_overlay = final: prev: { | ||
nodejs = prev.nodejs; | ||
}; | ||
|
||
eachSystem = f: | ||
nixpkgs.lib.genAttrs (import systems) ( | ||
system: | ||
f ((nixpkgs.legacyPackages.${system}.extend yarn_overlay).extend node_overlay) | ||
); | ||
in { | ||
|
||
devShells = eachSystem (pkgs: { | ||
default = pkgs.mkShell { | ||
buildInputs = with pkgs; [ | ||
nodejs | ||
yarn | ||
]; | ||
|
||
shellHook = '' | ||
echo "node `${pkgs.nodejs}/bin/node --version`" | ||
''; | ||
}; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM node:lts-alpine | ||
|
||
WORKDIR /opt/activitypub | ||
|
||
COPY package.json . | ||
COPY yarn.lock . | ||
|
||
RUN yarn | ||
|
||
COPY tsconfig.json . | ||
|
||
COPY src ./src | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["node", "--import", "tsx", "src/app.ts"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2013-2024 Ghost Foundation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ActivityPub V3 Final | ||
|
||
A multitenant ActivityPub service built using the [Fedify](https://fedify.dev/) framework, designed to integrate seamlessly with [Ghost](https://ghost.org/). This service provides ActivityPub functionality for following other users and publishing to the fediverse. Ghost communicates with this service to manage all ActivityPub features. | ||
|
||
**Note:** ⚠️ This project is in its early phases and not yet ready for production | ||
|
||
## How It Works | ||
|
||
All requests to `/.ghost/activitypub/*` and `/.well-known/webfinger` are proxied to this ActivityPub service using NGINX. All other requests are forwarded to Ghost. | ||
|
||
### Current Features | ||
|
||
- [x] Follow | ||
- [ ] Unfollow | ||
- [x] Auto Accept Follows | ||
- [ ] Manually Accept/Reject Follows | ||
- [x] Publish Articles to Followers | ||
- [x] Receive Articles in Inbox | ||
- [x] Receive Notes in Inbox | ||
|
||
## Running Locally / Development | ||
|
||
You need `docker` installed - this has only been tested on MacOS using Docker for Mac and OrbStack. | ||
|
||
### Setup Steps | ||
|
||
1. **Set up a Ghost development environment** | ||
- Ensure Ghost is running locally at `localhost:2368`. | ||
2. **Proxy your local environment** | ||
- Use `tailscale funnel 80` or `ngrok http 80` to expose your local port 80. | ||
3. **Configure Ghost** | ||
- Set the URL in your Ghost config to the URL output by the above command. | ||
4. **Start the ActivityPub Service** | ||
- Run `yarn dev` in the root directory of this project. | ||
5. **Visit the Exposed URL** | ||
- Access your Ghost instance via the URL provided by Tailscale or Ngrok. | ||
6. **Configure Webhook** | ||
- Set up a webhook for the `post.published` event pointing to `https://<your-url>/.ghost/activitypub/webhooks/post/published`. | ||
7. **Enable ActivityPub Alpha** | ||
- Switch on the ActivityPub Alpha flag in Labs | ||
|
||
### Running Tests | ||
|
||
- Run `yarn test` to execute tests within a Docker Compose stack. | ||
|
||
## Related Projects and Resources | ||
|
||
- [Fedify](https://github.com/dahlia/fedify/) | ||
- [Ghost](https://github.com/TryGhost/Ghost/) | ||
|
||
# Copyright & License | ||
|
||
Copyright (c) 2013-2024 Ghost Foundation - Released under the [MIT license](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
services: | ||
activitypub: | ||
build: . | ||
environment: | ||
- MYSQL_USER=ghost | ||
- MYSQL_PASSWORD=password | ||
- MYSQL_HOST=mysql-testing | ||
- MYSQL_PORT=3306 | ||
- MYSQL_DATABASE=activitypub | ||
- NODE_ENV=testing | ||
command: yarn test:all | ||
depends_on: | ||
mysql-testing: | ||
condition: service_healthy | ||
|
||
mysql-testing: | ||
image: mysql:lts | ||
volumes: | ||
- mysql-test-volume:/var/lib/mysql | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=root | ||
- MYSQL_USER=ghost | ||
- MYSQL_PASSWORD=password | ||
- MYSQL_DATABASE=activitypub | ||
healthcheck: | ||
test: "mysql -ughost -ppassword activitypub -e 'select 1'" | ||
interval: 1s | ||
retries: 120 | ||
|
||
volumes: | ||
mysql-test-volume: |
Oops, something went wrong.