Skip to content

Commit

Permalink
feat(worker/activitypub): modify mastodon data transformation logic (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankLi123 authored Oct 13, 2024
1 parent 6384e43 commit 7c28cb5
Show file tree
Hide file tree
Showing 13 changed files with 974 additions and 467 deletions.
283 changes: 282 additions & 1 deletion docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
{
"description": "Retrieve the details of decentralized activities.",
"name": "Decentralized"
},
{
"description": "Retrieve the details of federated activities.",
"name": "Federated"
}
],
"paths": {
Expand Down Expand Up @@ -276,6 +280,270 @@
}
}
},


"/federated/tx/{id}": {
"get": {
"summary": "Get Activity by ID",
"description": "Retrieve details for the specified activity ID.",
"tags": [
"Federated"
],
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"$ref": "#/components/parameters/activity_id_path"
},
{
"$ref": "#/components/parameters/action_limit_query"
},
{
"$ref": "#/components/parameters/action_page_query"
}
],
"responses": {
"200": {
"$ref": "#/components/responses/ActivityResponse"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
},
"/federated/{account}": {
"get": {
"summary": "Get Account Activities",
"description": "This endpoint retrieves the activities associated with a specified account in the federated system. You can use various query parameters to filter and paginate the results, including limits on the number of activities and actions, timestamps, success status, direction, and more.",
"tags": [
"Federated"
],
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"$ref": "#/components/parameters/account_path"
},
{
"$ref": "#/components/parameters/limit_query"
},
{
"$ref": "#/components/parameters/action_limit_query"
},
{
"$ref": "#/components/parameters/cursor_query"
},
{
"$ref": "#/components/parameters/since_timestamp_query"
},
{
"$ref": "#/components/parameters/until_timestamp_query"
},
{
"$ref": "#/components/parameters/success_query"
},
{
"$ref": "#/components/parameters/direction_query"
},
{
"$ref": "#/components/parameters/network_query"
},
{
"$ref": "#/components/parameters/tag_query"
},
{
"$ref": "#/components/parameters/type_query"
},
{
"$ref": "#/components/parameters/platform_query"
}
],
"responses": {
"200": {
"$ref": "#/components/responses/ActivitiesResponse"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
},
"/federated/accounts": {
"post": {
"summary": "Batch Get Accounts Activities",
"description": "Retrieve a batch of activities associated with multiple specified accounts in the federated system. You can use various query parameters to filter and paginate the results, including limits on the number of activities and actions, timestamps, success status, direction, and more.",
"tags": [
"Federated"
],
"security": [
{
"bearerAuth": []
}
],
"requestBody": {
"$ref": "#/components/requestBodies/BatchGetAccountsActivities"
},
"responses": {
"200": {
"$ref": "#/components/responses/ActivitiesResponse"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
},
"/federated/network/{network}": {
"get": {
"summary": "Get Network Activities",
"description": "Retrieve a list of activities from the specified federated network. This endpoint allows you to filter activities by various parameters such as limit, timestamp, success status, and more.",
"tags": [
"Federated"
],
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"$ref": "#/components/parameters/network_path"
},
{
"$ref": "#/components/parameters/limit_query"
},
{
"$ref": "#/components/parameters/action_limit_query"
},
{
"$ref": "#/components/parameters/cursor_query"
},
{
"$ref": "#/components/parameters/since_timestamp_query"
},
{
"$ref": "#/components/parameters/until_timestamp_query"
},
{
"$ref": "#/components/parameters/success_query"
},
{
"$ref": "#/components/parameters/direction_query"
},
{
"$ref": "#/components/parameters/tag_query"
},
{
"$ref": "#/components/parameters/type_query"
},
{
"$ref": "#/components/parameters/platform_query"
}
],
"responses": {
"200": {
"$ref": "#/components/responses/ActivitiesResponse"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
},
"/federated/platform/{platform}": {
"get": {
"summary": "Get Platform Activities",
"description": "Retrieve a list of activities from the specified federated platform. This endpoint allows you to filter activities by various parameters such as limit, timestamp, success status, and more.",
"tags": [
"Federated"
],
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"$ref": "#/components/parameters/platform_path"
},
{
"$ref": "#/components/parameters/limit_query"
},
{
"$ref": "#/components/parameters/action_limit_query"
},
{
"$ref": "#/components/parameters/cursor_query"
},
{
"$ref": "#/components/parameters/since_timestamp_query"
},
{
"$ref": "#/components/parameters/until_timestamp_query"
},
{
"$ref": "#/components/parameters/success_query"
},
{
"$ref": "#/components/parameters/direction_query"
},
{
"$ref": "#/components/parameters/tag_query"
},
{
"$ref": "#/components/parameters/type_query"
},
{
"$ref": "#/components/parameters/network_query"
}
],
"responses": {
"200": {
"$ref": "#/components/responses/ActivitiesResponse"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
},



"/rss/{path}": {
"get": {
"summary": "Get RSS Activity by Path",
Expand Down Expand Up @@ -1122,7 +1390,20 @@
"indexed_state": 0
}
],
"federated": null
"federated": [
{
"worker_id": "mastodon-core",
"network": "mastodon",
"worker": "mastodon",
"tags": [
"social"
],
"platform": "mastodon",
"status": "Ready",
"remote_state": 0,
"indexed_state": 0
}
]
}
},
"NetworkConfig": {
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ require (
github.com/emirpasic/gods v1.18.1
github.com/go-redsync/redsync/v4 v4.13.0
github.com/grafana/pyroscope-go v1.1.2
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056
github.com/mitchellh/mapstructure v1.5.0
github.com/redis/rueidis v1.0.45
github.com/redis/rueidis/rueidiscompat v1.0.45
Expand Down Expand Up @@ -132,6 +133,7 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
Expand All @@ -146,6 +148,7 @@ require (
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
Expand All @@ -157,13 +160,15 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/tdewolff/parse/v2 v2.7.15 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 h1:iCHtR9CQyktQ5+f3dMVZfwD2KWJUgm7M0gdL9NGr8KA=
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
Expand Down Expand Up @@ -279,6 +281,7 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
Expand Down Expand Up @@ -425,6 +428,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
Loading

0 comments on commit 7c28cb5

Please sign in to comment.