mirror of
https://github.com/versia-pub/activitypub.git
synced 2025-12-06 06:38:20 +01:00
feat: rename to Versia
This commit is contained in:
parent
29d8fc718a
commit
0b4574b2d1
|
|
@ -1,4 +1,4 @@
|
||||||
DATABASE_URL="sqlite:///home/aprl/Documents/lysand-ap-layer/db.sqlite?mode=rwc"
|
DATABASE_URL="sqlite:///home/aprl/Documents/versia-ap-layer/db.sqlite?mode=rwc"
|
||||||
LYSAND_DOMAIN="social.lysand.org"
|
LYSAND_DOMAIN="versia.social"
|
||||||
API_DOMAIN="ap.lysand.org"
|
API_DOMAIN="ap.versia.social"
|
||||||
RUST_LOG="debug"
|
RUST_LOG="debug"
|
||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1930,7 +1930,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lysand-ap-layer"
|
name = "versia-ap-layer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"activitypub_federation",
|
"activitypub_federation",
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
[package]
|
[package]
|
||||||
name = "lysand-ap-layer"
|
name = "versia-ap-layer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["April John <aprl@acab.dev>"]
|
authors = ["April John <aprl@acab.dev>"]
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
repository = "https://github.com/lysand-org/lysand-ap-layer"
|
repository = "https://github.com/versia-pub/versia-ap-layer"
|
||||||
description = "A compatibility layer between lysands official server and activitypub"
|
description = "A compatibility layer between versias official server and activitypub"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.20.0", features = ["rt", "macros"] }
|
tokio = { version = "1.20.0", features = ["rt", "macros"] }
|
||||||
|
|
|
||||||
34
Changelog.md
34
Changelog.md
|
|
@ -1,22 +1,22 @@
|
||||||
## 2024-04-14, Version 0.1.0
|
## 2024-04-14, Version 0.1.0
|
||||||
### Commits
|
### Commits
|
||||||
- [[`51a708a1c3`](https://github.com/lysand-org/lysand-ap-layer/commit/51a708a1c3d1aa974deb148156c07dfe7e775a8c)] feat! AGPL3 + Contributor Covenant (April John)
|
- [[`51a708a1c3`](https://github.com/versia-pub/versia-ap-layer/commit/51a708a1c3d1aa974deb148156c07dfe7e775a8c)] feat! AGPL3 + Contributor Covenant (April John)
|
||||||
- [[`cc663ffc9b`](https://github.com/lysand-org/lysand-ap-layer/commit/cc663ffc9b56b4b1a93ceaa2e488fc554e597790)] arbeiter (aprilthepink)
|
- [[`cc663ffc9b`](https://github.com/versia-pub/versia-ap-layer/commit/cc663ffc9b56b4b1a93ceaa2e488fc554e597790)] arbeiter (aprilthepink)
|
||||||
- [[`1e6c005698`](https://github.com/lysand-org/lysand-ap-layer/commit/1e6c005698df8c781c60abfb1bab94d0b968c4d9)] enable ttp sign (aprilthepink)
|
- [[`1e6c005698`](https://github.com/versia-pub/versia-ap-layer/commit/1e6c005698df8c781c60abfb1bab94d0b968c4d9)] enable ttp sign (aprilthepink)
|
||||||
- [[`0060d8baa8`](https://github.com/lysand-org/lysand-ap-layer/commit/0060d8baa8b356d61d0aabfcd6b6f5143a47e8fa)] boop (aprilthepink)
|
- [[`0060d8baa8`](https://github.com/versia-pub/versia-ap-layer/commit/0060d8baa8b356d61d0aabfcd6b6f5143a47e8fa)] boop (aprilthepink)
|
||||||
- [[`522ecabd07`](https://github.com/lysand-org/lysand-ap-layer/commit/522ecabd078b7b35276f2aa4f255f967f0b958bf)] aaaa (aprilthepink)
|
- [[`522ecabd07`](https://github.com/versia-pub/versia-ap-layer/commit/522ecabd078b7b35276f2aa4f255f967f0b958bf)] aaaa (aprilthepink)
|
||||||
- [[`e75b523bb3`](https://github.com/lysand-org/lysand-ap-layer/commit/e75b523bb3d74bcf696313a320c35caa6f78e225)] awa (aprilthepink)
|
- [[`e75b523bb3`](https://github.com/versia-pub/versia-ap-layer/commit/e75b523bb3d74bcf696313a320c35caa6f78e225)] awa (aprilthepink)
|
||||||
- [[`76d20cb2ef`](https://github.com/lysand-org/lysand-ap-layer/commit/76d20cb2ef8b3ef3ebe68e5a58c6f7588597ad4e)] awa (aprilthepink)
|
- [[`76d20cb2ef`](https://github.com/versia-pub/versia-ap-layer/commit/76d20cb2ef8b3ef3ebe68e5a58c6f7588597ad4e)] awa (aprilthepink)
|
||||||
- [[`4d3657132d`](https://github.com/lysand-org/lysand-ap-layer/commit/4d3657132d764e71f70878de1ee1a284427eb7bb)] mew (aprilthepink)
|
- [[`4d3657132d`](https://github.com/versia-pub/versia-ap-layer/commit/4d3657132d764e71f70878de1ee1a284427eb7bb)] mew (aprilthepink)
|
||||||
- [[`643dc59b4b`](https://github.com/lysand-org/lysand-ap-layer/commit/643dc59b4bb0d7da13daf8d6ef47f3e0f31d1500)] Use Action badge on readme (aprilthepink)
|
- [[`643dc59b4b`](https://github.com/versia-pub/versia-ap-layer/commit/643dc59b4bb0d7da13daf8d6ef47f3e0f31d1500)] Use Action badge on readme (aprilthepink)
|
||||||
- [[`3f4618d4d2`](https://github.com/lysand-org/lysand-ap-layer/commit/3f4618d4d2291e16369fbb4ecddd35d6a841833e)] [feat] GH nix builds (aprilthepink)
|
- [[`3f4618d4d2`](https://github.com/versia-pub/versia-ap-layer/commit/3f4618d4d2291e16369fbb4ecddd35d6a841833e)] [feat] GH nix builds (aprilthepink)
|
||||||
- [[`9bc640aadc`](https://github.com/lysand-org/lysand-ap-layer/commit/9bc640aadcd2c02374fa195aed09452b4a3bb3ea)] [fix] format files (aprilthepink)
|
- [[`9bc640aadc`](https://github.com/versia-pub/versia-ap-layer/commit/9bc640aadcd2c02374fa195aed09452b4a3bb3ea)] [fix] format files (aprilthepink)
|
||||||
- [[`b90a332b3c`](https://github.com/lysand-org/lysand-ap-layer/commit/b90a332b3c1e23198d1fad3caddcc8b69dee6a4b)] basic AP (aprilthepink)
|
- [[`b90a332b3c`](https://github.com/versia-pub/versia-ap-layer/commit/b90a332b3c1e23198d1fad3caddcc8b69dee6a4b)] basic AP (aprilthepink)
|
||||||
- [[`1c09eb793d`](https://github.com/lysand-org/lysand-ap-layer/commit/1c09eb793db0e9b29f3d45b044e269311420ed8b)] Rework readme (aprilthepink)
|
- [[`1c09eb793d`](https://github.com/versia-pub/versia-ap-layer/commit/1c09eb793db0e9b29f3d45b044e269311420ed8b)] Rework readme (aprilthepink)
|
||||||
- [[`091b8efe8e`](https://github.com/lysand-org/lysand-ap-layer/commit/091b8efe8e0578304a81722d11e12db906c4edbc)] [feat]: basic nix dev enviroment (aprilthepink)
|
- [[`091b8efe8e`](https://github.com/versia-pub/versia-ap-layer/commit/091b8efe8e0578304a81722d11e12db906c4edbc)] [feat]: basic nix dev enviroment (aprilthepink)
|
||||||
- [[`51c7a6d6a2`](https://github.com/lysand-org/lysand-ap-layer/commit/51c7a6d6a2054f6dafbbac70c6b41239e56e2fe9)] Removed mod entities from main.rs (Helba)
|
- [[`51c7a6d6a2`](https://github.com/versia-pub/versia-ap-layer/commit/51c7a6d6a2054f6dafbbac70c6b41239e56e2fe9)] Removed mod entities from main.rs (Helba)
|
||||||
- [[`9a021e768d`](https://github.com/lysand-org/lysand-ap-layer/commit/9a021e768d62d4355324f9137e63ae279358ebed)] Create LICENSE (Helba)
|
- [[`9a021e768d`](https://github.com/versia-pub/versia-ap-layer/commit/9a021e768d62d4355324f9137e63ae279358ebed)] Create LICENSE (Helba)
|
||||||
- [[`9609c7ab83`](https://github.com/lysand-org/lysand-ap-layer/commit/9609c7ab83251ca31ded4f0589a7dac04ceca874)] initial commit (Helba)
|
- [[`9609c7ab83`](https://github.com/versia-pub/versia-ap-layer/commit/9609c7ab83251ca31ded4f0589a7dac04ceca874)] initial commit (Helba)
|
||||||
|
|
||||||
### Stats
|
### Stats
|
||||||
```diff
|
```diff
|
||||||
|
|
|
||||||
10
README.MD
10
README.MD
|
|
@ -1,13 +1,13 @@
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://lysand.org"><img src="https://cdn.lysand.org/logo-long-dark.webp" alt="Lysand Logo" height="110"></a>
|
<a href="https://versia.pub"><img src="https://cdn.versia.pub/branding/logo-dark.svg" alt="Versia Logo" height="110"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Lysand ActivityPub Bridge
|
## Versia ActivityPub Bridge
|
||||||
|
|
||||||
[](https://github.com/lysand-org/activitypub/actions/workflows/nix-flake.yml)
|
[](https://github.com/versia-pub/activitypub/actions/workflows/nix-flake.yml)
|
||||||
|
|
||||||
**ActivityPub/ActivityStreams** compatibility layer for [**Lysand Server**](https://github.com/lysand-org/lysand).
|
**ActivityPub/ActivityStreams** compatibility layer for [**Versia Server**](https://github.com/versia-pub/versia).
|
||||||
|
|
||||||
Designed as a microservice, runs as its own process and communicates with the main server via HTTP.
|
Designed as a microservice, runs as its own process and communicates with the main server via HTTP.
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ docker build -t activitypub:latest .
|
||||||
To run the docker image, use the [`docker-compose.yml`](./docker-compose.yml) file:
|
To run the docker image, use the [`docker-compose.yml`](./docker-compose.yml) file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wget https://raw.githubusercontent.com/lysand-org/activitypub/main/docker-compose.yml
|
wget https://raw.githubusercontent.com/versia-pub/activitypub/main/docker-compose.yml
|
||||||
|
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,4 @@ services:
|
||||||
- LISTEN=0.0.0.0:8080
|
- LISTEN=0.0.0.0:8080
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
image: ghcr.io/lysand-org/activitypub:main
|
image: ghcr.io/versia-pub/activitypub:main
|
||||||
|
|
|
||||||
12
flake.nix
12
flake.nix
|
|
@ -53,11 +53,11 @@
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
overlayAttrs = {
|
overlayAttrs = {
|
||||||
inherit (config.packages) lysand-ap-layer ls-ap-migration;
|
inherit (config.packages) versia-ap-layer ls-ap-migration;
|
||||||
};
|
};
|
||||||
# Rust package
|
# Rust package
|
||||||
packages.default = config.packages.lysand-ap-layer;
|
packages.default = config.packages.versia-ap-layer;
|
||||||
packages.lysand-ap-layer = naersk'.buildPackage {
|
packages.versia-ap-layer = naersk'.buildPackage {
|
||||||
inherit (cargoToml.package) name version;
|
inherit (cargoToml.package) name version;
|
||||||
src = ./.;
|
src = ./.;
|
||||||
buildInputs = nonRustDeps;
|
buildInputs = nonRustDeps;
|
||||||
|
|
@ -77,10 +77,10 @@
|
||||||
};
|
};
|
||||||
packages.ociImage = pkgs.dockerTools.buildLayeredImage
|
packages.ociImage = pkgs.dockerTools.buildLayeredImage
|
||||||
{
|
{
|
||||||
name = "ghcr.io/lysand-org/activitypub";
|
name = "ghcr.io/versia-pub/activitypub";
|
||||||
tag = "main";
|
tag = "main";
|
||||||
contents = [
|
contents = [
|
||||||
config.packages.lysand-ap-layer
|
config.packages.versia-ap-layer
|
||||||
config.packages.ls-ap-migration
|
config.packages.ls-ap-migration
|
||||||
pkgs.bash
|
pkgs.bash
|
||||||
];
|
];
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
"${config.packages.ls-ap-migration}/bin/ls-ap-migration"
|
"${config.packages.ls-ap-migration}/bin/ls-ap-migration"
|
||||||
"up"
|
"up"
|
||||||
"&&"
|
"&&"
|
||||||
"${config.packages.lysand-ap-layer}/bin/lysand-ap-layer"
|
"${config.packages.versia-ap-layer}/bin/versia-ap-layer"
|
||||||
];
|
];
|
||||||
ExposedPorts = {
|
ExposedPorts = {
|
||||||
"8080/tcp" = { };
|
"8080/tcp" = { };
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
nix run .#ls-ap-migration
|
nix run .#ls-ap-migration
|
||||||
nix run .#lysand-ap-layer
|
nix run .#versia-ap-layer
|
||||||
|
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
post, prelude, user,
|
post, prelude, user,
|
||||||
},
|
},
|
||||||
error,
|
error,
|
||||||
lysand::funcs::send_follow_accept_to_lysand,
|
versia::funcs::send_follow_accept_to_versia,
|
||||||
utils::{generate_follow_accept_id, generate_random_object_id},
|
utils::{generate_follow_accept_id, generate_random_object_id},
|
||||||
DB,
|
DB,
|
||||||
};
|
};
|
||||||
|
|
@ -116,7 +116,7 @@ impl ActivityHandler for Follow {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn receive(self, data: &Data<Self::DataType>) -> Result<(), Self::Error> {
|
async fn receive(self, data: &Data<Self::DataType>) -> Result<(), Self::Error> {
|
||||||
//accept_follow(self, data).await?; TODO replace w/ lysand forward
|
//accept_follow(self, data).await?; TODO replace w/ versia forward
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -184,20 +184,20 @@ async fn save_accept_follow(
|
||||||
if query.is_none() {
|
if query.is_none() {
|
||||||
return Err(crate::error::Error(anyhow::anyhow!("oopsie woopise")));
|
return Err(crate::error::Error(anyhow::anyhow!("oopsie woopise")));
|
||||||
}
|
}
|
||||||
let lysand_accept_id = uuid::Uuid::now_v7().to_string();
|
let versia_accept_id = uuid::Uuid::now_v7().to_string();
|
||||||
// all values in the ActiveModel that are set, except the id, will be updated
|
// all values in the ActiveModel that are set, except the id, will be updated
|
||||||
let active_query = follow_relation::ActiveModel {
|
let active_query = follow_relation::ActiveModel {
|
||||||
id: Set(query.unwrap().id),
|
id: Set(query.unwrap().id),
|
||||||
ap_accept_id: Set(Some(accept_activity.id.to_string())),
|
ap_accept_id: Set(Some(accept_activity.id.to_string())),
|
||||||
ap_accept_json: Set(Some(serde_json::to_string(&accept_activity).unwrap())),
|
ap_accept_json: Set(Some(serde_json::to_string(&accept_activity).unwrap())),
|
||||||
accept_id: Set(Some(lysand_accept_id)),
|
accept_id: Set(Some(versia_accept_id)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
// modify db entry
|
// modify db entry
|
||||||
let res = prelude::FollowRelation::update(active_query);
|
let res = prelude::FollowRelation::update(active_query);
|
||||||
let model = res.exec(db).await?;
|
let model = res.exec(db).await?;
|
||||||
|
|
||||||
let _ = send_follow_accept_to_lysand(model.clone()).await?;
|
let _ = send_follow_accept_to_versia(model.clone()).await?;
|
||||||
|
|
||||||
Ok(model)
|
Ok(model)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
src/http.rs
10
src/http.rs
|
|
@ -2,9 +2,9 @@ use crate::{
|
||||||
database::StateHandle,
|
database::StateHandle,
|
||||||
entities::user,
|
entities::user,
|
||||||
error::Error,
|
error::Error,
|
||||||
lysand::{
|
versia::{
|
||||||
self,
|
self,
|
||||||
conversion::{db_user_from_url, local_db_user_from_name, receive_lysand_note},
|
conversion::{db_user_from_url, local_db_user_from_name, receive_versia_note},
|
||||||
},
|
},
|
||||||
objects::person::{DbUser, PersonAcceptedActivities},
|
objects::person::{DbUser, PersonAcceptedActivities},
|
||||||
utils::generate_user_id,
|
utils::generate_user_id,
|
||||||
|
|
@ -45,12 +45,12 @@ pub fn listen(config: &FederationConfig<StateHandle>) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lysand_inbox(
|
pub fn versia_inbox(
|
||||||
note: web::Json<lysand::objects::Note>,
|
note: web::Json<versia::objects::Note>,
|
||||||
id: web::Path<String>,
|
id: web::Path<String>,
|
||||||
data: Data<StateHandle>,
|
data: Data<StateHandle>,
|
||||||
) -> Result<HttpResponse, Error> {
|
) -> Result<HttpResponse, Error> {
|
||||||
tokio::spawn(receive_lysand_note(note.into_inner(), id.into_inner()));
|
tokio::spawn(receive_versia_note(note.into_inner(), id.into_inner()));
|
||||||
Ok(HttpResponse::Created().finish())
|
Ok(HttpResponse::Created().finish())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
12
src/main.rs
12
src/main.rs
|
|
@ -15,8 +15,8 @@ use clap::Parser;
|
||||||
use database::Database;
|
use database::Database;
|
||||||
use entities::post;
|
use entities::post;
|
||||||
use http::{http_get_user, http_post_user_inbox, webfinger};
|
use http::{http_get_user, http_post_user_inbox, webfinger};
|
||||||
use lysand::http::{
|
use versia::http::{
|
||||||
create_activity, fetch_lysand_post, fetch_post, fetch_user, lysand_inbox, query_post,
|
create_activity, fetch_versia_post, fetch_post, fetch_user, versia_inbox, query_post,
|
||||||
};
|
};
|
||||||
use objects::person::{DbUser, Person};
|
use objects::person::{DbUser, Person};
|
||||||
use sea_orm::{ActiveModelTrait, DatabaseConnection, Set};
|
use sea_orm::{ActiveModelTrait, DatabaseConnection, Set};
|
||||||
|
|
@ -47,7 +47,7 @@ mod database;
|
||||||
mod entities;
|
mod entities;
|
||||||
mod error;
|
mod error;
|
||||||
mod http;
|
mod http;
|
||||||
mod lysand;
|
mod versia;
|
||||||
mod objects;
|
mod objects;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ async fn follow_manually(
|
||||||
Ok(HttpResponse::Ok().json(Response { health: true }))
|
Ok(HttpResponse::Ok().json(Response { health: true }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const DOMAIN_DEF: &str = "social.lysand.org";
|
const DOMAIN_DEF: &str = "versia.social";
|
||||||
const LOCAL_USER_NAME: &str = "apservice";
|
const LOCAL_USER_NAME: &str = "apservice";
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|
@ -288,7 +288,7 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
|
||||||
.wrap(prometheus.clone())
|
.wrap(prometheus.clone())
|
||||||
.wrap(FederationMiddleware::new(data.clone()))
|
.wrap(FederationMiddleware::new(data.clone()))
|
||||||
.service(post_manually)
|
.service(post_manually)
|
||||||
.service(lysand_inbox)
|
.service(versia_inbox)
|
||||||
.service(follow_manually)
|
.service(follow_manually)
|
||||||
.route("/{user}", web::get().to(http_get_user))
|
.route("/{user}", web::get().to(http_get_user))
|
||||||
.route("/{user}/inbox", web::post().to(http_post_user_inbox))
|
.route("/{user}/inbox", web::post().to(http_post_user_inbox))
|
||||||
|
|
@ -302,7 +302,7 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
|
||||||
.service(fetch_user)
|
.service(fetch_user)
|
||||||
.service(create_activity)
|
.service(create_activity)
|
||||||
.service(query_post)
|
.service(query_post)
|
||||||
.service(fetch_lysand_post)
|
.service(fetch_versia_post)
|
||||||
})
|
})
|
||||||
.bind(SERVER_URL.to_string())?
|
.bind(SERVER_URL.to_string())?
|
||||||
.workers(num_cpus::get())
|
.workers(num_cpus::get())
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
database::StateHandle,
|
database::StateHandle,
|
||||||
entities::{post, user},
|
entities::{post, user},
|
||||||
error::Error,
|
error::Error,
|
||||||
lysand::conversion::db_user_from_url,
|
versia::conversion::db_user_from_url,
|
||||||
objects::person::DbUser,
|
objects::person::DbUser,
|
||||||
utils::generate_object_id,
|
utils::generate_object_id,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ pub fn generate_follow_req_id(domain: &str, db_id: &str) -> Result<Url, ParseErr
|
||||||
Url::parse(&format!("https://{}/apbridge/followreq/{}", domain, db_id))
|
Url::parse(&format!("https://{}/apbridge/followreq/{}", domain, db_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_lysand_post_url(domain: &str, db_id: &str) -> Result<Url, ParseError> {
|
pub fn generate_versia_post_url(domain: &str, db_id: &str) -> Result<Url, ParseError> {
|
||||||
Url::parse(&format!(
|
Url::parse(&format!(
|
||||||
"https://{}/apbridge/lysand/object/{}",
|
"https://{}/apbridge/versia/object/{}",
|
||||||
domain, db_id
|
domain, db_id
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
person::{AttachmentType, EndpointType, IconType, Person, TagType},
|
person::{AttachmentType, EndpointType, IconType, Person, TagType},
|
||||||
post::Mention,
|
post::Mention,
|
||||||
},
|
},
|
||||||
utils::{generate_lysand_post_url, generate_object_id, generate_user_id},
|
utils::{generate_versia_post_url, generate_object_id, generate_user_id},
|
||||||
API_DOMAIN, DB, FEDERATION_CONFIG, LOCAL_USER_NAME, LYSAND_DOMAIN, USERNAME,
|
API_DOMAIN, DB, FEDERATION_CONFIG, LOCAL_USER_NAME, LYSAND_DOMAIN, USERNAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -32,12 +32,12 @@ pub async fn fetch_user_from_url(url: Url) -> anyhow::Result<super::objects::Use
|
||||||
Ok(request.json::<super::objects::User>().await?)
|
Ok(request.json::<super::objects::User>().await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn lysand_post_from_db(
|
pub async fn versia_post_from_db(
|
||||||
post: entities::post::Model,
|
post: entities::post::Model,
|
||||||
) -> anyhow::Result<super::objects::Note> {
|
) -> anyhow::Result<super::objects::Note> {
|
||||||
let data = FEDERATION_CONFIG.get().unwrap();
|
let data = FEDERATION_CONFIG.get().unwrap();
|
||||||
let domain = data.domain();
|
let domain = data.domain();
|
||||||
let url = generate_lysand_post_url(domain, &post.id)?;
|
let url = generate_versia_post_url(domain, &post.id)?;
|
||||||
let creator = prelude::User::find()
|
let creator = prelude::User::find()
|
||||||
.filter(entities::user::Column::Id.eq(post.creator.clone()))
|
.filter(entities::user::Column::Id.eq(post.creator.clone()))
|
||||||
.one(DB.get().unwrap())
|
.one(DB.get().unwrap())
|
||||||
|
|
@ -60,7 +60,7 @@ pub async fn lysand_post_from_db(
|
||||||
ContentEntry::from_string(post.content),
|
ContentEntry::from_string(post.content),
|
||||||
);
|
);
|
||||||
let note = super::objects::Note {
|
let note = super::objects::Note {
|
||||||
rtype: super::objects::LysandType::Note,
|
rtype: super::objects::VersiaType::Note,
|
||||||
id: uuid::Uuid::parse_str(&post.id)?,
|
id: uuid::Uuid::parse_str(&post.id)?,
|
||||||
author: author.clone(),
|
author: author.clone(),
|
||||||
uri: url.clone(),
|
uri: url.clone(),
|
||||||
|
|
@ -81,30 +81,30 @@ pub async fn lysand_post_from_db(
|
||||||
Ok(note)
|
Ok(note)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn lysand_user_from_db(
|
pub async fn versia_user_from_db(
|
||||||
user: entities::user::Model,
|
user: entities::user::Model,
|
||||||
) -> anyhow::Result<super::objects::User> {
|
) -> anyhow::Result<super::objects::User> {
|
||||||
let url = Url::parse(&user.url)?;
|
let url = Url::parse(&user.url)?;
|
||||||
let ap = user.ap_json.unwrap();
|
let ap = user.ap_json.unwrap();
|
||||||
let serialized_ap: crate::objects::person::Person = serde_json::from_str(&ap)?;
|
let serialized_ap: crate::objects::person::Person = serde_json::from_str(&ap)?;
|
||||||
let inbox_url = Url::parse("https://ap.lysand.org/apbridge/lysand/inbox")?;
|
let inbox_url = Url::parse("https://ap.versia.social/apbridge/versia/inbox")?;
|
||||||
let outbox_url = Url::parse(
|
let outbox_url = Url::parse(
|
||||||
("https://ap.lysand.org/apbridge/lysand/outbox/".to_string() + &user.id).as_str(),
|
("https://ap.versia.social/apbridge/versia/outbox/".to_string() + &user.id).as_str(),
|
||||||
)?;
|
)?;
|
||||||
let followers_url = Url::parse(
|
let followers_url = Url::parse(
|
||||||
("https://ap.lysand.org/apbridge/lysand/followers/".to_string() + &user.id).as_str(),
|
("https://ap.versia.social/apbridge/versia/followers/".to_string() + &user.id).as_str(),
|
||||||
)?;
|
)?;
|
||||||
let following_url = Url::parse(
|
let following_url = Url::parse(
|
||||||
("https://ap.lysand.org/apbridge/lysand/following/".to_string() + &user.id).as_str(),
|
("https://ap.versia.social/apbridge/versia/following/".to_string() + &user.id).as_str(),
|
||||||
)?;
|
)?;
|
||||||
let featured_url = Url::parse(
|
let featured_url = Url::parse(
|
||||||
("https://ap.lysand.org/apbridge/lysand/featured/".to_string() + &user.id).as_str(),
|
("https://ap.versia.social/apbridge/versia/featured/".to_string() + &user.id).as_str(),
|
||||||
)?;
|
)?;
|
||||||
let likes_url = Url::parse(
|
let likes_url = Url::parse(
|
||||||
("https://ap.lysand.org/apbridge/lysand/likes/".to_string() + &user.id).as_str(),
|
("https://ap.versia.social/apbridge/versia/likes/".to_string() + &user.id).as_str(),
|
||||||
)?;
|
)?;
|
||||||
let dislikes_url = Url::parse(
|
let dislikes_url = Url::parse(
|
||||||
("https://ap.lysand.org/apbridge/lysand/dislikes/".to_string() + &user.id).as_str(),
|
("https://ap.versia.social/apbridge/versia/dislikes/".to_string() + &user.id).as_str(),
|
||||||
)?;
|
)?;
|
||||||
let og_displayname_ref = user.name.clone();
|
let og_displayname_ref = user.name.clone();
|
||||||
let og_username_ref = user.username.clone();
|
let og_username_ref = user.username.clone();
|
||||||
|
|
@ -206,7 +206,7 @@ pub async fn lysand_user_from_db(
|
||||||
custom_emojis: emojis,
|
custom_emojis: emojis,
|
||||||
};
|
};
|
||||||
let user = super::objects::User {
|
let user = super::objects::User {
|
||||||
rtype: super::objects::LysandType::User,
|
rtype: super::objects::VersiaType::User,
|
||||||
id: uuid::Uuid::parse_str(&user.id)?,
|
id: uuid::Uuid::parse_str(&user.id)?,
|
||||||
uri: url.clone(),
|
uri: url.clone(),
|
||||||
username: user.username,
|
username: user.username,
|
||||||
|
|
@ -244,7 +244,7 @@ pub async fn option_content_format_text(opt: Option<ContentFormat>) -> Option<St
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
pub async fn db_post_from_url(url: Url) -> anyhow::Result<entities::post::Model> {
|
pub async fn db_post_from_url(url: Url) -> anyhow::Result<entities::post::Model> {
|
||||||
if !url.domain().eq(&Some(LYSAND_DOMAIN.as_str())) {
|
if !url.domain().eq(&Some(LYSAND_DOMAIN.as_str())) {
|
||||||
return Err(anyhow!("not lysands domain"));
|
return Err(anyhow!("not versias domain"));
|
||||||
}
|
}
|
||||||
let str_url = url.to_string();
|
let str_url = url.to_string();
|
||||||
let post_res: Option<post::Model> = prelude::Post::find()
|
let post_res: Option<post::Model> = prelude::Post::find()
|
||||||
|
|
@ -256,7 +256,7 @@ pub async fn db_post_from_url(url: Url) -> anyhow::Result<entities::post::Model>
|
||||||
Ok(post)
|
Ok(post)
|
||||||
} else {
|
} else {
|
||||||
let post = fetch_note_from_url(url.clone()).await?;
|
let post = fetch_note_from_url(url.clone()).await?;
|
||||||
let res = receive_lysand_note(post, "https://ap.lysand.org/example".to_string()).await?; // TODO: Replace user id with actual user id
|
let res = receive_versia_note(post, "https://ap.versia.social/example".to_string()).await?; // TODO: Replace user id with actual user id
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -292,7 +292,7 @@ pub async fn db_user_from_url(url: Url) -> anyhow::Result<entities::user::Model>
|
||||||
if !url.domain().eq(&Some(LYSAND_DOMAIN.as_str()))
|
if !url.domain().eq(&Some(LYSAND_DOMAIN.as_str()))
|
||||||
&& !url.domain().eq(&Some(API_DOMAIN.as_str()))
|
&& !url.domain().eq(&Some(API_DOMAIN.as_str()))
|
||||||
{
|
{
|
||||||
return Err(anyhow!("not lysands domain"));
|
return Err(anyhow!("not versias domain"));
|
||||||
}
|
}
|
||||||
let user_res: Option<user::Model> = prelude::User::find()
|
let user_res: Option<user::Model> = prelude::User::find()
|
||||||
.filter(entities::user::Column::Url.eq(url.to_string()))
|
.filter(entities::user::Column::Url.eq(url.to_string()))
|
||||||
|
|
@ -434,11 +434,11 @@ pub async fn fetch_note_from_url(url: Url) -> anyhow::Result<super::objects::Not
|
||||||
Ok(request.json::<super::objects::Note>().await?)
|
Ok(request.json::<super::objects::Note>().await?)
|
||||||
}
|
}
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
pub async fn receive_lysand_note(
|
pub async fn receive_versia_note(
|
||||||
note: Note,
|
note: Note,
|
||||||
db_id: String,
|
db_id: String,
|
||||||
) -> anyhow::Result<entities::post::Model> {
|
) -> anyhow::Result<entities::post::Model> {
|
||||||
let lysand_author: entities::user::Model = db_user_from_url(note.author.clone()).await?;
|
let versia_author: entities::user::Model = db_user_from_url(note.author.clone()).await?;
|
||||||
let user_res = prelude::User::find_by_id(db_id)
|
let user_res = prelude::User::find_by_id(db_id)
|
||||||
.one(DB.get().unwrap())
|
.one(DB.get().unwrap())
|
||||||
.await;
|
.await;
|
||||||
|
|
@ -559,7 +559,7 @@ pub async fn receive_lysand_note(
|
||||||
}
|
}
|
||||||
let post = entities::post::ActiveModel {
|
let post = entities::post::ActiveModel {
|
||||||
id: Set(note.id.to_string()),
|
id: Set(note.id.to_string()),
|
||||||
creator: Set(lysand_author.id.clone()),
|
creator: Set(versia_author.id.clone()),
|
||||||
content: Set(ap_note.content.clone()),
|
content: Set(ap_note.content.clone()),
|
||||||
sensitive: Set(ap_note.sensitive.unwrap_or_default()),
|
sensitive: Set(ap_note.sensitive.unwrap_or_default()),
|
||||||
created_at: Set(Utc
|
created_at: Set(Utc
|
||||||
|
|
@ -9,12 +9,12 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
conversion::{fetch_user_from_url, lysand_user_from_db},
|
conversion::{fetch_user_from_url, versia_user_from_db},
|
||||||
objects::FollowResult,
|
objects::FollowResult,
|
||||||
superx::request_client,
|
superx::request_client,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn send_follow_accept_to_lysand(model: follow_relation::Model) -> anyhow::Result<()> {
|
pub async fn send_follow_accept_to_versia(model: follow_relation::Model) -> anyhow::Result<()> {
|
||||||
let request_client = request_client();
|
let request_client = request_client();
|
||||||
let db = DB.get().unwrap();
|
let db = DB.get().unwrap();
|
||||||
|
|
||||||
|
|
@ -27,26 +27,26 @@ pub async fn send_follow_accept_to_lysand(model: follow_relation::Model) -> anyh
|
||||||
.one(db)
|
.one(db)
|
||||||
.await?
|
.await?
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let lysand_follower = fetch_user_from_url(Url::parse(&follower_model.url)?).await?;
|
let versia_follower = fetch_user_from_url(Url::parse(&follower_model.url)?).await?;
|
||||||
|
|
||||||
let followee_model = prelude::User::find()
|
let followee_model = prelude::User::find()
|
||||||
.filter(user::Column::Id.eq(model.followee_id))
|
.filter(user::Column::Id.eq(model.followee_id))
|
||||||
.one(db)
|
.one(db)
|
||||||
.await?
|
.await?
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let lysand_followee = lysand_user_from_db(followee_model).await?;
|
let versia_followee = versia_user_from_db(followee_model).await?;
|
||||||
|
|
||||||
let entity = FollowResult {
|
let entity = FollowResult {
|
||||||
rtype: super::objects::LysandType::FollowAccept,
|
rtype: super::objects::VersiaType::FollowAccept,
|
||||||
id,
|
id,
|
||||||
uri,
|
uri,
|
||||||
created_at: OffsetDateTime::now_utc(),
|
created_at: OffsetDateTime::now_utc(),
|
||||||
author: lysand_followee.uri,
|
author: versia_followee.uri,
|
||||||
follower: lysand_follower.uri,
|
follower: versia_follower.uri,
|
||||||
};
|
};
|
||||||
|
|
||||||
let request = request_client
|
let request = request_client
|
||||||
.post(lysand_follower.inbox.as_str())
|
.post(versia_follower.inbox.as_str())
|
||||||
.header("Content-Type", "application/json; charset=utf-8")
|
.header("Content-Type", "application/json; charset=utf-8")
|
||||||
.header("Accept", "application/json")
|
.header("Accept", "application/json")
|
||||||
.header("Date", entity.created_at.clone().to_string())
|
.header("Date", entity.created_at.clone().to_string())
|
||||||
|
|
@ -57,6 +57,6 @@ pub async fn send_follow_accept_to_lysand(model: follow_relation::Model) -> anyh
|
||||||
if response.status().is_success() {
|
if response.status().is_success() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(anyhow::anyhow!("Failed to send follow accept to Lysand"))
|
Err(anyhow::anyhow!("Failed to send follow accept to Versia"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,8 +16,8 @@ use crate::{
|
||||||
prelude, user,
|
prelude, user,
|
||||||
},
|
},
|
||||||
error,
|
error,
|
||||||
lysand::{
|
versia::{
|
||||||
conversion::{lysand_post_from_db, lysand_user_from_db},
|
conversion::{versia_post_from_db, versia_user_from_db},
|
||||||
inbox::inbox_entry,
|
inbox::inbox_entry,
|
||||||
},
|
},
|
||||||
objects::{self, person::Person},
|
objects::{self, person::Person},
|
||||||
|
|
@ -28,7 +28,7 @@ use crate::{
|
||||||
use super::conversion::db_user_from_url;
|
use super::conversion::db_user_from_url;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
struct LysandQuery {
|
struct VersiaQuery {
|
||||||
// Post url
|
// Post url
|
||||||
url: Option<Url>,
|
url: Option<Url>,
|
||||||
// User handle
|
// User handle
|
||||||
|
|
@ -37,9 +37,9 @@ struct LysandQuery {
|
||||||
user_url: Option<Url>,
|
user_url: Option<Url>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/apbridge/lysand/query")]
|
#[get("/apbridge/versia/query")]
|
||||||
async fn query_post(
|
async fn query_post(
|
||||||
query: web::Query<LysandQuery>,
|
query: web::Query<VersiaQuery>,
|
||||||
state: web::Data<State>,
|
state: web::Data<State>,
|
||||||
) -> actix_web::Result<HttpResponse, error::Error> {
|
) -> actix_web::Result<HttpResponse, error::Error> {
|
||||||
if query.url.is_none() && query.user.is_none() && query.user_url.is_none() {
|
if query.url.is_none() && query.user.is_none() && query.user_url.is_none() {
|
||||||
|
|
@ -56,19 +56,19 @@ async fn query_post(
|
||||||
webfinger_resolve_actor::<State, user::Model>(user.as_str(), &data.to_request_data())
|
webfinger_resolve_actor::<State, user::Model>(user.as_str(), &data.to_request_data())
|
||||||
.await?;
|
.await?;
|
||||||
println!("!!!!!!! DB USER GOT");
|
println!("!!!!!!! DB USER GOT");
|
||||||
let lysand_user = lysand_user_from_db(target).await?;
|
let versia_user = versia_user_from_db(target).await?;
|
||||||
|
|
||||||
return Ok(HttpResponse::Ok()
|
return Ok(HttpResponse::Ok()
|
||||||
.content_type("application/json")
|
.content_type("application/json")
|
||||||
.json(lysand_user));
|
.json(versia_user));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(user) = query.user_url.clone() {
|
if let Some(user) = query.user_url.clone() {
|
||||||
let lysand_user = lysand_url_to_user(user).await?;
|
let versia_user = versia_url_to_user(user).await?;
|
||||||
|
|
||||||
return Ok(HttpResponse::Ok()
|
return Ok(HttpResponse::Ok()
|
||||||
.content_type("application/json")
|
.content_type("application/json")
|
||||||
.json(lysand_user));
|
.json(versia_user));
|
||||||
}
|
}
|
||||||
|
|
||||||
let opt_model = prelude::Post::find()
|
let opt_model = prelude::Post::find()
|
||||||
|
|
@ -86,11 +86,11 @@ async fn query_post(
|
||||||
|
|
||||||
Ok(HttpResponse::Ok()
|
Ok(HttpResponse::Ok()
|
||||||
.content_type("application/json")
|
.content_type("application/json")
|
||||||
.json(lysand_post_from_db(target).await?))
|
.json(versia_post_from_db(target).await?))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/apbridge/lysand/inbox")]
|
#[post("/apbridge/versia/inbox")]
|
||||||
async fn lysand_inbox(
|
async fn versia_inbox(
|
||||||
body: web::Bytes,
|
body: web::Bytes,
|
||||||
state: web::Data<State>,
|
state: web::Data<State>,
|
||||||
) -> actix_web::Result<HttpResponse, error::Error> {
|
) -> actix_web::Result<HttpResponse, error::Error> {
|
||||||
|
|
@ -145,8 +145,8 @@ async fn fetch_user(
|
||||||
.json(WithContext::new_default(deserialized_user)))
|
.json(WithContext::new_default(deserialized_user)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/apbridge/lysand/object/{post}")]
|
#[get("/apbridge/versia/object/{post}")]
|
||||||
async fn fetch_lysand_post(
|
async fn fetch_versia_post(
|
||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
state: web::Data<State>,
|
state: web::Data<State>,
|
||||||
) -> actix_web::Result<HttpResponse, error::Error> {
|
) -> actix_web::Result<HttpResponse, error::Error> {
|
||||||
|
|
@ -164,7 +164,7 @@ async fn fetch_lysand_post(
|
||||||
|
|
||||||
Ok(HttpResponse::Ok()
|
Ok(HttpResponse::Ok()
|
||||||
.content_type("application/json")
|
.content_type("application/json")
|
||||||
.json(lysand_post_from_db(post).await?))
|
.json(versia_post_from_db(post).await?))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/apbridge/create/{id}/{base64url}")]
|
#[get("/apbridge/create/{id}/{base64url}")]
|
||||||
|
|
@ -204,7 +204,7 @@ async fn create_activity(
|
||||||
.json(create_with_context))
|
.json(create_with_context))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn lysand_url_to_user(url: Url) -> anyhow::Result<super::objects::User> {
|
pub async fn versia_url_to_user(url: Url) -> anyhow::Result<super::objects::User> {
|
||||||
let db = DB.get().unwrap();
|
let db = DB.get().unwrap();
|
||||||
let data = FEDERATION_CONFIG.get().unwrap();
|
let data = FEDERATION_CONFIG.get().unwrap();
|
||||||
|
|
||||||
|
|
@ -222,10 +222,10 @@ pub async fn lysand_url_to_user(url: Url) -> anyhow::Result<super::objects::User
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(lysand_user_from_db(target).await?)
|
Ok(versia_user_from_db(target).await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn lysand_url_to_user_and_model(
|
pub async fn versia_url_to_user_and_model(
|
||||||
url: Url,
|
url: Url,
|
||||||
) -> anyhow::Result<(super::objects::User, user::Model)> {
|
) -> anyhow::Result<(super::objects::User, user::Model)> {
|
||||||
let db = DB.get().unwrap();
|
let db = DB.get().unwrap();
|
||||||
|
|
@ -245,10 +245,10 @@ pub async fn lysand_url_to_user_and_model(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((lysand_user_from_db(target.clone()).await?, target))
|
Ok((versia_user_from_db(target.clone()).await?, target))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn main_lysand_url_to_user_and_model(
|
pub async fn main_versia_url_to_user_and_model(
|
||||||
url: Url,
|
url: Url,
|
||||||
) -> anyhow::Result<(super::objects::User, user::Model)> {
|
) -> anyhow::Result<(super::objects::User, user::Model)> {
|
||||||
let db = DB.get().unwrap();
|
let db = DB.get().unwrap();
|
||||||
|
|
@ -265,5 +265,5 @@ pub async fn main_lysand_url_to_user_and_model(
|
||||||
target = db_user_from_url(url.clone()).await?;
|
target = db_user_from_url(url.clone()).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((lysand_user_from_db(target.clone()).await?, target))
|
Ok((versia_user_from_db(target.clone()).await?, target))
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
prelude::{self, FollowRelation},
|
prelude::{self, FollowRelation},
|
||||||
user,
|
user,
|
||||||
},
|
},
|
||||||
lysand::http::main_lysand_url_to_user_and_model,
|
versia::http::main_versia_url_to_user_and_model,
|
||||||
utils::generate_follow_req_id,
|
utils::generate_follow_req_id,
|
||||||
API_DOMAIN, DB, FEDERATION_CONFIG,
|
API_DOMAIN, DB, FEDERATION_CONFIG,
|
||||||
};
|
};
|
||||||
|
|
@ -19,9 +19,9 @@ use serde::Deserialize;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
conversion::lysand_user_from_db,
|
conversion::versia_user_from_db,
|
||||||
http::{lysand_url_to_user, lysand_url_to_user_and_model},
|
http::{versia_url_to_user, versia_url_to_user_and_model},
|
||||||
objects::LysandType,
|
objects::VersiaType,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn inbox_entry(json: &str) -> Result<()> {
|
pub async fn inbox_entry(json: &str) -> Result<()> {
|
||||||
|
|
@ -30,7 +30,7 @@ pub async fn inbox_entry(json: &str) -> Result<()> {
|
||||||
|
|
||||||
// Extract the "type" field from the JSON
|
// Extract the "type" field from the JSON
|
||||||
if let Some(json_type) = value.get("type") {
|
if let Some(json_type) = value.get("type") {
|
||||||
// Match the "type" field with the corresponding LysandType
|
// Match the "type" field with the corresponding VersiaType
|
||||||
match json_type.as_str() {
|
match json_type.as_str() {
|
||||||
Some("Note") => {
|
Some("Note") => {
|
||||||
let note: super::objects::Note = serde_json::from_str(json)?;
|
let note: super::objects::Note = serde_json::from_str(json)?;
|
||||||
|
|
@ -76,9 +76,9 @@ async fn follow_request(follow: super::objects::Follow) -> Result<()> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let data = FEDERATION_CONFIG.get().unwrap();
|
let data = FEDERATION_CONFIG.get().unwrap();
|
||||||
let author = main_lysand_url_to_user_and_model(follow.author.into()).await?;
|
let author = main_versia_url_to_user_and_model(follow.author.into()).await?;
|
||||||
println!("Followee URL: {}", &follow.followee.to_string());
|
println!("Followee URL: {}", &follow.followee.to_string());
|
||||||
let followee = lysand_url_to_user_and_model(follow.followee.into()).await?;
|
let followee = versia_url_to_user_and_model(follow.followee.into()).await?;
|
||||||
let serial_ap_author = serde_json::from_str::<crate::objects::person::Person>(
|
let serial_ap_author = serde_json::from_str::<crate::objects::person::Person>(
|
||||||
&(author.1.ap_json.clone()).unwrap(),
|
&(author.1.ap_json.clone()).unwrap(),
|
||||||
)?;
|
)?;
|
||||||
|
|
@ -22,7 +22,7 @@ const FORMAT: Iso8601<6651332276412969266533270467398074368> = Iso8601::<
|
||||||
.encode()
|
.encode()
|
||||||
},
|
},
|
||||||
>;
|
>;
|
||||||
time::serde::format_description!(iso_lysand, OffsetDateTime, FORMAT);
|
time::serde::format_description!(iso_versia, OffsetDateTime, FORMAT);
|
||||||
|
|
||||||
fn sort_alphabetically<T: Serialize, S: serde::Serializer>(
|
fn sort_alphabetically<T: Serialize, S: serde::Serializer>(
|
||||||
value: &T,
|
value: &T,
|
||||||
|
|
@ -36,7 +36,7 @@ fn sort_alphabetically<T: Serialize, S: serde::Serializer>(
|
||||||
pub struct SortAlphabetically<T: Serialize>(#[serde(serialize_with = "sort_alphabetically")] pub T);
|
pub struct SortAlphabetically<T: Serialize>(#[serde(serialize_with = "sort_alphabetically")] pub T);
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub enum LysandType {
|
pub enum VersiaType {
|
||||||
User,
|
User,
|
||||||
Note,
|
Note,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -71,26 +71,26 @@ pub enum VisibilityType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub enum LysandExtensions {
|
pub enum VersiaExtensions {
|
||||||
#[serde(rename = "org.lysand:microblogging/Announce")]
|
#[serde(rename = "org.versia:microblogging/Announce")]
|
||||||
Announce,
|
Announce,
|
||||||
#[serde(rename = "org.lysand:custom_emojis")]
|
#[serde(rename = "org.versia:custom_emojis")]
|
||||||
CustomEmojis,
|
CustomEmojis,
|
||||||
#[serde(rename = "org.lysand:reactions/Reaction")]
|
#[serde(rename = "org.versia:reactions/Reaction")]
|
||||||
Reaction,
|
Reaction,
|
||||||
#[serde(rename = "org.lysand:reactions")]
|
#[serde(rename = "org.versia:reactions")]
|
||||||
Reactions,
|
Reactions,
|
||||||
#[serde(rename = "org.lysand:polls")]
|
#[serde(rename = "org.versia:polls")]
|
||||||
Polls,
|
Polls,
|
||||||
#[serde(rename = "org.lysand:is_cat")]
|
#[serde(rename = "org.versia:is_cat")]
|
||||||
IsCat,
|
IsCat,
|
||||||
#[serde(rename = "org.lysand:server_endorsement/Endorsement")]
|
#[serde(rename = "org.versia:server_endorsement/Endorsement")]
|
||||||
Endorsement,
|
Endorsement,
|
||||||
#[serde(rename = "org.lysand:server_endorsement")]
|
#[serde(rename = "org.versia:server_endorsement")]
|
||||||
EndorsementCollection,
|
EndorsementCollection,
|
||||||
#[serde(rename = "org.lysand:reports/Report")]
|
#[serde(rename = "org.versia:reports/Report")]
|
||||||
Report,
|
Report,
|
||||||
#[serde(rename = "org.lysand:vanity")]
|
#[serde(rename = "org.versia:vanity")]
|
||||||
Vanity,
|
Vanity,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,10 +254,10 @@ impl ContentEntry {
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub public_key: PublicKey,
|
pub public_key: PublicKey,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub rtype: LysandType,
|
pub rtype: VersiaType,
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub uri: Url,
|
pub uri: Url,
|
||||||
#[serde(with = "iso_lysand")]
|
#[serde(with = "iso_versia")]
|
||||||
pub created_at: OffsetDateTime,
|
pub created_at: OffsetDateTime,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub display_name: Option<String>,
|
pub display_name: Option<String>,
|
||||||
|
|
@ -284,7 +284,7 @@ pub struct User {
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct ExtensionSpecs {
|
pub struct ExtensionSpecs {
|
||||||
#[serde(rename = "org.lysand:custom_emojis")]
|
#[serde(rename = "org.versia:custom_emojis")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub custom_emojis: Option<CustomEmojis>,
|
pub custom_emojis: Option<CustomEmojis>,
|
||||||
}
|
}
|
||||||
|
|
@ -321,11 +321,11 @@ pub struct LinkPreview {
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct Note {
|
pub struct Note {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub rtype: LysandType,
|
pub rtype: VersiaType,
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub uri: Url,
|
pub uri: Url,
|
||||||
pub author: Url,
|
pub author: Url,
|
||||||
#[serde(with = "iso_lysand")]
|
#[serde(with = "iso_versia")]
|
||||||
pub created_at: OffsetDateTime,
|
pub created_at: OffsetDateTime,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub category: Option<CategoryType>,
|
pub category: Option<CategoryType>,
|
||||||
|
|
@ -357,13 +357,13 @@ pub struct Note {
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct Patch {
|
pub struct Patch {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub rtype: LysandType,
|
pub rtype: VersiaType,
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub uri: Url,
|
pub uri: Url,
|
||||||
pub author: Url,
|
pub author: Url,
|
||||||
#[serde(with = "iso_lysand")]
|
#[serde(with = "iso_versia")]
|
||||||
pub created_at: OffsetDateTime,
|
pub created_at: OffsetDateTime,
|
||||||
#[serde(with = "iso_lysand")]
|
#[serde(with = "iso_versia")]
|
||||||
pub patched_at: OffsetDateTime,
|
pub patched_at: OffsetDateTime,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub category: Option<CategoryType>,
|
pub category: Option<CategoryType>,
|
||||||
|
|
@ -406,11 +406,11 @@ pub struct Outbox {
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct Follow {
|
pub struct Follow {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub rtype: LysandType,
|
pub rtype: VersiaType,
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub uri: Url,
|
pub uri: Url,
|
||||||
pub author: Url,
|
pub author: Url,
|
||||||
#[serde(with = "iso_lysand")]
|
#[serde(with = "iso_versia")]
|
||||||
pub created_at: OffsetDateTime,
|
pub created_at: OffsetDateTime,
|
||||||
pub followee: Url,
|
pub followee: Url,
|
||||||
}
|
}
|
||||||
|
|
@ -418,11 +418,11 @@ pub struct Follow {
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct FollowResult {
|
pub struct FollowResult {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub rtype: LysandType,
|
pub rtype: VersiaType,
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub uri: Url,
|
pub uri: Url,
|
||||||
pub author: Url,
|
pub author: Url,
|
||||||
#[serde(with = "iso_lysand")]
|
#[serde(with = "iso_versia")]
|
||||||
pub created_at: OffsetDateTime,
|
pub created_at: OffsetDateTime,
|
||||||
pub follower: Url,
|
pub follower: Url,
|
||||||
}
|
}
|
||||||
|
|
@ -10,15 +10,15 @@ pub async fn serialize_user(user: super::objects::User) -> anyhow::Result<String
|
||||||
Ok(data)
|
Ok(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn deserialize_lysand_type(data: String) -> anyhow::Result<super::objects::LysandType> {
|
pub async fn deserialize_versia_type(data: String) -> anyhow::Result<super::objects::VersiaType> {
|
||||||
let lysand_type: super::objects::LysandType = serde_json::from_str(&data)?;
|
let versia_type: super::objects::VersiaType = serde_json::from_str(&data)?;
|
||||||
Ok(lysand_type)
|
Ok(versia_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn serialize_lysand_type(
|
pub async fn serialize_versia_type(
|
||||||
lysand_type: super::objects::LysandType,
|
versia_type: super::objects::VersiaType,
|
||||||
) -> anyhow::Result<String> {
|
) -> anyhow::Result<String> {
|
||||||
let data = serde_json::to_string(&lysand_type)?;
|
let data = serde_json::to_string(&versia_type)?;
|
||||||
Ok(data)
|
Ok(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::lysand::objects::SortAlphabetically;
|
use crate::versia::objects::SortAlphabetically;
|
||||||
|
|
||||||
use super::superx::request_client;
|
use super::superx::request_client;
|
||||||
|
|
||||||
|
|
@ -6,7 +6,7 @@ use super::superx::request_client;
|
||||||
async fn test_user_serial() {
|
async fn test_user_serial() {
|
||||||
let client = request_client();
|
let client = request_client();
|
||||||
let response = client
|
let response = client
|
||||||
.get("https://social.lysand.org/users/018ec082-0ae1-761c-b2c5-22275a611771")
|
.get("https://versia.social/users/018ec082-0ae1-761c-b2c5-22275a611771")
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
@ -25,7 +25,7 @@ pub async fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
println!("Requesting user");
|
println!("Requesting user");
|
||||||
let response = client
|
let response = client
|
||||||
.get("https://social.lysand.org/users/018ec082-0ae1-761c-b2c5-22275a611771")
|
.get("https://versia.social/users/018ec082-0ae1-761c-b2c5-22275a611771")
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
println!("Response: {:?}", response);
|
println!("Response: {:?}", response);
|
||||||
|
|
@ -50,9 +50,9 @@ pub async fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
println!("\n\n\nas AP:");
|
println!("\n\n\nas AP:");
|
||||||
for item in outbox.items {
|
for item in outbox.items {
|
||||||
let ap_item = super::conversion::receive_lysand_note(
|
let ap_item = super::conversion::receive_versia_note(
|
||||||
item,
|
item,
|
||||||
"https://ap.lysand.org/example".to_string(),
|
"https://ap.versia.social/example".to_string(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
println!("{:#?}", ap_item);
|
println!("{:#?}", ap_item);
|
||||||
Loading…
Reference in a new issue