This commit is contained in:
Piyush मिश्रः 2021-05-12 17:04:23 +05:30
parent e8396d0634
commit f5e56c5c0c
6 changed files with 29 additions and 6 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target
/.env

8
Cargo.lock generated
View File

@ -715,6 +715,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
[[package]]
name = "dotenv"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "dtoa"
version = "0.4.8"
@ -1204,8 +1210,10 @@ dependencies = [
"actix-web-actors",
"base64",
"clap",
"dotenv",
"env_logger",
"futures",
"lazy_static",
"openssl",
"rand 0.8.3",
"serde",

View File

@ -17,7 +17,10 @@ actix-ratelimit = "0.3.1"
env_logger = "0.8.3"
openssl = "0.10.28"
dotenv = "0.15.0"
clap = "2.33.3"
lazy_static = "1.4.0"
serde = "1.0.123"
serde_json = "1.0.62"
rand = "0.8.3"

View File

@ -8,6 +8,10 @@
//! |--> ws_sansad3 <---- /
//! |--> ws_sansad4 <----/
//!
#[macro_use]
extern crate lazy_static;
use actix_web::{
App, Error, HttpRequest, HttpResponse, HttpServer, middleware::Logger, web,
client::{Client, Connector}
@ -24,8 +28,15 @@ mod broker_messages;
mod ws_sansad;
mod chat_pinnd;
mod validator;
lazy_static! {
pub static ref SALT: String = std::env::var("SALT").unwrap();
pub static ref TENOR_API_KEY: String = std::env::var("TENOR_API_KEY").unwrap();
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenv::dotenv().ok();
std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
let store = MemoryStore::new();
@ -63,7 +74,7 @@ async fn gif(req: HttpRequest) -> Result<HttpResponse, Error> {
.finish();
let url = format!("https://g.tenor.com/v1/search?q={}&key=LIVDSRZULELA&limit=20&media_filter=tinygif", name);
let url = format!("https://g.tenor.com/v1/search?q={}&key={}&limit=20&media_filter=tinygif", name, TENOR_API_KEY.to_owned());
let response = client.get(url)
.header("User-Agent", "actix-web/3.0")
.send()

View File

@ -22,7 +22,7 @@ impl WsSansad {
// kunjika to hash and base64
let mut m = sha1::Sha1::new();
m.update(format!("{}{}",kunjika,
std::env::var("SALT").unwrap_or("".to_owned())).as_bytes());
crate::SALT.to_owned()).as_bytes());
let kunjika = base64::encode(m.digest().bytes())[..8].to_owned();
let name = match val.get("name") {
@ -139,7 +139,7 @@ impl WsSansad {
// kunjika to hash and base64
let mut m = sha1::Sha1::new();
m.update(format!("{}{}",kunjika,
std::env::var("SALT").unwrap_or("".to_owned())).as_bytes());
crate::SALT.to_owned()).as_bytes());
let kunjika = base64::encode(m.digest().bytes())[..8].to_owned();
let name = match val.get("name") {

View File

@ -48,7 +48,7 @@
<div>
<label>Your kunjika(your id)</label>
<input name="kunjika" type="text" placeholder="Your kunjika (Don't share it)">
<small class="text-grey">Pick a random kunjika(id)<br><b>Don't share it</b></small>
<small class="text-grey">Pick a random kunjika(id). <b>Don't share it</b></small>
</div>
<div>
<label>Your name</label>