checksum = "3dae854440faecce70f0664f41f09a588de1e7a4366931ec3962ded3d8f903c5"
dependencies = [
"blocking",
- "nats",
+ "nats 0.10.1",
]
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+[[package]]
+name = "chrono"
+version = "0.4.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
+dependencies = [
+ "libc",
+ "num-integer",
+ "num-traits 0.2.14",
+ "serde 1.0.130",
+ "time",
+ "winapi 0.3.9",
+]
+
[[package]]
name = "cloudabi"
version = "0.0.3"
dependencies = [
"cfg-if 1.0.0",
"libc",
- "wasi 0.10.2+wasi-snapshot-preview1",
+ "wasi 0.10.0+wasi-snapshot-preview1",
]
[[package]]
"winapi 0.3.9",
]
+[[package]]
+name = "nats"
+version = "0.15.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2a3097b182107db2cf690280d61f23f17ee31d49f3994ad152ee6a10261f77c3"
+dependencies = [
+ "base64",
+ "base64-url",
+ "blocking",
+ "chrono",
+ "crossbeam-channel",
+ "fastrand",
+ "itoa",
+ "json",
+ "libc",
+ "log",
+ "memchr",
+ "nkeys",
+ "nuid",
+ "once_cell",
+ "parking_lot 0.11.2",
+ "regex",
+ "rustls",
+ "rustls-native-certs",
+ "serde 1.0.130",
+ "serde_json",
+ "webpki",
+ "winapi 0.3.9",
+]
+
[[package]]
name = "net2"
version = "0.2.37"
"rand 0.8.4",
]
+[[package]]
+name = "num-integer"
+version = "0.1.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
+dependencies = [
+ "autocfg",
+ "num-traits 0.2.14",
+]
+
[[package]]
name = "num-traits"
version = "0.1.43"
"syn",
]
+[[package]]
+name = "time"
+version = "0.1.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
+dependencies = [
+ "libc",
+ "wasi 0.10.0+wasi-snapshot-preview1",
+ "winapi 0.3.9",
+]
+
[[package]]
name = "tinyvec"
version = "1.3.1"
[[package]]
name = "wasi"
-version = "0.10.2+wasi-snapshot-preview1"
+version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
+checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "wasm-bindgen"
"hyper",
"libsodium-sys",
"log",
+ "nats 0.15.2",
"pretty_env_logger",
"serde 1.0.130",
"serde_json",
"hyper": "@raze__hyper__0_14_12//:hyper",
"libsodium-sys": "@raze__libsodium_sys__0_2_7//:libsodium_sys",
"log": "@raze__log__0_4_14//:log",
+ "nats": "@raze__nats__0_15_2//:nats",
"pretty_env_logger": "@raze__pretty_env_logger__0_4_0//:pretty_env_logger",
"serde": "@raze__serde__1_0_130//:serde",
"serde_json": "@raze__serde_json__1_0_67//:serde_json",
build_file = Label("//cargo/remote:BUILD.cfg-if-1.0.0.bazel"),
)
+ maybe(
+ http_archive,
+ name = "raze__chrono__0_4_19",
+ url = "https://crates.io/api/v1/crates/chrono/0.4.19/download",
+ type = "tar.gz",
+ sha256 = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73",
+ strip_prefix = "chrono-0.4.19",
+ build_file = Label("//cargo/remote:BUILD.chrono-0.4.19.bazel"),
+ )
+
maybe(
http_archive,
name = "raze__cloudabi__0_0_3",
build_file = Label("//cargo/remote:BUILD.nats-0.10.1.bazel"),
)
+ maybe(
+ http_archive,
+ name = "raze__nats__0_15_2",
+ url = "https://crates.io/api/v1/crates/nats/0.15.2/download",
+ type = "tar.gz",
+ sha256 = "2a3097b182107db2cf690280d61f23f17ee31d49f3994ad152ee6a10261f77c3",
+ strip_prefix = "nats-0.15.2",
+ build_file = Label("//cargo/remote:BUILD.nats-0.15.2.bazel"),
+ )
+
maybe(
http_archive,
name = "raze__net2__0_2_37",
build_file = Label("//cargo/remote:BUILD.nuid-0.3.0.bazel"),
)
+ maybe(
+ http_archive,
+ name = "raze__num_integer__0_1_44",
+ url = "https://crates.io/api/v1/crates/num-integer/0.1.44/download",
+ type = "tar.gz",
+ sha256 = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db",
+ strip_prefix = "num-integer-0.1.44",
+ build_file = Label("//cargo/remote:BUILD.num-integer-0.1.44.bazel"),
+ )
+
maybe(
http_archive,
name = "raze__num_traits__0_1_43",
build_file = Label("//cargo/remote:BUILD.thiserror-impl-1.0.29.bazel"),
)
+ maybe(
+ http_archive,
+ name = "raze__time__0_1_44",
+ url = "https://crates.io/api/v1/crates/time/0.1.44/download",
+ type = "tar.gz",
+ sha256 = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255",
+ strip_prefix = "time-0.1.44",
+ build_file = Label("//cargo/remote:BUILD.time-0.1.44.bazel"),
+ )
+
maybe(
http_archive,
name = "raze__tinyvec__1_3_1",
maybe(
http_archive,
- name = "raze__wasi__0_10_2_wasi_snapshot_preview1",
- url = "https://crates.io/api/v1/crates/wasi/0.10.2+wasi-snapshot-preview1/download",
+ name = "raze__wasi__0_10_0_wasi_snapshot_preview1",
+ url = "https://crates.io/api/v1/crates/wasi/0.10.0+wasi-snapshot-preview1/download",
type = "tar.gz",
- sha256 = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6",
- strip_prefix = "wasi-0.10.2+wasi-snapshot-preview1",
- build_file = Label("//cargo/remote:BUILD.wasi-0.10.2+wasi-snapshot-preview1.bazel"),
+ sha256 = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f",
+ strip_prefix = "wasi-0.10.0+wasi-snapshot-preview1",
+ build_file = Label("//cargo/remote:BUILD.wasi-0.10.0+wasi-snapshot-preview1.bazel"),
)
maybe(
--- /dev/null
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # MIT from expression "MIT OR Apache-2.0"
+])
+
+# Generated Targets
+
+# Unsupported target "chrono" with type "bench" omitted
+
+# Unsupported target "serde" with type "bench" omitted
+
+rust_library(
+ name = "chrono",
+ srcs = glob(["**/*.rs"]),
+ aliases = {
+ },
+ crate_features = [
+ "clock",
+ "default",
+ "libc",
+ "oldtime",
+ "serde",
+ "std",
+ "time",
+ "winapi",
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2015",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.4.19",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__libc__0_2_101//:libc",
+ "@raze__num_integer__0_1_44//:num_integer",
+ "@raze__num_traits__0_2_14//:num_traits",
+ "@raze__serde__1_0_130//:serde",
+ "@raze__time__0_1_44//:time",
+ ] + selects.with_or({
+ # cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))
+ (
+ "@rules_rust//rust/platform:wasm32-unknown-unknown",
+ ): [
+ ],
+ "//conditions:default": [],
+ }) + selects.with_or({
+ # cfg(windows)
+ (
+ "@rules_rust//rust/platform:i686-pc-windows-msvc",
+ "@rules_rust//rust/platform:x86_64-pc-windows-msvc",
+ ): [
+ "@raze__winapi__0_3_9//:winapi",
+ ],
+ "//conditions:default": [],
+ }),
+)
+
+# Unsupported target "wasm" with type "test" omitted
(
"@rules_rust//rust/platform:wasm32-wasi",
): [
- "@raze__wasi__0_10_2_wasi_snapshot_preview1//:wasi",
+ "@raze__wasi__0_10_0_wasi_snapshot_preview1//:wasi",
],
"//conditions:default": [],
}) + selects.with_or({
--- /dev/null
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # Apache-2.0 from expression "Apache-2.0"
+])
+
+# Generated Targets
+
+# Unsupported target "nats_bench" with type "bench" omitted
+
+# Unsupported target "async_nats_bench" with type "example" omitted
+
+# Unsupported target "nats-box" with type "example" omitted
+
+# Unsupported target "nats_bench" with type "example" omitted
+
+# Unsupported target "serde-json" with type "example" omitted
+
+rust_library(
+ name = "nats",
+ srcs = glob(["**/*.rs"]),
+ aliases = {
+ },
+ crate_features = [
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.15.2",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__base64__0_13_0//:base64",
+ "@raze__base64_url__1_4_10//:base64_url",
+ "@raze__blocking__1_0_2//:blocking",
+ "@raze__chrono__0_4_19//:chrono",
+ "@raze__crossbeam_channel__0_5_1//:crossbeam_channel",
+ "@raze__fastrand__1_5_0//:fastrand",
+ "@raze__itoa__0_4_8//:itoa",
+ "@raze__json__0_12_4//:json",
+ "@raze__log__0_4_14//:log",
+ "@raze__memchr__2_4_1//:memchr",
+ "@raze__nkeys__0_1_0//:nkeys",
+ "@raze__nuid__0_3_0//:nuid",
+ "@raze__once_cell__1_8_0//:once_cell",
+ "@raze__parking_lot__0_11_2//:parking_lot",
+ "@raze__regex__1_5_4//:regex",
+ "@raze__rustls__0_19_1//:rustls",
+ "@raze__rustls_native_certs__0_5_0//:rustls_native_certs",
+ "@raze__serde__1_0_130//:serde",
+ "@raze__serde_json__1_0_67//:serde_json",
+ "@raze__webpki__0_21_4//:webpki",
+ ] + selects.with_or({
+ # cfg(unix)
+ (
+ "@rules_rust//rust/platform:aarch64-apple-darwin",
+ "@rules_rust//rust/platform:aarch64-apple-ios",
+ "@rules_rust//rust/platform:aarch64-linux-android",
+ "@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
+ "@rules_rust//rust/platform:arm-unknown-linux-gnueabi",
+ "@rules_rust//rust/platform:i686-apple-darwin",
+ "@rules_rust//rust/platform:i686-linux-android",
+ "@rules_rust//rust/platform:i686-unknown-freebsd",
+ "@rules_rust//rust/platform:i686-unknown-linux-gnu",
+ "@rules_rust//rust/platform:powerpc-unknown-linux-gnu",
+ "@rules_rust//rust/platform:s390x-unknown-linux-gnu",
+ "@rules_rust//rust/platform:x86_64-apple-darwin",
+ "@rules_rust//rust/platform:x86_64-apple-ios",
+ "@rules_rust//rust/platform:x86_64-linux-android",
+ "@rules_rust//rust/platform:x86_64-unknown-freebsd",
+ "@rules_rust//rust/platform:x86_64-unknown-linux-gnu",
+ ): [
+ "@raze__libc__0_2_101//:libc",
+ ],
+ "//conditions:default": [],
+ }) + selects.with_or({
+ # cfg(windows)
+ (
+ "@rules_rust//rust/platform:i686-pc-windows-msvc",
+ "@rules_rust//rust/platform:x86_64-pc-windows-msvc",
+ ): [
+ "@raze__winapi__0_3_9//:winapi",
+ ],
+ "//conditions:default": [],
+ }),
+)
+
+# Unsupported target "auth_nkey" with type "test" omitted
+
+# Unsupported target "auth_tls" with type "test" omitted
+
+# Unsupported target "auth_user_pass" with type "test" omitted
+
+# Unsupported target "connect" with type "test" omitted
+
+# Unsupported target "drop" with type "test" omitted
+
+# Unsupported target "jetstream" with type "test" omitted
+
+# Unsupported target "reconnection" with type "test" omitted
--- /dev/null
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # MIT from expression "MIT OR Apache-2.0"
+])
+
+# Generated Targets
+# buildifier: disable=out-of-order-load
+# buildifier: disable=load-on-top
+load(
+ "@rules_rust//cargo:cargo_build_script.bzl",
+ "cargo_build_script",
+)
+
+cargo_build_script(
+ name = "num_integer_build_script",
+ srcs = glob(["**/*.rs"]),
+ build_script_env = {
+ },
+ crate_features = [
+ ],
+ crate_root = "build.rs",
+ data = glob(["**"]),
+ edition = "2015",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.1.44",
+ visibility = ["//visibility:private"],
+ deps = [
+ "@raze__autocfg__1_0_1//:autocfg",
+ ],
+)
+
+# Unsupported target "average" with type "bench" omitted
+
+# Unsupported target "gcd" with type "bench" omitted
+
+# Unsupported target "roots" with type "bench" omitted
+
+rust_library(
+ name = "num_integer",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2015",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.1.44",
+ # buildifier: leave-alone
+ deps = [
+ ":num_integer_build_script",
+ "@raze__num_traits__0_2_14//:num_traits",
+ ],
+)
+
+# Unsupported target "average" with type "test" omitted
+
+# Unsupported target "roots" with type "test" omitted
--- /dev/null
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # MIT from expression "MIT OR Apache-2.0"
+])
+
+# Generated Targets
+
+rust_library(
+ name = "time",
+ srcs = glob(["**/*.rs"]),
+ aliases = {
+ },
+ crate_features = [
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2015",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.1.44",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__libc__0_2_101//:libc",
+ ] + selects.with_or({
+ # cfg(target_os = "wasi")
+ (
+ "@rules_rust//rust/platform:wasm32-wasi",
+ ): [
+ "@raze__wasi__0_10_0_wasi_snapshot_preview1//:wasi",
+ ],
+ "//conditions:default": [],
+ }) + selects.with_or({
+ # cfg(windows)
+ (
+ "@rules_rust//rust/platform:i686-pc-windows-msvc",
+ "@rules_rust//rust/platform:x86_64-pc-windows-msvc",
+ ): [
+ "@raze__winapi__0_3_9//:winapi",
+ ],
+ "//conditions:default": [],
+ }),
+)
--- /dev/null
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # Apache-2.0 from expression "Apache-2.0 OR (Apache-2.0 OR MIT)"
+])
+
+# Generated Targets
+
+rust_library(
+ name = "wasi",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ "default",
+ "std",
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.10.0+wasi-snapshot-preview1",
+ # buildifier: leave-alone
+ deps = [
+ ],
+)
+++ /dev/null
-"""
-@generated
-cargo-raze crate build file.
-
-DO NOT EDIT! Replaced on runs of cargo-raze
-"""
-
-# buildifier: disable=load
-load("@bazel_skylib//lib:selects.bzl", "selects")
-
-# buildifier: disable=load
-load(
- "@rules_rust//rust:rust.bzl",
- "rust_binary",
- "rust_library",
- "rust_test",
-)
-
-package(default_visibility = [
- # Public for visibility by "@raze__crate__version//" targets.
- #
- # Prefer access through "//cargo", which limits external
- # visibility to explicit Cargo.toml dependencies.
- "//visibility:public",
-])
-
-licenses([
- "notice", # Apache-2.0 from expression "Apache-2.0 OR (Apache-2.0 OR MIT)"
-])
-
-# Generated Targets
-
-rust_library(
- name = "wasi",
- srcs = glob(["**/*.rs"]),
- crate_features = [
- "default",
- "std",
- ],
- crate_root = "src/lib.rs",
- crate_type = "lib",
- data = [],
- edition = "2018",
- rustc_flags = [
- "--cap-lints=allow",
- ],
- tags = [
- "cargo-raze",
- "manual",
- ],
- version = "0.10.2+wasi-snapshot-preview1",
- # buildifier: leave-alone
- deps = [
- ],
-)
"ntsecapi",
"ntstatus",
"processenv",
+ "profileapi",
"schannel",
"securitybaseapi",
"sspi",
"ntsecapi",
"ntstatus",
"processenv",
+ "profileapi",
"schannel",
"securitybaseapi",
"sspi",
ports:
- "8222:8222"
- "4222:4222"
- hostname: nats-server
- registry:
- restart: always
- image: registry:2
- ports:
- - 5000:5000
\ No newline at end of file
+ hostname: nats-server
\ No newline at end of file
pretty_env_logger = "0.4"
serde_json = { version = "1.0" }
common = { path = "../common/rust" }
+nats = "0.15.2"
[[bin]]
name = "webhook"
],
)
+alias(
+ name = "nats",
+ actual = "@raze__nats__0_15_2//:nats",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
+
alias(
name = "pretty_env_logger",
actual = "@raze__pretty_env_logger__0_4_0//:pretty_env_logger",
port: 8000\r
discord:\r
client_id: 738817757650485300\r
- public_key: "475bed67e20fb1e2d9b9007607f08d7b25b5a0aa936ef2d4ddaf7d592c993860"\r
+ public_key: "2dc5873bb9e603dbf70e6abc217768b9d7dfacef9e74ddaefcca6a9aed41f30d"\r
\r
use std::task::{Context, Poll};\r
use serde::{Deserialize, Serialize};\r
use crate::config::Config;\r
+use nats::{Connection, connect};\r
\r
pub fn validate_signature(b64_public_key: &str, data: &Vec<u8>, b64_signature: &str) -> bool {\r
// First, we need to check if the signature & private key is valid base64.\r
\r
pub struct HandlerService {\r
pub config: Config,\r
+ pub nats: Box<Connection>\r
}\r
\r
#[derive(Debug, Serialize, Deserialize)]\r
fn call(&mut self, req: Request<Body>) -> Self::Future {\r
if req.method() == Method::POST {\r
let public_key = self.config.discord.public_key.clone();\r
+ let nats = self.nats.clone();\r
return Box::pin(async move {\r
let headers = req.headers().clone();\r
if let Some((signature, timestamp)) = get_signature(&headers) {\r
let contatenated_data = [timestamp.as_bytes().to_vec(), data.to_vec()].concat();\r
\r
if validate_signature(public_key.as_str(), &contatenated_data, signature) {\r
- let data: Value = serde_json::from_str(from_utf8(&data).unwrap()).unwrap();\r
- let t = data.get("type").unwrap().as_i64().unwrap();\r
+ let d: Value = serde_json::from_str(from_utf8(&data).unwrap()).unwrap();\r
+ let t = d.get("type").unwrap().as_i64().unwrap();\r
\r
if t == 1 {\r
- info!("success!");\r
-\r
return Ok(Response::builder().header("Content-Type", "application/json").body(serde_json::to_string(&Ping {\r
t: 1\r
}).unwrap().into()).unwrap());\r
- \r
} else {\r
- Ok(Response::builder().status(StatusCode::UNAUTHORIZED).body("invalid operation".into()).unwrap())\r
+ info!("Handled event");\r
+ nats.publish(&format!("nova.dispatch.interaction_raw"), data).unwrap();\r
+ return Ok(Response::builder().header("Content-Type", "application/json").body(serde_json::to_string(&Ping {\r
+ t: 5\r
+ }).unwrap().into()).unwrap());\r
}\r
} else {\r
Ok(Response::builder().status(StatusCode::UNAUTHORIZED).body("signature verification failed".into()).unwrap())\r
\r
pub struct MakeSvc {\r
pub settings: Config,\r
+ pub nats: Box<Connection>,\r
}\r
\r
impl<T> Service<T> for MakeSvc {\r
fn call(&mut self, _: T) -> Self::Future {\r
future::ready(Ok(HandlerService {\r
config: self.settings.clone(),\r
+ nats: self.nats.clone(),\r
}))\r
}\r
}\r
"Starting server on {}:{}",\r
settings.config.server.address, settings.config.server.port\r
);\r
+ let nats = Box::new(nats::connect("localhost").unwrap());\r
let server = Server::bind(&addr).serve(MakeSvc {\r
settings: settings.config.clone(),\r
+ nats\r
});\r
\r
if let Err(e) = server.await {\r