[fix] format files

This commit is contained in:
aprilthepink 2024-04-09 19:55:07 +02:00
parent b90a332b3c
commit 9bc640aadc
11 changed files with 78 additions and 46 deletions

View file

@ -3,9 +3,9 @@ fn main() {
vcpkg::Config::new() vcpkg::Config::new()
.emit_includes(true) .emit_includes(true)
.copy_dlls(true) .copy_dlls(true)
.find_package("libpq").unwrap(); .find_package("libpq")
.unwrap();
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
fn main() { fn main() {}
}

41
flake.lock generated
View file

@ -18,6 +18,26 @@
"type": "github" "type": "github"
} }
}, },
"nix-github-actions": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1703863825,
"narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "5163432afc817cf8bd1f031418d1869e4c9d5547",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1710806803, "lastModified": 1710806803,
@ -52,25 +72,10 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1708475490,
"narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e74ca98a74bc7270d28838369593635a5db3260",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nix-github-actions": "nix-github-actions",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"systems": "systems", "systems": "systems",
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
@ -93,7 +98,9 @@
}, },
"treefmt-nix": { "treefmt-nix": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2" "nixpkgs": [
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1710781103, "lastModified": 1710781103,

View file

@ -1,12 +1,19 @@
{ {
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
systems.url = "github:nix-systems/default"; systems.url = "github:nix-systems/default";
systems.inputs.nixpkgs.follows = "nixpkgs";
nix-github-actions.url = "github:nix-community/nix-github-actions";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
# Dev tools # Dev tools
treefmt-nix.url = "github:numtide/treefmt-nix"; treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = inputs: outputs = inputs:

View file

@ -1,9 +1,9 @@
use crate::{ use crate::{
database::DatabaseHandle, database::DatabaseHandle,
error::Error, error::Error,
objects::post::DbPost,
objects::{person::DbUser, post::Note}, objects::{person::DbUser, post::Note},
utils::generate_object_id, utils::generate_object_id,
objects::post::DbPost,
}; };
use activitypub_federation::{ use activitypub_federation::{
activity_sending::SendActivityTask, activity_sending::SendActivityTask,

View file

@ -1,4 +1,4 @@
use crate::{objects::person::DbUser, error::Error}; use crate::{error::Error, objects::person::DbUser};
use anyhow::anyhow; use anyhow::anyhow;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};

View file

@ -1,6 +1,6 @@
use crate::{ use crate::{
error::Error,
database::DatabaseHandle, database::DatabaseHandle,
error::Error,
objects::person::{DbUser, PersonAcceptedActivities}, objects::person::{DbUser, PersonAcceptedActivities},
}; };
use activitypub_federation::{ use activitypub_federation::{

View file

@ -6,17 +6,20 @@ use database::Database;
use http::{http_get_user, http_post_user_inbox, webfinger}; use http::{http_get_user, http_post_user_inbox, webfinger};
use objects::person::DbUser; use objects::person::DbUser;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::signal;
use std::{ use std::{
collections::HashMap, env, net::ToSocketAddrs, sync::{Arc, Mutex} collections::HashMap,
env,
net::ToSocketAddrs,
sync::{Arc, Mutex},
}; };
use tokio::signal;
mod database;
mod objects;
mod activities; mod activities;
mod utils; mod database;
mod error; mod error;
mod http; mod http;
mod objects;
mod utils;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct State { struct State {
@ -55,7 +58,15 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
let server_url = env::var("LISTEN").unwrap_or("127.0.0.1:8080".to_string()); let server_url = env::var("LISTEN").unwrap_or("127.0.0.1:8080".to_string());
let local_user = DbUser::new(env::var("FEDERATED_DOMAIN").unwrap_or(DOMAIN.to_string()).as_str(), env::var("LOCAL_USER_NAME").unwrap_or(LOCAL_USER_NAME.to_string()).as_str()).unwrap(); let local_user = DbUser::new(
env::var("FEDERATED_DOMAIN")
.unwrap_or(DOMAIN.to_string())
.as_str(),
env::var("LOCAL_USER_NAME")
.unwrap_or(LOCAL_USER_NAME.to_string())
.as_str(),
)
.unwrap();
let database = Arc::new(Database { let database = Arc::new(Database {
users: Mutex::new(vec![local_user]), users: Mutex::new(vec![local_user]),
@ -66,12 +77,22 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
let data = FederationConfig::builder() let data = FederationConfig::builder()
.domain(env::var("FEDERATED_DOMAIN").expect("FEDERATED_DOMAIN must be set")) .domain(env::var("FEDERATED_DOMAIN").expect("FEDERATED_DOMAIN must be set"))
.app_data(state.clone().database) .app_data(state.clone().database)
.build().await?; .build()
.await?;
let mut labels = HashMap::new(); let mut labels = HashMap::new();
labels.insert("domain".to_string(), env::var("FEDERATED_DOMAIN").expect("FEDERATED_DOMAIN must be set").to_string()); labels.insert(
labels.insert("name".to_string(), env::var("LOCAL_USER_NAME").expect("LOCAL_USER_NAME must be set").to_string()); "domain".to_string(),
env::var("FEDERATED_DOMAIN")
.expect("FEDERATED_DOMAIN must be set")
.to_string(),
);
labels.insert(
"name".to_string(),
env::var("LOCAL_USER_NAME")
.expect("LOCAL_USER_NAME must be set")
.to_string(),
);
let prometheus = PrometheusMetricsBuilder::new("api") let prometheus = PrometheusMetricsBuilder::new("api")
.endpoint("/metrics") .endpoint("/metrics")
@ -99,11 +120,11 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
tokio::spawn(http_server); tokio::spawn(http_server);
match signal::ctrl_c().await { match signal::ctrl_c().await {
Ok(()) => {}, Ok(()) => {}
Err(err) => { Err(err) => {
eprintln!("Unable to listen for shutdown signal: {}", err); eprintln!("Unable to listen for shutdown signal: {}", err);
// we also shut down in case of error // we also shut down in case of error
}, }
} }
Ok(()) Ok(())

View file

@ -1,9 +1,6 @@
use crate::{ use crate::{
activities::create_post::CreatePost, activities::create_post::CreatePost, database::DatabaseHandle, error::Error,
database::DatabaseHandle, objects::person::DbUser, utils::generate_object_id,
error::Error,
utils::generate_object_id,
objects::person::DbUser,
}; };
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,