mirror of
https://github.com/versia-pub/activitypub.git
synced 2025-12-06 06:38:20 +01:00
feat: Add .env file to gitignore and update dependencies
The commit adds the `.env` file to the `.gitignore` and updates the dependencies in the `Cargo.toml` and `Cargo.lock` files. This change ensures that sensitive environment variables are not committed to the repository and keeps the dependencies up to date.
This commit is contained in:
parent
1174f92915
commit
15bba70d2a
4
.env.example
Normal file
4
.env.example
Normal file
|
|
@ -0,0 +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"
|
||||
RUST_LOG="debug"
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -5,4 +5,5 @@
|
|||
/result-lib
|
||||
.direnv
|
||||
migration/target
|
||||
db.sqlite
|
||||
db.sqlite
|
||||
.env
|
||||
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -1027,6 +1027,12 @@ dependencies = [
|
|||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dotenv"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
|
||||
[[package]]
|
||||
name = "dotenvy"
|
||||
version = "0.15.7"
|
||||
|
|
@ -1908,6 +1914,7 @@ dependencies = [
|
|||
"async_once",
|
||||
"chrono",
|
||||
"clap",
|
||||
"dotenv",
|
||||
"enum_delegate",
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ async_once = "0.2.6"
|
|||
reqwest = { version = "0.12.4", features = ["blocking", "json", "multipart"] }
|
||||
time = { version = "0.3.36", features = ["serde"] }
|
||||
serde_derive = "1.0.201"
|
||||
dotenv = "0.15.0"
|
||||
|
||||
[dependencies.sea-orm]
|
||||
version = "0.12.0"
|
||||
|
|
|
|||
7
migration/Cargo.lock
generated
7
migration/Cargo.lock
generated
|
|
@ -583,6 +583,12 @@ dependencies = [
|
|||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dotenv"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
|
||||
[[package]]
|
||||
name = "dotenvy"
|
||||
version = "0.15.7"
|
||||
|
|
@ -1129,6 +1135,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"async-std",
|
||||
"chrono",
|
||||
"dotenv",
|
||||
"sea-orm-migration",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ path = "src/lib.rs"
|
|||
[dependencies]
|
||||
async-std = { version = "1", features = ["attributes", "tokio1"] }
|
||||
chrono = "0.4.38"
|
||||
dotenv = "0.15.0"
|
||||
|
||||
[dependencies.sea-orm-migration]
|
||||
version = "0.12.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use sea_orm_migration::prelude::*;
|
||||
use dotenv::dotenv;
|
||||
|
||||
#[async_std::main]
|
||||
async fn main() {
|
||||
dotenv().ok();
|
||||
cli::run_cli(migration::Migrator).await;
|
||||
}
|
||||
|
|
|
|||
2
nix-bootstrap.sh
Normal file
2
nix-bootstrap.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
nix run .#ls-ap-migration
|
||||
nix run .#lysand-ap-layer
|
||||
|
|
@ -76,6 +76,7 @@ pub async fn receive_lysand_note(note: Note, db_id: String) -> anyhow::Result<cr
|
|||
let id: ObjectId<post::Model> = generate_object_id(data.domain(), ¬e.id.to_string())?.into();
|
||||
let user_id = generate_user_id(data.domain(), &target.id.to_string())?;
|
||||
let user = fetch_user_from_url(note.author.clone()).await?;
|
||||
let data = FEDERATION_CONFIG.get().unwrap();
|
||||
let mut tag: Vec<Mention> = Vec::new();
|
||||
for l_tag in note.mentions.clone().unwrap_or_default() {
|
||||
tag.push(Mention { href: l_tag, //TODO convert to ap url
|
||||
|
|
@ -94,7 +95,18 @@ pub async fn receive_lysand_note(note: Note, db_id: String) -> anyhow::Result<cr
|
|||
let reply: Option<ObjectId<entities::post::Model>> = if let Some(rep) = note.replies_to.clone() {
|
||||
let note = fetch_note_from_url(rep).await?;
|
||||
let fake_rep_url = Url::parse(&format!(
|
||||
"https://{}/lysand/apnote/{}",
|
||||
"https://{}/apbridge/object/{}",
|
||||
API_DOMAIN.to_string(),
|
||||
¬e.id.to_string()
|
||||
))?;
|
||||
Some(fake_rep_url.into())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let quote: Option<ObjectId<entities::post::Model>> = if let Some(rep) = note.quotes.clone() {
|
||||
let note = fetch_note_from_url(rep).await?;
|
||||
let fake_rep_url = Url::parse(&format!(
|
||||
"https://{}/apbridge/object/{}",
|
||||
API_DOMAIN.to_string(),
|
||||
¬e.id.to_string()
|
||||
))?;
|
||||
|
|
@ -105,7 +117,7 @@ pub async fn receive_lysand_note(note: Note, db_id: String) -> anyhow::Result<cr
|
|||
let reply_string: Option<String> = if let Some(rep) = note.replies_to {
|
||||
let note = fetch_note_from_url(rep).await?;
|
||||
let fake_rep_url = Url::parse(&format!(
|
||||
"https://{}/lysand/apnote/{}",
|
||||
"https://{}/apbridge/object/{}",
|
||||
API_DOMAIN.to_string(),
|
||||
¬e.id.to_string()
|
||||
))?;
|
||||
|
|
@ -116,7 +128,7 @@ pub async fn receive_lysand_note(note: Note, db_id: String) -> anyhow::Result<cr
|
|||
let quote_string: Option<String> = if let Some(rep) = note.quotes.clone() {
|
||||
let note = fetch_note_from_url(rep).await?;
|
||||
let fake_rep_url = Url::parse(&format!(
|
||||
"https://{}/lysand/apnote/{}",
|
||||
"https://{}/apbridge/object/{}",
|
||||
API_DOMAIN.to_string(),
|
||||
¬e.id.to_string()
|
||||
))?;
|
||||
|
|
@ -133,7 +145,7 @@ pub async fn receive_lysand_note(note: Note, db_id: String) -> anyhow::Result<cr
|
|||
tag,
|
||||
attributed_to: Url::parse(user.uri.clone().as_str()).unwrap().into(),
|
||||
content: option_content_format_text(note.content).await.unwrap_or_default(),
|
||||
in_reply_to: reply
|
||||
in_reply_to: reply.clone()
|
||||
};
|
||||
|
||||
let visibility = match note.visibility.clone().unwrap_or(super::objects::VisibilityType::Public) {
|
||||
|
|
@ -142,7 +154,12 @@ pub async fn receive_lysand_note(note: Note, db_id: String) -> anyhow::Result<cr
|
|||
super::objects::VisibilityType::Direct => "direct",
|
||||
super::objects::VisibilityType::Unlisted => "unlisted",
|
||||
};
|
||||
|
||||
if let Some(obj) = quote {
|
||||
println!("Quoting: {}", obj.dereference(&data.to_request_data()).await.unwrap().url);
|
||||
}
|
||||
if let Some(obj) = reply {
|
||||
println!("Replying to: {}", obj.dereference(&data.to_request_data()).await.unwrap().url);
|
||||
}
|
||||
let post = entities::post::ActiveModel {
|
||||
id: Set(note.id.to_string()),
|
||||
creator: Set(lysand_author.id.clone()),
|
||||
|
|
|
|||
|
|
@ -7,18 +7,21 @@ use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
|
|||
use crate::{database::State, entities::{post::{self, Entity}, prelude}, error, Response, DB, FEDERATION_CONFIG};
|
||||
|
||||
#[get("/apbridge/object/{post}")]
|
||||
async fn post_manually(
|
||||
path: web::Path<(String, String)>,
|
||||
async fn fetch_post(
|
||||
path: web::Path<String>,
|
||||
state: web::Data<State>,
|
||||
) -> actix_web::Result<HttpResponse, error::Error> {
|
||||
let db = DB.get().unwrap();
|
||||
|
||||
let post = prelude::Post::find()
|
||||
.filter(post::Column::Id.eq(path.0.as_str()))
|
||||
.filter(post::Column::Id.eq(path.as_str()))
|
||||
.one(db)
|
||||
.await?;
|
||||
|
||||
let post = post.unwrap();
|
||||
let post = match post {
|
||||
Some(post) => post,
|
||||
None => return Ok(HttpResponse::NotFound().finish()),
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok().content_type(FEDERATION_CONTENT_TYPE).json(post.into_json(&FEDERATION_CONFIG.get().unwrap().to_request_data()).await?))
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ use crate::{
|
|||
};
|
||||
use crate::{activities::follow::Follow, entities::user};
|
||||
use lazy_static::lazy_static;
|
||||
use dotenv::dotenv;
|
||||
|
||||
mod activities;
|
||||
mod database;
|
||||
|
|
@ -152,6 +153,7 @@ static FEDERATION_CONFIG: OnceLock<FederationConfig<State>> = OnceLock::new();
|
|||
|
||||
#[actix_web::main]
|
||||
async fn main() -> actix_web::Result<(), anyhow::Error> {
|
||||
dotenv().ok();
|
||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||
|
||||
let ap_id = Url::parse(&format!(
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ impl Object for post::Model {
|
|||
let post = crate::entities::prelude::Post::find()
|
||||
.filter(post::Column::Id.eq(object_id.to_string()))
|
||||
.one(data.app_data().database_connection.clone().as_ref()).await;
|
||||
Ok(None)
|
||||
Ok(post.unwrap())
|
||||
}
|
||||
|
||||
async fn into_json(self, _data: &Data<Self::DataType>) -> Result<Self::Kind, Self::Error> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue