mirror of
https://codeberg.org/icewind/rss-webhook-trigger.git
synced 2026-11-30 12:10:50 +01:00
clippy, interal nix option
This commit is contained in:
parent
c04a04ea29
commit
7821076b15
3 changed files with 21 additions and 15 deletions
|
|
@ -8,13 +8,19 @@ with lib; let
|
||||||
cfg = config.services.rss-webhook-trigger;
|
cfg = config.services.rss-webhook-trigger;
|
||||||
format = pkgs.formats.toml {};
|
format = pkgs.formats.toml {};
|
||||||
configFile = format.generate "trigger.toml" {
|
configFile = format.generate "trigger.toml" {
|
||||||
|
inherit (cfg) jwt interval;
|
||||||
feed = cfg.hooks;
|
feed = cfg.hooks;
|
||||||
jwt = cfg.jwt;
|
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.services.rss-webhook-trigger = {
|
options.services.rss-webhook-trigger = {
|
||||||
enable = mkEnableOption "Enables the rss-webhook-trigger service";
|
enable = mkEnableOption "Enables the rss-webhook-trigger service";
|
||||||
|
|
||||||
|
interval = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 1800;
|
||||||
|
description = "how often to check the feeds for updates";
|
||||||
|
};
|
||||||
|
|
||||||
jwt = mkOption {
|
jwt = mkOption {
|
||||||
description = "Configuration for generating JWT authorization tokens";
|
description = "Configuration for generating JWT authorization tokens";
|
||||||
type = types.nullOr (types.submodule {
|
type = types.nullOr (types.submodule {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::error::{ConfigError, JwtError};
|
use crate::error::{ConfigError, JwtError};
|
||||||
use jsonwebtoken::EncodingKey;
|
use jsonwebtoken::EncodingKey;
|
||||||
use secretfile::{load, SecretError};
|
use secretfile::{SecretError, load};
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
@ -66,7 +66,7 @@ impl TryFrom<JwtConfigRaw> for JwtConfig {
|
||||||
let secret = load_secret(value.key)?;
|
let secret = load_secret(value.key)?;
|
||||||
|
|
||||||
Ok(JwtConfig {
|
Ok(JwtConfig {
|
||||||
key: EncodingKey::from_rsa_pem(&secret.as_bytes())?,
|
key: EncodingKey::from_rsa_pem(secret.as_bytes())?,
|
||||||
issuer: value.issuer,
|
issuer: value.issuer,
|
||||||
listen: value.listen,
|
listen: value.listen,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,9 @@ fn main() -> MainResult {
|
||||||
|
|
||||||
let config = Config::from_file(&file)?;
|
let config = Config::from_file(&file)?;
|
||||||
|
|
||||||
if let Some(jwt_config) = config.jwt.clone() {
|
if let Some(jwt_config) = config.jwt.clone()
|
||||||
if let Some(listen) = jwt_config.listen.clone() {
|
&& let Some(listen) = jwt_config.listen.clone()
|
||||||
|
{
|
||||||
spawn(|| {
|
spawn(|| {
|
||||||
let rt = tokio::runtime::Builder::new_current_thread()
|
let rt = tokio::runtime::Builder::new_current_thread()
|
||||||
.enable_io()
|
.enable_io()
|
||||||
|
|
@ -59,7 +60,6 @@ fn main() -> MainResult {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
info!("Running rss trigger for {} feeds", config.feed.len());
|
info!("Running rss trigger for {} feeds", config.feed.len());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue