Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into testing-scale
Browse files Browse the repository at this point in the history
* upstream/main: (23 commits)
  Fixed handling of missing Host and invalid Authorization headers
  Update opentelemetry-js monorepo
  Update Vite packages to v2.1.7
  Update dependency @sentry/node to v8.42.0
  Added to and cc fields to Articles
  Update dependency @fedify/fedify to v1.3.0
  Update nginx Docker tag to v1.27.3
  Update dependency @fedify/cli to v1.3.0
  Update dependency typescript to v5.7.2
  Update dependency @google-cloud/pubsub to v4.9.0
  Update dependency @logtape/logtape to v0.8.0
  Added explicit OTel dependencies
  Update wiremock/wiremock Docker tag to v3.10.0
  Update dependency @sentry/node to v8.41.0
  Update dependency @sentry/node to v8.39.0
  Update Vite packages to v2.1.6
  Update dependency mysql2 to v3.11.5
  Reduced size of activitypub collection page (#219)
  Misc cleanup after adding profile posts endpoint (#218)
  Added endpoint for retrieving profile posts (#217)
  ...
  • Loading branch information
allouis committed Dec 11, 2024
2 parents 34b8962 + 4132703 commit 9b2841d
Show file tree
Hide file tree
Showing 21 changed files with 581 additions and 566 deletions.
11 changes: 4 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ 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
[*.feature]
indent_size = 2

[*.{yml,yaml}]
indent_size = 2

[Makefile]
indent_style = tab
[*.md]
trim_trailing_whitespace = false
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</p>
&nbsp;


# ActivityPub 🚧

A multitenant ActivityPub server for [Ghost](https://ghost.org/), built with [Fedify](https://fedify.dev/). This service makes it possible for independent websites to publish their content directly to the Fediverse, enabling networked publishing to the open social web.
Expand All @@ -25,7 +24,7 @@ We're publishing a weekly build-log about the development of this project. Sign

# 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.
All requests to `/.ghost/activitypub/*`, `/.well-known/webfinger` and `/.well-known/nodeinfo` are proxied to this ActivityPub service using nginx. All other requests are forwarded to Ghost.

## Current features

Expand All @@ -41,14 +40,14 @@ All requests to `/.ghost/activitypub/*` and `/.well-known/webfinger` are proxied

# Running locally for development

This has only been tested on MacOS using [Docker for Mac](https://docs.docker.com/desktop/install/mac-install/) and [OrbStack](https://orbstack.dev/).
This has only been tested on macOS using [Docker for Mac](https://docs.docker.com/desktop/install/mac-install/) and [OrbStack](https://orbstack.dev/).

## Setup

1. **[Install Ghost](https://ghost.org/docs/install/)**
- Ensure Ghost is running locally at `localhost:2368`.
- Ensure Ghost is running locally at `localhost:2368`
2. **Proxy with [Tailscale](https://tailscale.com/kb/1080/cli?q=cli)** (or [ngrok](https://ngrok.com/))
- Use `tailscale funnel 80` or `ngrok http 80` to expose your local port 80.
- Use `tailscale funnel 80` or `ngrok http 80` to expose your local port 80
3. **Configure Ghost**
- Run `ghost config url` and set it to the URL provided by Tailscale
4. **Start the ActivityPub Service**
Expand All @@ -73,23 +72,23 @@ To enable auto-formatting on save, you'll need to set the [default formatter](ht

- Run `yarn test` to execute tests within a Docker Compose stack.


## Populating the DB

The below command will populate the DB with ~5000 followers for the `activitypub` host

- Run `docker compose run scripts populate-activitypub-db`

&nbsp;
## Migrations

![Leaderboard](https://github.com/TryGhost/ActivityPub/assets/115641230/371e8f36-8293-43d2-912a-772e56517e1d)
`docker compose run migrate` or `docker compose run migrate-testing` will run the `up` migrations against your dev or testing db respectively.

## Migrations
If you would like to run other commands you can run `docker compose exec -it migrate /bin/bash` or `docker compose exec -it migrate-testing /bin/bash` - This will drop you into a shell with the `migrate` binary available as well as a `MYSQL_DB` environment variable that is correctly formated for use as the `-database` argument to the `migrate` binary

`docker compose run migrate` or `docker compose run migrate-testing` will run the up migrations against your dev or testing db respectively.
&nbsp;

If you would like to run other commands you can run `docker compose exec -it migrate /bin/bash` or `docker compose exec -it migrate-testing /bin/bash` This will drop you into a shell with the `migrate` binary available as well as a $MYSQL_DB environment variable that is correctly formated for use as the `-database` argument to the `migrate` binary
# Community leaderboard

![Leaderboard](https://github.com/TryGhost/ActivityPub/assets/115641230/371e8f36-8293-43d2-912a-772e56517e1d)

&nbsp;

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,17 @@ services:
start_period: 5s

fake-ghost-activitypub:
image: wiremock/wiremock:3.9.2-1
image: wiremock/wiremock:3.10.0-1
entrypoint: [ "/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose", "--port=80", "--https-port=443" ]
volumes:
- ./wiremock/fake-ghost/mappings:/home/wiremock/mappings

fake-external-activitypub:
image: wiremock/wiremock:3.9.2-1
image: wiremock/wiremock:3.10.0-1
entrypoint: [ "/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose", "--port=80", "--https-port=443" ]

fake-mastodon:
image: wiremock/wiremock:3.9.2-1
image: wiremock/wiremock:3.10.0-1
ports:
- "8084:8080"
entrypoint: [ "/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose" ]
2 changes: 1 addition & 1 deletion docker/cucumber-tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/sh
#!/usr/bin/env bash

export TAGS=$1

Expand Down
25 changes: 12 additions & 13 deletions features/accept-follows.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ Feature: We automatically accept Follow requests
And "Alice" is in our Followers

Rule: We can be followed multiple times by the same actor, but we only record them once

Example: An actor attempts to follow us multiple times
Given an Actor "Person(Alice)"
And a "Follow(Us)" Activity "F1" by "Alice"
And a "Follow(Us)" Activity "F2" by "Alice"
When "Alice" sends "F1" to the Inbox
And "F1" is in our Inbox
And "Alice" sends "F2" to the Inbox
And "F2" is in our Inbox
Then an "Accept(F1)" Activity "A1" is created by "Us"
And an "Accept(F2)" Activity "A2" is created by "Us"
And Activity "A1" is sent to "Alice"
And Activity "A2" is sent to "Alice"
And "Alice" is in our Followers once only
Given an Actor "Person(Alice)"
And a "Follow(Us)" Activity "F1" by "Alice"
And a "Follow(Us)" Activity "F2" by "Alice"
When "Alice" sends "F1" to the Inbox
And "F1" is in our Inbox
And "Alice" sends "F2" to the Inbox
And "F2" is in our Inbox
Then an "Accept(F1)" Activity "A1" is created by "Us"
And an "Accept(F2)" Activity "A2" is created by "Us"
And Activity "A1" is sent to "Alice"
And Activity "A2" is sent to "Alice"
And "Alice" is in our Followers once only
71 changes: 36 additions & 35 deletions features/create-note.feature
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
Feature: Creating a note
Scenario: Note content is validated against being empty
When we attempt to create a note with no content
Then the request is rejected with a 400

Scenario: Note content is validated against being invalid
When we attempt to create a note with invalid content
Then the request is rejected with a 400
Scenario: Note content is validated against being empty
When we attempt to create a note with no content
Then the request is rejected with a 400

Scenario: Created note is added to the Outbox
When we create a note "Note" with the content
"""
Hello, world!
"""
Then "Note" is in our Outbox
Scenario: Note content is validated against being invalid
When we attempt to create a note with invalid content
Then the request is rejected with a 400

Scenario: Created note is formatted
When we create a note "Note" with the content
"""
Hello
World
"""
Then "Note" is in our Outbox
And "Note" has the content "<p>Hello<br />World</p>"
Scenario: Created note is added to the Outbox
When we create a note "Note" with the content
"""
Hello, world!
"""
Then "Note" is in our Outbox

Scenario: Created note is sent to followers
Given an Actor "Person(Alice)"
And an Actor "Person(Bob)"
And a "Follow(Us)" Activity "F1" by "Alice"
And a "Follow(Us)" Activity "F2" by "Bob"
And "Alice" sends "F1" to the Inbox
And "F1" is in our Inbox
And "Bob" sends "F2" to the Inbox
And "F2" is in our Inbox
When we create a note "Note" with the content
"""
Hello, world!
"""
Then Activity "Note" is sent to "Alice"
And Activity "Note" is sent to "Bob"
Scenario: Created note is formatted
When we create a note "Note" with the content
"""
Hello
World
"""
Then "Note" is in our Outbox
And "Note" has the content "<p>Hello<br />World</p>"

Scenario: Created note is sent to followers
Given an Actor "Person(Alice)"
And an Actor "Person(Bob)"
And a "Follow(Us)" Activity "F1" by "Alice"
And a "Follow(Us)" Activity "F2" by "Bob"
And "Alice" sends "F1" to the Inbox
And "F1" is in our Inbox
And "Bob" sends "F2" to the Inbox
And "F2" is in our Inbox
When we create a note "Note" with the content
"""
Hello, world!
"""
Then Activity "Note" is sent to "Alice"
And Activity "Note" is sent to "Bob"
1 change: 1 addition & 0 deletions migrate/bin/up
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

if [ -n "$MYSQL_DB" ]; then
echo "Running migrate -path migrations -database $MYSQL_DB up"
migrate -path migrations -database "$MYSQL_DB" up
Expand Down
2 changes: 1 addition & 1 deletion nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM nginx:1.27.2
FROM nginx:1.27.3
COPY nginx.conf /etc/nginx/nginx.conf
COPY server.conf /etc/nginx/conf.d/default.conf
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,39 @@
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@cucumber/cucumber": "10.9.0",
"@fedify/cli": "1.2.6",
"@fedify/cli": "1.3.0",
"@types/jsonwebtoken": "9.0.7",
"@types/node": "20.17.6",
"@types/node-jose": "1.1.13",
"@types/sanitize-html": "2.13.0",
"@types/sinon": "17.0.3",
"@types/uuid": "10.0.0",
"@vitest/coverage-v8": "2.1.5",
"@vitest/coverage-v8": "2.1.7",
"concurrently": "9.1.0",
"esbuild": "0.24.0",
"typescript": "5.6.3",
"vitest": "2.1.5",
"typescript": "5.7.2",
"vitest": "2.1.7",
"wiremock-captain": "3.5.0"
},
"dependencies": {
"@fedify/fedify": "1.2.6",
"@fedify/fedify": "1.3.0",
"@google-cloud/opentelemetry-cloud-trace-exporter": "2.4.1",
"@google-cloud/opentelemetry-cloud-trace-propagator": "0.20.0",
"@google-cloud/pubsub": "4.8.0",
"@google-cloud/pubsub": "4.9.0",
"@hono/node-server": "1.13.5",
"@js-temporal/polyfill": "0.4.4",
"@logtape/logtape": "0.7.1",
"@logtape/logtape": "0.8.0",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.55.0",
"@opentelemetry/sdk-trace-base": "1.28.0",
"@sentry/node": "8.38.0",
"@opentelemetry/core": "1.29.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.56.0",
"@opentelemetry/resources": "1.29.0",
"@opentelemetry/sdk-trace-base": "1.29.0",
"@sentry/node": "8.42.0",
"hono": "4.6.10",
"jsonwebtoken": "9.0.2",
"knex": "3.1.0",
"ky": "1.7.2",
"mysql2": "3.11.4",
"mysql2": "3.11.5",
"node-jose": "2.2.0",
"sanitize-html": "2.13.1",
"uuid": "10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion pubsub/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This script is used to start the Pub/Sub emulator and create the required
# topic and subscription upfront (defined in the environment variables)
Expand Down
Loading

0 comments on commit 9b2841d

Please sign in to comment.