[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

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

41
flake.lock generated
View file

@ -18,6 +18,26 @@
"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": {
"locked": {
"lastModified": 1710806803,
@ -52,25 +72,10 @@
"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": {
"inputs": {
"flake-parts": "flake-parts",
"nix-github-actions": "nix-github-actions",
"nixpkgs": "nixpkgs",
"systems": "systems",
"treefmt-nix": "treefmt-nix"
@ -93,7 +98,9 @@
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_2"
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1710781103,

View file

@ -1,12 +1,19 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
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
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs:

View file

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {}}:
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
buildInputs = with pkgs; [

View file

@ -1,9 +1,9 @@
use crate::{
database::DatabaseHandle,
error::Error,
objects::post::DbPost,
objects::{person::DbUser, post::Note},
utils::generate_object_id,
objects::post::DbPost,
};
use activitypub_federation::{
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 std::sync::{Arc, Mutex};

View file

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

View file

@ -6,17 +6,20 @@ use database::Database;
use http::{http_get_user, http_post_user_inbox, webfinger};
use objects::person::DbUser;
use serde::{Deserialize, Serialize};
use tokio::signal;
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 utils;
mod database;
mod error;
mod http;
mod objects;
mod utils;
#[derive(Debug, Clone)]
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 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 {
users: Mutex::new(vec![local_user]),
@ -66,12 +77,22 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
let data = FederationConfig::builder()
.domain(env::var("FEDERATED_DOMAIN").expect("FEDERATED_DOMAIN must be set"))
.app_data(state.clone().database)
.build().await?;
.build()
.await?;
let mut labels = HashMap::new();
labels.insert("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());
labels.insert(
"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")
.endpoint("/metrics")
@ -99,11 +120,11 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
tokio::spawn(http_server);
match signal::ctrl_c().await {
Ok(()) => {},
Ok(()) => {}
Err(err) => {
eprintln!("Unable to listen for shutdown signal: {}", err);
// we also shut down in case of error
},
}
}
Ok(())

View file

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