feat: rename to Versia

This commit is contained in:
April John 2024-08-28 15:24:22 +02:00
parent 29d8fc718a
commit 0b4574b2d1
21 changed files with 148 additions and 148 deletions

View file

@ -1,4 +1,4 @@
DATABASE_URL="sqlite:///home/aprl/Documents/lysand-ap-layer/db.sqlite?mode=rwc"
LYSAND_DOMAIN="social.lysand.org"
API_DOMAIN="ap.lysand.org"
DATABASE_URL="sqlite:///home/aprl/Documents/versia-ap-layer/db.sqlite?mode=rwc"
LYSAND_DOMAIN="versia.social"
API_DOMAIN="ap.versia.social"
RUST_LOG="debug"

2
Cargo.lock generated
View file

@ -1930,7 +1930,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "lysand-ap-layer"
name = "versia-ap-layer"
version = "0.1.0"
dependencies = [
"activitypub_federation",

View file

@ -1,11 +1,11 @@
[package]
name = "lysand-ap-layer"
name = "versia-ap-layer"
version = "0.1.0"
edition = "2021"
authors = ["April John <aprl@acab.dev>"]
license = "AGPL-3.0-or-later"
repository = "https://github.com/lysand-org/lysand-ap-layer"
description = "A compatibility layer between lysands official server and activitypub"
repository = "https://github.com/versia-pub/versia-ap-layer"
description = "A compatibility layer between versias official server and activitypub"
[dependencies]
tokio = { version = "1.20.0", features = ["rt", "macros"] }

View file

@ -1,22 +1,22 @@
## 2024-04-14, Version 0.1.0
### Commits
- [[`51a708a1c3`](https://github.com/lysand-org/lysand-ap-layer/commit/51a708a1c3d1aa974deb148156c07dfe7e775a8c)] feat! AGPL3 + Contributor Covenant (April John)
- [[`cc663ffc9b`](https://github.com/lysand-org/lysand-ap-layer/commit/cc663ffc9b56b4b1a93ceaa2e488fc554e597790)] arbeiter (aprilthepink)
- [[`1e6c005698`](https://github.com/lysand-org/lysand-ap-layer/commit/1e6c005698df8c781c60abfb1bab94d0b968c4d9)] enable ttp sign (aprilthepink)
- [[`0060d8baa8`](https://github.com/lysand-org/lysand-ap-layer/commit/0060d8baa8b356d61d0aabfcd6b6f5143a47e8fa)] boop (aprilthepink)
- [[`522ecabd07`](https://github.com/lysand-org/lysand-ap-layer/commit/522ecabd078b7b35276f2aa4f255f967f0b958bf)] aaaa (aprilthepink)
- [[`e75b523bb3`](https://github.com/lysand-org/lysand-ap-layer/commit/e75b523bb3d74bcf696313a320c35caa6f78e225)] awa (aprilthepink)
- [[`76d20cb2ef`](https://github.com/lysand-org/lysand-ap-layer/commit/76d20cb2ef8b3ef3ebe68e5a58c6f7588597ad4e)] awa (aprilthepink)
- [[`4d3657132d`](https://github.com/lysand-org/lysand-ap-layer/commit/4d3657132d764e71f70878de1ee1a284427eb7bb)] mew (aprilthepink)
- [[`643dc59b4b`](https://github.com/lysand-org/lysand-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)
- [[`9bc640aadc`](https://github.com/lysand-org/lysand-ap-layer/commit/9bc640aadcd2c02374fa195aed09452b4a3bb3ea)] [fix] format files (aprilthepink)
- [[`b90a332b3c`](https://github.com/lysand-org/lysand-ap-layer/commit/b90a332b3c1e23198d1fad3caddcc8b69dee6a4b)] basic AP (aprilthepink)
- [[`1c09eb793d`](https://github.com/lysand-org/lysand-ap-layer/commit/1c09eb793db0e9b29f3d45b044e269311420ed8b)] Rework readme (aprilthepink)
- [[`091b8efe8e`](https://github.com/lysand-org/lysand-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)
- [[`9a021e768d`](https://github.com/lysand-org/lysand-ap-layer/commit/9a021e768d62d4355324f9137e63ae279358ebed)] Create LICENSE (Helba)
- [[`9609c7ab83`](https://github.com/lysand-org/lysand-ap-layer/commit/9609c7ab83251ca31ded4f0589a7dac04ceca874)] initial commit (Helba)
- [[`51a708a1c3`](https://github.com/versia-pub/versia-ap-layer/commit/51a708a1c3d1aa974deb148156c07dfe7e775a8c)] feat! AGPL3 + Contributor Covenant (April John)
- [[`cc663ffc9b`](https://github.com/versia-pub/versia-ap-layer/commit/cc663ffc9b56b4b1a93ceaa2e488fc554e597790)] arbeiter (aprilthepink)
- [[`1e6c005698`](https://github.com/versia-pub/versia-ap-layer/commit/1e6c005698df8c781c60abfb1bab94d0b968c4d9)] enable ttp sign (aprilthepink)
- [[`0060d8baa8`](https://github.com/versia-pub/versia-ap-layer/commit/0060d8baa8b356d61d0aabfcd6b6f5143a47e8fa)] boop (aprilthepink)
- [[`522ecabd07`](https://github.com/versia-pub/versia-ap-layer/commit/522ecabd078b7b35276f2aa4f255f967f0b958bf)] aaaa (aprilthepink)
- [[`e75b523bb3`](https://github.com/versia-pub/versia-ap-layer/commit/e75b523bb3d74bcf696313a320c35caa6f78e225)] awa (aprilthepink)
- [[`76d20cb2ef`](https://github.com/versia-pub/versia-ap-layer/commit/76d20cb2ef8b3ef3ebe68e5a58c6f7588597ad4e)] awa (aprilthepink)
- [[`4d3657132d`](https://github.com/versia-pub/versia-ap-layer/commit/4d3657132d764e71f70878de1ee1a284427eb7bb)] mew (aprilthepink)
- [[`643dc59b4b`](https://github.com/versia-pub/versia-ap-layer/commit/643dc59b4bb0d7da13daf8d6ef47f3e0f31d1500)] Use Action badge on readme (aprilthepink)
- [[`3f4618d4d2`](https://github.com/versia-pub/versia-ap-layer/commit/3f4618d4d2291e16369fbb4ecddd35d6a841833e)] [feat] GH nix builds (aprilthepink)
- [[`9bc640aadc`](https://github.com/versia-pub/versia-ap-layer/commit/9bc640aadcd2c02374fa195aed09452b4a3bb3ea)] [fix] format files (aprilthepink)
- [[`b90a332b3c`](https://github.com/versia-pub/versia-ap-layer/commit/b90a332b3c1e23198d1fad3caddcc8b69dee6a4b)] basic AP (aprilthepink)
- [[`1c09eb793d`](https://github.com/versia-pub/versia-ap-layer/commit/1c09eb793db0e9b29f3d45b044e269311420ed8b)] Rework readme (aprilthepink)
- [[`091b8efe8e`](https://github.com/versia-pub/versia-ap-layer/commit/091b8efe8e0578304a81722d11e12db906c4edbc)] [feat]: basic nix dev enviroment (aprilthepink)
- [[`51c7a6d6a2`](https://github.com/versia-pub/versia-ap-layer/commit/51c7a6d6a2054f6dafbbac70c6b41239e56e2fe9)] Removed mod entities from main.rs (Helba)
- [[`9a021e768d`](https://github.com/versia-pub/versia-ap-layer/commit/9a021e768d62d4355324f9137e63ae279358ebed)] Create LICENSE (Helba)
- [[`9609c7ab83`](https://github.com/versia-pub/versia-ap-layer/commit/9609c7ab83251ca31ded4f0589a7dac04ceca874)] initial commit (Helba)
### Stats
```diff

View file

@ -1,13 +1,13 @@
<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>
## Lysand ActivityPub Bridge
## Versia ActivityPub Bridge
[![Nix Flake actions](https://github.com/lysand-org/activitypub/actions/workflows/nix-flake.yml/badge.svg)](https://github.com/lysand-org/activitypub/actions/workflows/nix-flake.yml)
[![Nix Flake actions](https://github.com/versia-pub/activitypub/actions/workflows/nix-flake.yml/badge.svg)](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.
@ -41,7 +41,7 @@ docker build -t activitypub:latest .
To run the docker image, use the [`docker-compose.yml`](./docker-compose.yml) file:
```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
```

View file

@ -6,4 +6,4 @@ services:
- LISTEN=0.0.0.0:8080
ports:
- 8080:8080
image: ghcr.io/lysand-org/activitypub:main
image: ghcr.io/versia-pub/activitypub:main

View file

@ -53,11 +53,11 @@
in
{
overlayAttrs = {
inherit (config.packages) lysand-ap-layer ls-ap-migration;
inherit (config.packages) versia-ap-layer ls-ap-migration;
};
# Rust package
packages.default = config.packages.lysand-ap-layer;
packages.lysand-ap-layer = naersk'.buildPackage {
packages.default = config.packages.versia-ap-layer;
packages.versia-ap-layer = naersk'.buildPackage {
inherit (cargoToml.package) name version;
src = ./.;
buildInputs = nonRustDeps;
@ -77,10 +77,10 @@
};
packages.ociImage = pkgs.dockerTools.buildLayeredImage
{
name = "ghcr.io/lysand-org/activitypub";
name = "ghcr.io/versia-pub/activitypub";
tag = "main";
contents = [
config.packages.lysand-ap-layer
config.packages.versia-ap-layer
config.packages.ls-ap-migration
pkgs.bash
];
@ -90,7 +90,7 @@
"${config.packages.ls-ap-migration}/bin/ls-ap-migration"
"up"
"&&"
"${config.packages.lysand-ap-layer}/bin/lysand-ap-layer"
"${config.packages.versia-ap-layer}/bin/versia-ap-layer"
];
ExposedPorts = {
"8080/tcp" = { };

View file

@ -1,2 +1,2 @@
nix run .#ls-ap-migration
nix run .#lysand-ap-layer
nix run .#versia-ap-layer

View file

@ -17,7 +17,7 @@ use crate::{
post, prelude, user,
},
error,
lysand::funcs::send_follow_accept_to_lysand,
versia::funcs::send_follow_accept_to_versia,
utils::{generate_follow_accept_id, generate_random_object_id},
DB,
};
@ -116,7 +116,7 @@ impl ActivityHandler for Follow {
}
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(())
}
}
@ -184,20 +184,20 @@ async fn save_accept_follow(
if query.is_none() {
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
let active_query = follow_relation::ActiveModel {
id: Set(query.unwrap().id),
ap_accept_id: Set(Some(accept_activity.id.to_string())),
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()
};
// modify db entry
let res = prelude::FollowRelation::update(active_query);
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)
}

View file

@ -2,9 +2,9 @@ use crate::{
database::StateHandle,
entities::user,
error::Error,
lysand::{
versia::{
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},
utils::generate_user_id,
@ -45,12 +45,12 @@ pub fn listen(config: &FederationConfig<StateHandle>) -> Result<(), Error> {
Ok(())
}
pub fn lysand_inbox(
note: web::Json<lysand::objects::Note>,
pub fn versia_inbox(
note: web::Json<versia::objects::Note>,
id: web::Path<String>,
data: Data<StateHandle>,
) -> 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())
}

View file

@ -15,8 +15,8 @@ use clap::Parser;
use database::Database;
use entities::post;
use http::{http_get_user, http_post_user_inbox, webfinger};
use lysand::http::{
create_activity, fetch_lysand_post, fetch_post, fetch_user, lysand_inbox, query_post,
use versia::http::{
create_activity, fetch_versia_post, fetch_post, fetch_user, versia_inbox, query_post,
};
use objects::person::{DbUser, Person};
use sea_orm::{ActiveModelTrait, DatabaseConnection, Set};
@ -47,7 +47,7 @@ mod database;
mod entities;
mod error;
mod http;
mod lysand;
mod versia;
mod objects;
mod utils;
@ -157,7 +157,7 @@ async fn follow_manually(
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";
lazy_static! {
@ -288,7 +288,7 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
.wrap(prometheus.clone())
.wrap(FederationMiddleware::new(data.clone()))
.service(post_manually)
.service(lysand_inbox)
.service(versia_inbox)
.service(follow_manually)
.route("/{user}", web::get().to(http_get_user))
.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(create_activity)
.service(query_post)
.service(fetch_lysand_post)
.service(fetch_versia_post)
})
.bind(SERVER_URL.to_string())?
.workers(num_cpus::get())

View file

@ -3,7 +3,7 @@ use crate::{
database::StateHandle,
entities::{post, user},
error::Error,
lysand::conversion::db_user_from_url,
versia::conversion::db_user_from_url,
objects::person::DbUser,
utils::generate_object_id,
};

View file

@ -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))
}
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!(
"https://{}/apbridge/lysand/object/{}",
"https://{}/apbridge/versia/object/{}",
domain, db_id
))
}

View file

@ -17,7 +17,7 @@ use crate::{
person::{AttachmentType, EndpointType, IconType, Person, TagType},
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,
};
@ -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?)
}
pub async fn lysand_post_from_db(
pub async fn versia_post_from_db(
post: entities::post::Model,
) -> anyhow::Result<super::objects::Note> {
let data = FEDERATION_CONFIG.get().unwrap();
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()
.filter(entities::user::Column::Id.eq(post.creator.clone()))
.one(DB.get().unwrap())
@ -60,7 +60,7 @@ pub async fn lysand_post_from_db(
ContentEntry::from_string(post.content),
);
let note = super::objects::Note {
rtype: super::objects::LysandType::Note,
rtype: super::objects::VersiaType::Note,
id: uuid::Uuid::parse_str(&post.id)?,
author: author.clone(),
uri: url.clone(),
@ -81,30 +81,30 @@ pub async fn lysand_post_from_db(
Ok(note)
}
pub async fn lysand_user_from_db(
pub async fn versia_user_from_db(
user: entities::user::Model,
) -> anyhow::Result<super::objects::User> {
let url = Url::parse(&user.url)?;
let ap = user.ap_json.unwrap();
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(
("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(
("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(
("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(
("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(
("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(
("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_username_ref = user.username.clone();
@ -206,7 +206,7 @@ pub async fn lysand_user_from_db(
custom_emojis: emojis,
};
let user = super::objects::User {
rtype: super::objects::LysandType::User,
rtype: super::objects::VersiaType::User,
id: uuid::Uuid::parse_str(&user.id)?,
uri: url.clone(),
username: user.username,
@ -244,7 +244,7 @@ pub async fn option_content_format_text(opt: Option<ContentFormat>) -> Option<St
#[async_recursion]
pub async fn db_post_from_url(url: Url) -> anyhow::Result<entities::post::Model> {
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 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)
} else {
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)
}
}
@ -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()))
&& !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()
.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?)
}
#[async_recursion]
pub async fn receive_lysand_note(
pub async fn receive_versia_note(
note: Note,
db_id: String,
) -> 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)
.one(DB.get().unwrap())
.await;
@ -559,7 +559,7 @@ pub async fn receive_lysand_note(
}
let post = entities::post::ActiveModel {
id: Set(note.id.to_string()),
creator: Set(lysand_author.id.clone()),
creator: Set(versia_author.id.clone()),
content: Set(ap_note.content.clone()),
sensitive: Set(ap_note.sensitive.unwrap_or_default()),
created_at: Set(Utc

View file

@ -9,12 +9,12 @@ use crate::{
};
use super::{
conversion::{fetch_user_from_url, lysand_user_from_db},
conversion::{fetch_user_from_url, versia_user_from_db},
objects::FollowResult,
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 db = DB.get().unwrap();
@ -27,26 +27,26 @@ pub async fn send_follow_accept_to_lysand(model: follow_relation::Model) -> anyh
.one(db)
.await?
.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()
.filter(user::Column::Id.eq(model.followee_id))
.one(db)
.await?
.unwrap();
let lysand_followee = lysand_user_from_db(followee_model).await?;
let versia_followee = versia_user_from_db(followee_model).await?;
let entity = FollowResult {
rtype: super::objects::LysandType::FollowAccept,
rtype: super::objects::VersiaType::FollowAccept,
id,
uri,
created_at: OffsetDateTime::now_utc(),
author: lysand_followee.uri,
follower: lysand_follower.uri,
author: versia_followee.uri,
follower: versia_follower.uri,
};
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("Accept", "application/json")
.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() {
Ok(())
} else {
Err(anyhow::anyhow!("Failed to send follow accept to Lysand"))
Err(anyhow::anyhow!("Failed to send follow accept to Versia"))
}
}

View file

@ -16,8 +16,8 @@ use crate::{
prelude, user,
},
error,
lysand::{
conversion::{lysand_post_from_db, lysand_user_from_db},
versia::{
conversion::{versia_post_from_db, versia_user_from_db},
inbox::inbox_entry,
},
objects::{self, person::Person},
@ -28,7 +28,7 @@ use crate::{
use super::conversion::db_user_from_url;
#[derive(serde::Deserialize)]
struct LysandQuery {
struct VersiaQuery {
// Post url
url: Option<Url>,
// User handle
@ -37,9 +37,9 @@ struct LysandQuery {
user_url: Option<Url>,
}
#[get("/apbridge/lysand/query")]
#[get("/apbridge/versia/query")]
async fn query_post(
query: web::Query<LysandQuery>,
query: web::Query<VersiaQuery>,
state: web::Data<State>,
) -> actix_web::Result<HttpResponse, error::Error> {
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())
.await?;
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()
.content_type("application/json")
.json(lysand_user));
.json(versia_user));
}
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()
.content_type("application/json")
.json(lysand_user));
.json(versia_user));
}
let opt_model = prelude::Post::find()
@ -86,11 +86,11 @@ async fn query_post(
Ok(HttpResponse::Ok()
.content_type("application/json")
.json(lysand_post_from_db(target).await?))
.json(versia_post_from_db(target).await?))
}
#[post("/apbridge/lysand/inbox")]
async fn lysand_inbox(
#[post("/apbridge/versia/inbox")]
async fn versia_inbox(
body: web::Bytes,
state: web::Data<State>,
) -> actix_web::Result<HttpResponse, error::Error> {
@ -145,8 +145,8 @@ async fn fetch_user(
.json(WithContext::new_default(deserialized_user)))
}
#[get("/apbridge/lysand/object/{post}")]
async fn fetch_lysand_post(
#[get("/apbridge/versia/object/{post}")]
async fn fetch_versia_post(
path: web::Path<String>,
state: web::Data<State>,
) -> actix_web::Result<HttpResponse, error::Error> {
@ -164,7 +164,7 @@ async fn fetch_lysand_post(
Ok(HttpResponse::Ok()
.content_type("application/json")
.json(lysand_post_from_db(post).await?))
.json(versia_post_from_db(post).await?))
}
#[get("/apbridge/create/{id}/{base64url}")]
@ -204,7 +204,7 @@ async fn create_activity(
.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 data = FEDERATION_CONFIG.get().unwrap();
@ -222,10 +222,10 @@ pub async fn lysand_url_to_user(url: Url) -> anyhow::Result<super::objects::User
.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,
) -> anyhow::Result<(super::objects::User, user::Model)> {
let db = DB.get().unwrap();
@ -245,10 +245,10 @@ pub async fn lysand_url_to_user_and_model(
.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,
) -> anyhow::Result<(super::objects::User, user::Model)> {
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?;
}
Ok((lysand_user_from_db(target.clone()).await?, target))
Ok((versia_user_from_db(target.clone()).await?, target))
}

View file

@ -5,7 +5,7 @@ use crate::{
prelude::{self, FollowRelation},
user,
},
lysand::http::main_lysand_url_to_user_and_model,
versia::http::main_versia_url_to_user_and_model,
utils::generate_follow_req_id,
API_DOMAIN, DB, FEDERATION_CONFIG,
};
@ -19,9 +19,9 @@ use serde::Deserialize;
use url::Url;
use super::{
conversion::lysand_user_from_db,
http::{lysand_url_to_user, lysand_url_to_user_and_model},
objects::LysandType,
conversion::versia_user_from_db,
http::{versia_url_to_user, versia_url_to_user_and_model},
objects::VersiaType,
};
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
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() {
Some("Note") => {
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 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());
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>(
&(author.1.ap_json.clone()).unwrap(),
)?;

View file

@ -22,7 +22,7 @@ const FORMAT: Iso8601<6651332276412969266533270467398074368> = Iso8601::<
.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>(
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);
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum LysandType {
pub enum VersiaType {
User,
Note,
Patch,
@ -71,26 +71,26 @@ pub enum VisibilityType {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum LysandExtensions {
#[serde(rename = "org.lysand:microblogging/Announce")]
pub enum VersiaExtensions {
#[serde(rename = "org.versia:microblogging/Announce")]
Announce,
#[serde(rename = "org.lysand:custom_emojis")]
#[serde(rename = "org.versia:custom_emojis")]
CustomEmojis,
#[serde(rename = "org.lysand:reactions/Reaction")]
#[serde(rename = "org.versia:reactions/Reaction")]
Reaction,
#[serde(rename = "org.lysand:reactions")]
#[serde(rename = "org.versia:reactions")]
Reactions,
#[serde(rename = "org.lysand:polls")]
#[serde(rename = "org.versia:polls")]
Polls,
#[serde(rename = "org.lysand:is_cat")]
#[serde(rename = "org.versia:is_cat")]
IsCat,
#[serde(rename = "org.lysand:server_endorsement/Endorsement")]
#[serde(rename = "org.versia:server_endorsement/Endorsement")]
Endorsement,
#[serde(rename = "org.lysand:server_endorsement")]
#[serde(rename = "org.versia:server_endorsement")]
EndorsementCollection,
#[serde(rename = "org.lysand:reports/Report")]
#[serde(rename = "org.versia:reports/Report")]
Report,
#[serde(rename = "org.lysand:vanity")]
#[serde(rename = "org.versia:vanity")]
Vanity,
}
@ -254,10 +254,10 @@ impl ContentEntry {
pub struct User {
pub public_key: PublicKey,
#[serde(rename = "type")]
pub rtype: LysandType,
pub rtype: VersiaType,
pub id: Uuid,
pub uri: Url,
#[serde(with = "iso_lysand")]
#[serde(with = "iso_versia")]
pub created_at: OffsetDateTime,
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
@ -284,7 +284,7 @@ pub struct User {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ExtensionSpecs {
#[serde(rename = "org.lysand:custom_emojis")]
#[serde(rename = "org.versia:custom_emojis")]
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_emojis: Option<CustomEmojis>,
}
@ -321,11 +321,11 @@ pub struct LinkPreview {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Note {
#[serde(rename = "type")]
pub rtype: LysandType,
pub rtype: VersiaType,
pub id: Uuid,
pub uri: Url,
pub author: Url,
#[serde(with = "iso_lysand")]
#[serde(with = "iso_versia")]
pub created_at: OffsetDateTime,
#[serde(skip_serializing_if = "Option::is_none")]
pub category: Option<CategoryType>,
@ -357,13 +357,13 @@ pub struct Note {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Patch {
#[serde(rename = "type")]
pub rtype: LysandType,
pub rtype: VersiaType,
pub id: Uuid,
pub uri: Url,
pub author: Url,
#[serde(with = "iso_lysand")]
#[serde(with = "iso_versia")]
pub created_at: OffsetDateTime,
#[serde(with = "iso_lysand")]
#[serde(with = "iso_versia")]
pub patched_at: OffsetDateTime,
#[serde(skip_serializing_if = "Option::is_none")]
pub category: Option<CategoryType>,
@ -406,11 +406,11 @@ pub struct Outbox {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Follow {
#[serde(rename = "type")]
pub rtype: LysandType,
pub rtype: VersiaType,
pub id: Uuid,
pub uri: Url,
pub author: Url,
#[serde(with = "iso_lysand")]
#[serde(with = "iso_versia")]
pub created_at: OffsetDateTime,
pub followee: Url,
}
@ -418,11 +418,11 @@ pub struct Follow {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct FollowResult {
#[serde(rename = "type")]
pub rtype: LysandType,
pub rtype: VersiaType,
pub id: Uuid,
pub uri: Url,
pub author: Url,
#[serde(with = "iso_lysand")]
#[serde(with = "iso_versia")]
pub created_at: OffsetDateTime,
pub follower: Url,
}

View file

@ -10,15 +10,15 @@ pub async fn serialize_user(user: super::objects::User) -> anyhow::Result<String
Ok(data)
}
pub async fn deserialize_lysand_type(data: String) -> anyhow::Result<super::objects::LysandType> {
let lysand_type: super::objects::LysandType = serde_json::from_str(&data)?;
Ok(lysand_type)
pub async fn deserialize_versia_type(data: String) -> anyhow::Result<super::objects::VersiaType> {
let versia_type: super::objects::VersiaType = serde_json::from_str(&data)?;
Ok(versia_type)
}
pub async fn serialize_lysand_type(
lysand_type: super::objects::LysandType,
pub async fn serialize_versia_type(
versia_type: super::objects::VersiaType,
) -> anyhow::Result<String> {
let data = serde_json::to_string(&lysand_type)?;
let data = serde_json::to_string(&versia_type)?;
Ok(data)
}

View file

@ -1,4 +1,4 @@
use crate::lysand::objects::SortAlphabetically;
use crate::versia::objects::SortAlphabetically;
use super::superx::request_client;
@ -6,7 +6,7 @@ use super::superx::request_client;
async fn test_user_serial() {
let client = request_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()
.await
.unwrap();
@ -25,7 +25,7 @@ pub async fn main() -> anyhow::Result<()> {
println!("Requesting user");
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()
.await?;
println!("Response: {:?}", response);
@ -50,9 +50,9 @@ pub async fn main() -> anyhow::Result<()> {
println!("\n\n\nas AP:");
for item in outbox.items {
let ap_item = super::conversion::receive_lysand_note(
let ap_item = super::conversion::receive_versia_note(
item,
"https://ap.lysand.org/example".to_string(),
"https://ap.versia.social/example".to_string(),
)
.await?;
println!("{:#?}", ap_item);