expose pluralkit and the like in web

This commit is contained in:
Cadey Ratio 2020-11-04 12:36:12 -05:00
parent 19ab543438
commit 62489eaff4
3 changed files with 18 additions and 8 deletions

View File

@ -1,5 +1,9 @@
use super::{Error, Result, StringBody}; use super::{Error, Result, StringBody};
use crate::{models, paseto, schema, web, MainDatabase}; use crate::{
models, paseto, schema,
web::{PluralKit, SwitchCounter},
MainDatabase,
};
use chrono::prelude::*; use chrono::prelude::*;
use diesel::prelude::*; use diesel::prelude::*;
use rocket::State; use rocket::State;
@ -82,8 +86,8 @@ pub fn current_front(conn: MainDatabase, tok: paseto::Token) -> Result<Json<Fron
pub fn switch( pub fn switch(
conn: MainDatabase, conn: MainDatabase,
who: StringBody, who: StringBody,
sc: State<web::switchcounter::Client>, sc: State<SwitchCounter>,
pk: State<web::pluralkit::Client>, pk: State<PluralKit>,
tok: paseto::Token, tok: paseto::Token,
) -> Result<String> { ) -> Result<String> {
use schema::{members, switches}; use schema::{members, switches};

View File

@ -43,11 +43,11 @@ fn main() -> Result<()> {
.attach(MainDatabase::fairing()) .attach(MainDatabase::fairing())
.attach(SpaceHelmet::default()) .attach(SpaceHelmet::default())
.attach(paseto::ed25519_keypair()) .attach(paseto::ed25519_keypair())
.attach(discord_webhook::Client::fairing()) .attach(DiscordWebhook::fairing())
.attach(mastodon::Client::fairing()) .attach(Mastodon::fairing())
.attach(pluralkit::Client::fairing()) .attach(PluralKit::fairing())
.attach(switchcounter::Client::fairing()) .attach(SwitchCounter::fairing())
.attach(twitter::Client::fairing()) .attach(Twitter::fairing())
.mount("/metrics", prometheus) .mount("/metrics", prometheus)
.mount("/", routes![botinfo]) .mount("/", routes![botinfo])
.mount( .mount(

View File

@ -4,6 +4,12 @@ pub mod pluralkit;
pub mod switchcounter; pub mod switchcounter;
pub mod twitter; pub mod twitter;
pub use discord_webhook::Client as DiscordWebhook;
pub use mastodon::Client as Mastodon;
pub use pluralkit::Client as PluralKit;
pub use switchcounter::Client as SwitchCounter;
pub use twitter::Client as Twitter;
pub type Result<T = ()> = std::result::Result<T, Error>; pub type Result<T = ()> = std::result::Result<T, Error>;
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]