summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu <matthieu@developershouse.xyz>2021-11-05 19:04:58 +0400
committerMatthieu <matthieu@developershouse.xyz>2021-11-05 19:04:58 +0400
commit7ddb5d3820c15ce4202e6f43057310a9fbb7178a (patch)
treee61f4fd5bd6c515a5317adf8c8cbb10a362d91ff
parentb73f3c90ec2a491d59275818e3f61826471452ba (diff)
use twilight for deserialization and gateway
-rw-r--r--Cargo.lock230
-rw-r--r--cargo/crates.bzl202
-rw-r--r--cargo/remote/BUILD.ct-logs-0.8.0.bazel54
-rw-r--r--cargo/remote/BUILD.flate2-1.0.22.bazel4
-rw-r--r--cargo/remote/BUILD.hyper-rustls-0.22.1.bazel72
-rw-r--r--cargo/remote/BUILD.input_buffer-0.4.0.bazel (renamed from cargo/remote/BUILD.num-complex-0.4.0.bazel)7
-rw-r--r--cargo/remote/BUILD.libz-sys-1.1.3.bazel (renamed from cargo/remote/BUILD.num-iter-0.1.42.bazel)43
-rw-r--r--cargo/remote/BUILD.num-bigint-0.4.2.bazel112
-rw-r--r--cargo/remote/BUILD.num-integer-0.1.44.bazel4
-rw-r--r--cargo/remote/BUILD.num-rational-0.4.0.bazel93
-rw-r--r--cargo/remote/BUILD.num-traits-0.2.14.bazel2
-rw-r--r--cargo/remote/BUILD.ordered-float-2.8.0.bazel (renamed from cargo/remote/BUILD.num-0.4.0.bazel)14
-rw-r--r--cargo/remote/BUILD.serde-value-0.7.0.bazel55
-rw-r--r--cargo/remote/BUILD.tokio-tungstenite-0.14.0.bazel (renamed from cargo/remote/BUILD.tokio-tungstenite-0.15.0.bazel)5
-rw-r--r--cargo/remote/BUILD.tracing-0.1.29.bazel5
-rw-r--r--cargo/remote/BUILD.tracing-attributes-0.1.18.bazel (renamed from cargo/remote/BUILD.num-derive-0.3.3.bazel)24
-rw-r--r--cargo/remote/BUILD.tungstenite-0.13.0.bazel (renamed from cargo/remote/BUILD.tungstenite-0.14.0.bazel)9
-rw-r--r--cargo/remote/BUILD.twilight-gateway-0.6.5.bazel72
-rw-r--r--cargo/remote/BUILD.twilight-gateway-queue-0.6.0.bazel57
-rw-r--r--cargo/remote/BUILD.twilight-http-0.6.6.bazel65
-rw-r--r--cargo/remote/BUILD.twilight-model-0.6.5.bazel62
-rw-r--r--common/rust/Cargo.toml2
-rw-r--r--common/rust/cargo/BUILD.bazel18
-rw-r--r--common/rust/src/discord_models/application.rs38
-rw-r--r--common/rust/src/discord_models/audit_log.rs214
-rw-r--r--common/rust/src/discord_models/channel.rs341
-rw-r--r--common/rust/src/discord_models/emoji.rs15
-rw-r--r--common/rust/src/discord_models/gateway.rs124
-rw-r--r--common/rust/src/discord_models/guild.rs255
-rw-r--r--common/rust/src/discord_models/guild_template.rs18
-rw-r--r--common/rust/src/discord_models/invite.rs48
-rw-r--r--common/rust/src/discord_models/message_components.rs75
-rw-r--r--common/rust/src/discord_models/mod.rs16
-rw-r--r--common/rust/src/discord_models/permissions.rs21
-rw-r--r--common/rust/src/discord_models/slash_commands.rs104
-rw-r--r--common/rust/src/discord_models/stage_instance.rs19
-rw-r--r--common/rust/src/discord_models/teams.rs28
-rw-r--r--common/rust/src/discord_models/user.rs73
-rw-r--r--common/rust/src/discord_models/voice.rs30
-rw-r--r--common/rust/src/discord_models/webhook.rs29
-rw-r--r--common/rust/src/lib.rs2
-rw-r--r--common/rust/src/payloads.rs259
-rw-r--r--common/rust/src/serializable_event.rs165
-rw-r--r--gateway/BUILD4
-rw-r--r--gateway/Cargo.toml18
-rw-r--r--gateway/cargo/BUILD.bazel67
-rw-r--r--gateway/src/config.rs14
-rw-r--r--gateway/src/connection/mod.rs36
-rw-r--r--gateway/src/connection/stream.rs99
-rw-r--r--gateway/src/connection/utils.rs42
-rw-r--r--gateway/src/error.rs22
-rw-r--r--gateway/src/main.rs69
-rw-r--r--gateway/src/payloads/dispatch.rs46
-rw-r--r--gateway/src/payloads/events/mod.rs1
-rw-r--r--gateway/src/payloads/events/ready.rs13
-rw-r--r--gateway/src/payloads/gateway.rs78
-rw-r--r--gateway/src/payloads/mod.rs4
-rw-r--r--gateway/src/payloads/opcodes/hello.rs8
-rw-r--r--gateway/src/payloads/opcodes/identify.rs47
-rw-r--r--gateway/src/payloads/opcodes/mod.rs22
-rw-r--r--gateway/src/payloads/opcodes/presence.rs63
-rw-r--r--gateway/src/payloads/opcodes/resume.rs8
-rw-r--r--gateway/src/shard/actions.rs132
-rw-r--r--gateway/src/shard/connection.rs193
-rw-r--r--gateway/src/shard/mod.rs49
-rw-r--r--gateway/src/shard/state.rs35
-rw-r--r--gateway/src/utils.rs8
-rw-r--r--webhook/Cargo.toml1
-rw-r--r--webhook/cargo/BUILD.bazel9
-rw-r--r--webhook/src/handler/error.rs14
-rw-r--r--webhook/src/handler/handler.rs84
-rw-r--r--webhook/src/handler/tests/handler_integration.rs35
72 files changed, 1135 insertions, 3171 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d68741b..f7454bb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -213,9 +213,11 @@ dependencies = [
"prometheus",
"redis",
"serde 1.0.130",
+ "serde_json",
"serde_repr",
"testcontainers",
"tokio",
+ "twilight-model",
]
[[package]]
@@ -314,6 +316,15 @@ dependencies = [
]
[[package]]
+name = "ct-logs"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8"
+dependencies = [
+ "sct",
+]
+
+[[package]]
name = "ctor"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -438,6 +449,7 @@ dependencies = [
"cfg-if",
"crc32fast",
"libc",
+ "libz-sys",
"miniz_oxide",
]
@@ -586,18 +598,11 @@ name = "gateway"
version = "0.1.0"
dependencies = [
"common",
- "enumflags2",
"futures",
- "futures-util",
- "num",
- "num-derive",
- "num-traits 0.2.14",
"serde 1.0.130",
"serde_json",
- "serde_repr",
"tokio",
- "tokio-tungstenite",
- "url",
+ "twilight-gateway",
]
[[package]]
@@ -750,6 +755,23 @@ dependencies = [
]
[[package]]
+name = "hyper-rustls"
+version = "0.22.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64"
+dependencies = [
+ "ct-logs",
+ "futures-util",
+ "hyper",
+ "log",
+ "rustls",
+ "rustls-native-certs",
+ "tokio",
+ "tokio-rustls",
+ "webpki",
+]
+
+[[package]]
name = "hyper-tls"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -784,6 +806,15 @@ dependencies = [
]
[[package]]
+name = "input_buffer"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413"
+dependencies = [
+ "bytes",
+]
+
+[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -839,6 +870,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce"
[[package]]
+name = "libz-sys"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66"
+dependencies = [
+ "cc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
name = "linked-hash-map"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1006,51 +1048,6 @@ dependencies = [
]
[[package]]
-name = "num"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
-dependencies = [
- "num-bigint",
- "num-complex",
- "num-integer",
- "num-iter",
- "num-rational",
- "num-traits 0.2.14",
-]
-
-[[package]]
-name = "num-bigint"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535"
-dependencies = [
- "autocfg",
- "num-integer",
- "num-traits 0.2.14",
-]
-
-[[package]]
-name = "num-complex"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
-dependencies = [
- "num-traits 0.2.14",
-]
-
-[[package]]
-name = "num-derive"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1061,29 +1058,6 @@ dependencies = [
]
[[package]]
-name = "num-iter"
-version = "0.1.42"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
-dependencies = [
- "autocfg",
- "num-integer",
- "num-traits 0.2.14",
-]
-
-[[package]]
-name = "num-rational"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
-dependencies = [
- "autocfg",
- "num-bigint",
- "num-integer",
- "num-traits 0.2.14",
-]
-
-[[package]]
name = "num-traits"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1157,6 +1131,15 @@ dependencies = [
]
[[package]]
+name = "ordered-float"
+version = "2.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97c9d06878b3a851e8026ef94bf7fef9ba93062cd412601da4d9cf369b1cc62d"
+dependencies = [
+ "num-traits 0.2.14",
+]
+
+[[package]]
name = "parking"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1603,6 +1586,16 @@ dependencies = [
]
[[package]]
+name = "serde-value"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
+dependencies = [
+ "ordered-float",
+ "serde 1.0.130",
+]
+
+[[package]]
name = "serde_derive"
version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1904,9 +1897,9 @@ dependencies = [
[[package]]
name = "tokio-tungstenite"
-version = "0.15.0"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8"
+checksum = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2"
dependencies = [
"futures-util",
"log",
@@ -1956,10 +1949,22 @@ checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
dependencies = [
"cfg-if",
"pin-project-lite",
+ "tracing-attributes",
"tracing-core",
]
[[package]]
+name = "tracing-attributes"
+version = "0.1.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "tracing-core"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1976,24 +1981,86 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "tungstenite"
-version = "0.14.0"
+version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5"
+checksum = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093"
dependencies = [
"base64",
"byteorder",
"bytes",
"http",
"httparse",
+ "input_buffer",
"log",
"rand 0.8.4",
"rustls",
- "rustls-native-certs",
"sha-1",
"thiserror",
"url",
"utf-8",
"webpki",
+ "webpki-roots",
+]
+
+[[package]]
+name = "twilight-gateway"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d0495761099f21c92050486717b3ccd8b3cd137626a511c0694d32edd92511b"
+dependencies = [
+ "bitflags",
+ "flate2",
+ "futures-util",
+ "once_cell",
+ "serde 1.0.130",
+ "serde_json",
+ "tokio",
+ "tokio-tungstenite",
+ "tracing",
+ "twilight-gateway-queue",
+ "twilight-http",
+ "twilight-model",
+ "url",
+]
+
+[[package]]
+name = "twilight-gateway-queue"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f45ea68d917d5fbbfe739be9ace81d6824518262feb7a9139552bab64811f5a"
+dependencies = [
+ "tokio",
+ "tracing",
+ "twilight-http",
+]
+
+[[package]]
+name = "twilight-http"
+version = "0.6.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08ef176da0d6a25e7f6b69d6efddacc215ac62313596047566726360ec6cf438"
+dependencies = [
+ "hyper",
+ "hyper-rustls",
+ "percent-encoding",
+ "rand 0.8.4",
+ "serde 1.0.130",
+ "serde_json",
+ "tokio",
+ "twilight-model",
+]
+
+[[package]]
+name = "twilight-model"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d7d27af7e29d24bdf4f7e2511b36cc571fb5613b5ca5726ca0da36f55d76668a"
+dependencies = [
+ "bitflags",
+ "serde 1.0.130",
+ "serde-value",
+ "serde_repr",
+ "tracing",
]
[[package]]
@@ -2166,6 +2233,7 @@ dependencies = [
"serde 1.0.130",
"serde_json",
"tokio",
+ "twilight-model",
]
[[package]]
diff --git a/cargo/crates.bzl b/cargo/crates.bzl
index 5d2dd87..1a9825d 100644
--- a/cargo/crates.bzl
+++ b/cargo/crates.bzl
@@ -21,6 +21,7 @@ _DEPENDENCIES = {
"serde": "@raze__serde__1_0_130//:serde",
"serde_json": "@raze__serde_json__1_0_68//:serde_json",
"tokio": "@raze__tokio__1_12_0//:tokio",
+ "twilight-model": "@raze__twilight_model__0_6_5//:twilight_model",
},
"common/rust": {
"config": "@raze__config__0_11_0//:config",
@@ -32,20 +33,17 @@ _DEPENDENCIES = {
"prometheus": "@raze__prometheus__0_12_0//:prometheus",
"redis": "@raze__redis__0_21_3//:redis",
"serde": "@raze__serde__1_0_130//:serde",
+ "serde_json": "@raze__serde_json__1_0_68//:serde_json",
"testcontainers": "@raze__testcontainers__0_12_0//:testcontainers",
"tokio": "@raze__tokio__1_12_0//:tokio",
+ "twilight-model": "@raze__twilight_model__0_6_5//:twilight_model",
},
"gateway": {
- "enumflags2": "@raze__enumflags2__0_7_1//:enumflags2",
"futures": "@raze__futures__0_3_17//:futures",
- "futures-util": "@raze__futures_util__0_3_17//:futures_util",
- "num": "@raze__num__0_4_0//:num",
- "num-traits": "@raze__num_traits__0_2_14//:num_traits",
"serde": "@raze__serde__1_0_130//:serde",
"serde_json": "@raze__serde_json__1_0_68//:serde_json",
"tokio": "@raze__tokio__1_12_0//:tokio",
- "tokio-tungstenite": "@raze__tokio_tungstenite__0_15_0//:tokio_tungstenite",
- "url": "@raze__url__2_2_2//:url",
+ "twilight-gateway": "@raze__twilight_gateway__0_6_5//:twilight_gateway",
},
"cache": {
"log": "@raze__log__0_4_14//:log",
@@ -77,8 +75,6 @@ _PROC_MACRO_DEPENDENCIES = {
"serde_repr": "@raze__serde_repr__0_1_7//:serde_repr",
},
"gateway": {
- "num-derive": "@raze__num_derive__0_3_3//:num_derive",
- "serde_repr": "@raze__serde_repr__0_1_7//:serde_repr",
},
"cache": {
},
@@ -587,6 +583,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__ct_logs__0_8_0",
+ url = "https://crates.io/api/v1/crates/ct-logs/0.8.0/download",
+ type = "tar.gz",
+ sha256 = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8",
+ strip_prefix = "ct-logs-0.8.0",
+ build_file = Label("//cargo/remote:BUILD.ct-logs-0.8.0.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__ctor__0_1_21",
url = "https://crates.io/api/v1/crates/ctor/0.1.21/download",
type = "tar.gz",
@@ -997,6 +1003,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__hyper_rustls__0_22_1",
+ url = "https://crates.io/api/v1/crates/hyper-rustls/0.22.1/download",
+ type = "tar.gz",
+ sha256 = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64",
+ strip_prefix = "hyper-rustls-0.22.1",
+ build_file = Label("//cargo/remote:BUILD.hyper-rustls-0.22.1.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__hyper_tls__0_5_0",
url = "https://crates.io/api/v1/crates/hyper-tls/0.5.0/download",
type = "tar.gz",
@@ -1027,6 +1043,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__input_buffer__0_4_0",
+ url = "https://crates.io/api/v1/crates/input_buffer/0.4.0/download",
+ type = "tar.gz",
+ sha256 = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413",
+ strip_prefix = "input_buffer-0.4.0",
+ build_file = Label("//cargo/remote:BUILD.input_buffer-0.4.0.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__instant__0_1_12",
url = "https://crates.io/api/v1/crates/instant/0.1.12/download",
type = "tar.gz",
@@ -1097,6 +1123,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__libz_sys__1_1_3",
+ url = "https://crates.io/api/v1/crates/libz-sys/1.1.3/download",
+ type = "tar.gz",
+ sha256 = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66",
+ strip_prefix = "libz-sys-1.1.3",
+ build_file = Label("//cargo/remote:BUILD.libz-sys-1.1.3.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__linked_hash_map__0_5_4",
url = "https://crates.io/api/v1/crates/linked-hash-map/0.5.4/download",
type = "tar.gz",
@@ -1237,46 +1273,6 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
- name = "raze__num__0_4_0",
- url = "https://crates.io/api/v1/crates/num/0.4.0/download",
- type = "tar.gz",
- sha256 = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606",
- strip_prefix = "num-0.4.0",
- build_file = Label("//cargo/remote:BUILD.num-0.4.0.bazel"),
- )
-
- maybe(
- http_archive,
- name = "raze__num_bigint__0_4_2",
- url = "https://crates.io/api/v1/crates/num-bigint/0.4.2/download",
- type = "tar.gz",
- sha256 = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535",
- strip_prefix = "num-bigint-0.4.2",
- build_file = Label("//cargo/remote:BUILD.num-bigint-0.4.2.bazel"),
- )
-
- maybe(
- http_archive,
- name = "raze__num_complex__0_4_0",
- url = "https://crates.io/api/v1/crates/num-complex/0.4.0/download",
- type = "tar.gz",
- sha256 = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085",
- strip_prefix = "num-complex-0.4.0",
- build_file = Label("//cargo/remote:BUILD.num-complex-0.4.0.bazel"),
- )
-
- maybe(
- http_archive,
- name = "raze__num_derive__0_3_3",
- url = "https://crates.io/api/v1/crates/num-derive/0.3.3/download",
- type = "tar.gz",
- sha256 = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d",
- strip_prefix = "num-derive-0.3.3",
- build_file = Label("//cargo/remote:BUILD.num-derive-0.3.3.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",
@@ -1287,26 +1283,6 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
- name = "raze__num_iter__0_1_42",
- url = "https://crates.io/api/v1/crates/num-iter/0.1.42/download",
- type = "tar.gz",
- sha256 = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59",
- strip_prefix = "num-iter-0.1.42",
- build_file = Label("//cargo/remote:BUILD.num-iter-0.1.42.bazel"),
- )
-
- maybe(
- http_archive,
- name = "raze__num_rational__0_4_0",
- url = "https://crates.io/api/v1/crates/num-rational/0.4.0/download",
- type = "tar.gz",
- sha256 = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a",
- strip_prefix = "num-rational-0.4.0",
- build_file = Label("//cargo/remote:BUILD.num-rational-0.4.0.bazel"),
- )
-
- maybe(
- http_archive,
name = "raze__num_traits__0_1_43",
url = "https://crates.io/api/v1/crates/num-traits/0.1.43/download",
type = "tar.gz",
@@ -1387,6 +1363,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__ordered_float__2_8_0",
+ url = "https://crates.io/api/v1/crates/ordered-float/2.8.0/download",
+ type = "tar.gz",
+ sha256 = "97c9d06878b3a851e8026ef94bf7fef9ba93062cd412601da4d9cf369b1cc62d",
+ strip_prefix = "ordered-float-2.8.0",
+ build_file = Label("//cargo/remote:BUILD.ordered-float-2.8.0.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__parking__2_0_0",
url = "https://crates.io/api/v1/crates/parking/2.0.0/download",
type = "tar.gz",
@@ -1837,6 +1823,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__serde_value__0_7_0",
+ url = "https://crates.io/api/v1/crates/serde-value/0.7.0/download",
+ type = "tar.gz",
+ sha256 = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c",
+ strip_prefix = "serde-value-0.7.0",
+ build_file = Label("//cargo/remote:BUILD.serde-value-0.7.0.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__serde_derive__1_0_130",
url = "https://crates.io/api/v1/crates/serde_derive/1.0.130/download",
type = "tar.gz",
@@ -2137,12 +2133,12 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
- name = "raze__tokio_tungstenite__0_15_0",
- url = "https://crates.io/api/v1/crates/tokio-tungstenite/0.15.0/download",
+ name = "raze__tokio_tungstenite__0_14_0",
+ url = "https://crates.io/api/v1/crates/tokio-tungstenite/0.14.0/download",
type = "tar.gz",
- sha256 = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8",
- strip_prefix = "tokio-tungstenite-0.15.0",
- build_file = Label("//cargo/remote:BUILD.tokio-tungstenite-0.15.0.bazel"),
+ sha256 = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2",
+ strip_prefix = "tokio-tungstenite-0.14.0",
+ build_file = Label("//cargo/remote:BUILD.tokio-tungstenite-0.14.0.bazel"),
)
maybe(
@@ -2187,6 +2183,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__tracing_attributes__0_1_18",
+ url = "https://crates.io/api/v1/crates/tracing-attributes/0.1.18/download",
+ type = "tar.gz",
+ sha256 = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e",
+ strip_prefix = "tracing-attributes-0.1.18",
+ build_file = Label("//cargo/remote:BUILD.tracing-attributes-0.1.18.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__tracing_core__0_1_21",
url = "https://crates.io/api/v1/crates/tracing-core/0.1.21/download",
type = "tar.gz",
@@ -2207,12 +2213,52 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
- name = "raze__tungstenite__0_14_0",
- url = "https://crates.io/api/v1/crates/tungstenite/0.14.0/download",
+ name = "raze__tungstenite__0_13_0",
+ url = "https://crates.io/api/v1/crates/tungstenite/0.13.0/download",
+ type = "tar.gz",
+ sha256 = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093",
+ strip_prefix = "tungstenite-0.13.0",
+ build_file = Label("//cargo/remote:BUILD.tungstenite-0.13.0.bazel"),
+ )
+
+ maybe(
+ http_archive,
+ name = "raze__twilight_gateway__0_6_5",
+ url = "https://crates.io/api/v1/crates/twilight-gateway/0.6.5/download",
+ type = "tar.gz",
+ sha256 = "3d0495761099f21c92050486717b3ccd8b3cd137626a511c0694d32edd92511b",
+ strip_prefix = "twilight-gateway-0.6.5",
+ build_file = Label("//cargo/remote:BUILD.twilight-gateway-0.6.5.bazel"),
+ )
+
+ maybe(
+ http_archive,
+ name = "raze__twilight_gateway_queue__0_6_0",
+ url = "https://crates.io/api/v1/crates/twilight-gateway-queue/0.6.0/download",
+ type = "tar.gz",
+ sha256 = "5f45ea68d917d5fbbfe739be9ace81d6824518262feb7a9139552bab64811f5a",
+ strip_prefix = "twilight-gateway-queue-0.6.0",
+ build_file = Label("//cargo/remote:BUILD.twilight-gateway-queue-0.6.0.bazel"),
+ )
+
+ maybe(
+ http_archive,
+ name = "raze__twilight_http__0_6_6",
+ url = "https://crates.io/api/v1/crates/twilight-http/0.6.6/download",
+ type = "tar.gz",
+ sha256 = "08ef176da0d6a25e7f6b69d6efddacc215ac62313596047566726360ec6cf438",
+ strip_prefix = "twilight-http-0.6.6",
+ build_file = Label("//cargo/remote:BUILD.twilight-http-0.6.6.bazel"),
+ )
+
+ maybe(
+ http_archive,
+ name = "raze__twilight_model__0_6_5",
+ url = "https://crates.io/api/v1/crates/twilight-model/0.6.5/download",
type = "tar.gz",
- sha256 = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5",
- strip_prefix = "tungstenite-0.14.0",
- build_file = Label("//cargo/remote:BUILD.tungstenite-0.14.0.bazel"),
+ sha256 = "d7d27af7e29d24bdf4f7e2511b36cc571fb5613b5ca5726ca0da36f55d76668a",
+ strip_prefix = "twilight-model-0.6.5",
+ build_file = Label("//cargo/remote:BUILD.twilight-model-0.6.5.bazel"),
)
maybe(
diff --git a/cargo/remote/BUILD.ct-logs-0.8.0.bazel b/cargo/remote/BUILD.ct-logs-0.8.0.bazel
new file mode 100644
index 0000000..4045ffa
--- /dev/null
+++ b/cargo/remote/BUILD.ct-logs-0.8.0.bazel
@@ -0,0 +1,54 @@
+"""
+@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 (ISC OR MIT)"
+])
+
+# Generated Targets
+
+rust_library(
+ name = "ct_logs",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.8.0",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__sct__0_6_1//:sct",
+ ],
+)
diff --git a/cargo/remote/BUILD.flate2-1.0.22.bazel b/cargo/remote/BUILD.flate2-1.0.22.bazel
index b90354e..dc36758 100644
--- a/cargo/remote/BUILD.flate2-1.0.22.bazel
+++ b/cargo/remote/BUILD.flate2-1.0.22.bazel
@@ -80,9 +80,12 @@ rust_library(
aliases = {
},
crate_features = [
+ "any_zlib",
"default",
+ "libz-sys",
"miniz_oxide",
"rust_backend",
+ "zlib",
],
crate_root = "src/lib.rs",
crate_type = "lib",
@@ -102,6 +105,7 @@ rust_library(
"@raze__cfg_if__1_0_0//:cfg_if",
"@raze__crc32fast__1_2_1//:crc32fast",
"@raze__libc__0_2_104//:libc",
+ "@raze__libz_sys__1_1_3//:libz_sys",
"@raze__miniz_oxide__0_4_4//:miniz_oxide",
] + selects.with_or({
# cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))
diff --git a/cargo/remote/BUILD.hyper-rustls-0.22.1.bazel b/cargo/remote/BUILD.hyper-rustls-0.22.1.bazel
new file mode 100644
index 0000000..fa0faf8
--- /dev/null
+++ b/cargo/remote/BUILD.hyper-rustls-0.22.1.bazel
@@ -0,0 +1,72 @@
+"""
+@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 (ISC OR MIT)"
+])
+
+# Generated Targets
+
+# Unsupported target "client" with type "example" omitted
+
+# Unsupported target "server" with type "example" omitted
+
+rust_library(
+ name = "hyper_rustls",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ "ct-logs",
+ "native-tokio",
+ "rustls-native-certs",
+ "tokio-runtime",
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.22.1",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__ct_logs__0_8_0//:ct_logs",
+ "@raze__futures_util__0_3_17//:futures_util",
+ "@raze__hyper__0_14_13//:hyper",
+ "@raze__log__0_4_14//:log",
+ "@raze__rustls__0_19_1//:rustls",
+ "@raze__rustls_native_certs__0_5_0//:rustls_native_certs",
+ "@raze__tokio__1_12_0//:tokio",
+ "@raze__tokio_rustls__0_22_0//:tokio_rustls",
+ "@raze__webpki__0_21_4//:webpki",
+ ],
+)
+
+# Unsupported target "tests" with type "test" omitted
diff --git a/cargo/remote/BUILD.num-complex-0.4.0.bazel b/cargo/remote/BUILD.input_buffer-0.4.0.bazel
index 4e32b7b..e59c53a 100644
--- a/cargo/remote/BUILD.num-complex-0.4.0.bazel
+++ b/cargo/remote/BUILD.input_buffer-0.4.0.bazel
@@ -31,15 +31,14 @@ licenses([
# Generated Targets
rust_library(
- name = "num_complex",
+ name = "input_buffer",
srcs = glob(["**/*.rs"]),
crate_features = [
- "std",
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
- edition = "2018",
+ edition = "2015",
rustc_flags = [
"--cap-lints=allow",
],
@@ -50,6 +49,6 @@ rust_library(
version = "0.4.0",
# buildifier: leave-alone
deps = [
- "@raze__num_traits__0_2_14//:num_traits",
+ "@raze__bytes__1_1_0//:bytes",
],
)
diff --git a/cargo/remote/BUILD.num-iter-0.1.42.bazel b/cargo/remote/BUILD.libz-sys-1.1.3.bazel
index ecf8946..459fa37 100644
--- a/cargo/remote/BUILD.num-iter-0.1.42.bazel
+++ b/cargo/remote/BUILD.libz-sys-1.1.3.bazel
@@ -37,17 +37,16 @@ load(
)
cargo_build_script(
- name = "num_iter_build_script",
+ name = "libz_sys_build_script",
srcs = glob(["**/*.rs"]),
build_script_env = {
},
crate_features = [
- "i128",
- "std",
],
crate_root = "build.rs",
data = glob(["**"]),
edition = "2015",
+ links = "z",
rustc_flags = [
"--cap-lints=allow",
],
@@ -55,19 +54,29 @@ cargo_build_script(
"cargo-raze",
"manual",
],
- version = "0.1.42",
+ version = "1.1.3",
visibility = ["//visibility:private"],
deps = [
- "@raze__autocfg__1_0_1//:autocfg",
- ],
+ "@raze__cc__1_0_71//:cc",
+ "@raze__pkg_config__0_3_20//:pkg_config",
+ ] + selects.with_or({
+ # cfg(target_env = "msvc")
+ (
+ "@rules_rust//rust/platform:i686-pc-windows-msvc",
+ "@rules_rust//rust/platform:x86_64-pc-windows-msvc",
+ ): [
+ "@raze__vcpkg__0_2_15//:vcpkg",
+ ],
+ "//conditions:default": [],
+ }),
)
rust_library(
- name = "num_iter",
+ name = "libz_sys",
srcs = glob(["**/*.rs"]),
+ aliases = {
+ },
crate_features = [
- "i128",
- "std",
],
crate_root = "src/lib.rs",
crate_type = "lib",
@@ -80,11 +89,17 @@ rust_library(
"cargo-raze",
"manual",
],
- version = "0.1.42",
+ version = "1.1.3",
# buildifier: leave-alone
deps = [
- ":num_iter_build_script",
- "@raze__num_integer__0_1_44//:num_integer",
- "@raze__num_traits__0_2_14//:num_traits",
- ],
+ ":libz_sys_build_script",
+ ] + selects.with_or({
+ # cfg(target_env = "msvc")
+ (
+ "@rules_rust//rust/platform:i686-pc-windows-msvc",
+ "@rules_rust//rust/platform:x86_64-pc-windows-msvc",
+ ): [
+ ],
+ "//conditions:default": [],
+ }),
)
diff --git a/cargo/remote/BUILD.num-bigint-0.4.2.bazel b/cargo/remote/BUILD.num-bigint-0.4.2.bazel
deleted file mode 100644
index eb2b157..0000000
--- a/cargo/remote/BUILD.num-bigint-0.4.2.bazel
+++ /dev/null
@@ -1,112 +0,0 @@
-"""
-@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_bigint_build_script",
- srcs = glob(["**/*.rs"]),
- build_script_env = {
- },
- crate_features = [
- "std",
- ],
- crate_root = "build.rs",
- data = glob(["**"]),
- edition = "2018",
- rustc_flags = [
- "--cap-lints=allow",
- ],
- tags = [
- "cargo-raze",
- "manual",
- ],
- version = "0.4.2",
- visibility = ["//visibility:private"],
- deps = [
- "@raze__autocfg__1_0_1//:autocfg",
- ],
-)
-
-# Unsupported target "bigint" with type "bench" omitted
-
-# Unsupported target "factorial" with type "bench" omitted
-
-# Unsupported target "gcd" with type "bench" omitted
-
-# Unsupported target "roots" with type "bench" omitted
-
-# Unsupported target "shootout-pidigits" with type "bench" omitted
-
-rust_library(
- name = "num_bigint",
- srcs = glob(["**/*.rs"]),
- crate_features = [
- "std",
- ],
- crate_root = "src/lib.rs",
- crate_type = "lib",
- data = [],
- edition = "2018",
- rustc_flags = [
- "--cap-lints=allow",
- ],
- tags = [
- "cargo-raze",
- "manual",
- ],
- version = "0.4.2",
- # buildifier: leave-alone
- deps = [
- ":num_bigint_build_script",
- "@raze__num_integer__0_1_44//:num_integer",
- "@raze__num_traits__0_2_14//:num_traits",
- ],
-)
-
-# Unsupported target "bigint" with type "test" omitted
-
-# Unsupported target "bigint_bitwise" with type "test" omitted
-
-# Unsupported target "bigint_scalar" with type "test" omitted
-
-# Unsupported target "biguint" with type "test" omitted
-
-# Unsupported target "biguint_scalar" with type "test" omitted
-
-# Unsupported target "modpow" with type "test" omitted
-
-# Unsupported target "roots" with type "test" omitted
diff --git a/cargo/remote/BUILD.num-integer-0.1.44.bazel b/cargo/remote/BUILD.num-integer-0.1.44.bazel
index 8f9a78e..51f2ad6 100644
--- a/cargo/remote/BUILD.num-integer-0.1.44.bazel
+++ b/cargo/remote/BUILD.num-integer-0.1.44.bazel
@@ -42,8 +42,6 @@ cargo_build_script(
build_script_env = {
},
crate_features = [
- "i128",
- "std",
],
crate_root = "build.rs",
data = glob(["**"]),
@@ -72,8 +70,6 @@ rust_library(
name = "num_integer",
srcs = glob(["**/*.rs"]),
crate_features = [
- "i128",
- "std",
],
crate_root = "src/lib.rs",
crate_type = "lib",
diff --git a/cargo/remote/BUILD.num-rational-0.4.0.bazel b/cargo/remote/BUILD.num-rational-0.4.0.bazel
deleted file mode 100644
index 6d9ef28..0000000
--- a/cargo/remote/BUILD.num-rational-0.4.0.bazel
+++ /dev/null
@@ -1,93 +0,0 @@
-"""
-@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_rational_build_script",
- srcs = glob(["**/*.rs"]),
- build_script_env = {
- },
- crate_features = [
- "num-bigint",
- "num-bigint-std",
- "std",
- ],
- crate_root = "build.rs",
- data = glob(["**"]),
- edition = "2018",
- rustc_flags = [
- "--cap-lints=allow",
- ],
- tags = [
- "cargo-raze",
- "manual",
- ],
- version = "0.4.0",
- visibility = ["//visibility:private"],
- deps = [
- "@raze__autocfg__1_0_1//:autocfg",
- ],
-)
-
-rust_library(
- name = "num_rational",
- srcs = glob(["**/*.rs"]),
- crate_features = [
- "num-bigint",
- "num-bigint-std",
- "std",
- ],
- crate_root = "src/lib.rs",
- crate_type = "lib",
- data = [],
- edition = "2018",
- rustc_flags = [
- "--cap-lints=allow",
- ],
- tags = [
- "cargo-raze",
- "manual",
- ],
- version = "0.4.0",
- # buildifier: leave-alone
- deps = [
- ":num_rational_build_script",
- "@raze__num_bigint__0_4_2//:num_bigint",
- "@raze__num_integer__0_1_44//:num_integer",
- "@raze__num_traits__0_2_14//:num_traits",
- ],
-)
diff --git a/cargo/remote/BUILD.num-traits-0.2.14.bazel b/cargo/remote/BUILD.num-traits-0.2.14.bazel
index dc9a697..1e6e653 100644
--- a/cargo/remote/BUILD.num-traits-0.2.14.bazel
+++ b/cargo/remote/BUILD.num-traits-0.2.14.bazel
@@ -43,7 +43,6 @@ cargo_build_script(
},
crate_features = [
"default",
- "i128",
"std",
],
crate_root = "build.rs",
@@ -68,7 +67,6 @@ rust_library(
srcs = glob(["**/*.rs"]),
crate_features = [
"default",
- "i128",
"std",
],
crate_root = "src/lib.rs",
diff --git a/cargo/remote/BUILD.num-0.4.0.bazel b/cargo/remote/BUILD.ordered-float-2.8.0.bazel
index 8409859..b64a3ae 100644
--- a/cargo/remote/BUILD.num-0.4.0.bazel
+++ b/cargo/remote/BUILD.ordered-float-2.8.0.bazel
@@ -25,17 +25,16 @@ package(default_visibility = [
])
licenses([
- "notice", # MIT from expression "MIT OR Apache-2.0"
+ "notice", # MIT from expression "MIT"
])
# Generated Targets
rust_library(
- name = "num",
+ name = "ordered_float",
srcs = glob(["**/*.rs"]),
crate_features = [
"default",
- "num-bigint",
"std",
],
crate_root = "src/lib.rs",
@@ -49,14 +48,11 @@ rust_library(
"cargo-raze",
"manual",
],
- version = "0.4.0",
+ version = "2.8.0",
# buildifier: leave-alone
deps = [
- "@raze__num_bigint__0_4_2//:num_bigint",
- "@raze__num_complex__0_4_0//:num_complex",
- "@raze__num_integer__0_1_44//:num_integer",
- "@raze__num_iter__0_1_42//:num_iter",
- "@raze__num_rational__0_4_0//:num_rational",
"@raze__num_traits__0_2_14//:num_traits",
],
)
+
+# Unsupported target "test" with type "test" omitted
diff --git a/cargo/remote/BUILD.serde-value-0.7.0.bazel b/cargo/remote/BUILD.serde-value-0.7.0.bazel
new file mode 100644
index 0000000..675a2d1
--- /dev/null
+++ b/cargo/remote/BUILD.serde-value-0.7.0.bazel
@@ -0,0 +1,55 @@
+"""
+@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"
+])
+
+# Generated Targets
+
+rust_library(
+ name = "serde_value",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.7.0",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__ordered_float__2_8_0//:ordered_float",
+ "@raze__serde__1_0_130//:serde",
+ ],
+)
diff --git a/cargo/remote/BUILD.tokio-tungstenite-0.15.0.bazel b/cargo/remote/BUILD.tokio-tungstenite-0.14.0.bazel
index d292afc..d8df4a4 100644
--- a/cargo/remote/BUILD.tokio-tungstenite-0.15.0.bazel
+++ b/cargo/remote/BUILD.tokio-tungstenite-0.14.0.bazel
@@ -47,7 +47,6 @@ rust_library(
srcs = glob(["**/*.rs"]),
crate_features = [
"connect",
- "default",
"rustls",
"rustls-tls",
"stream",
@@ -66,7 +65,7 @@ rust_library(
"cargo-raze",
"manual",
],
- version = "0.15.0",
+ version = "0.14.0",
# buildifier: leave-alone
deps = [
"@raze__futures_util__0_3_17//:futures_util",
@@ -75,7 +74,7 @@ rust_library(
"@raze__rustls__0_19_1//:rustls",
"@raze__tokio__1_12_0//:tokio",
"@raze__tokio_rustls__0_22_0//:tokio_rustls",
- "@raze__tungstenite__0_14_0//:tungstenite",
+ "@raze__tungstenite__0_13_0//:tungstenite",
"@raze__webpki__0_21_4//:webpki",
"@raze__webpki_roots__0_21_1//:webpki_roots",
],
diff --git a/cargo/remote/BUILD.tracing-0.1.29.bazel b/cargo/remote/BUILD.tracing-0.1.29.bazel
index e0ccc93..2573d6c 100644
--- a/cargo/remote/BUILD.tracing-0.1.29.bazel
+++ b/cargo/remote/BUILD.tracing-0.1.29.bazel
@@ -40,12 +40,17 @@ rust_library(
aliases = {
},
crate_features = [
+ "attributes",
"std",
+ "tracing-attributes",
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2018",
+ proc_macro_deps = [
+ "@raze__tracing_attributes__0_1_18//:tracing_attributes",
+ ],
rustc_flags = [
"--cap-lints=allow",
],
diff --git a/cargo/remote/BUILD.num-derive-0.3.3.bazel b/cargo/remote/BUILD.tracing-attributes-0.1.18.bazel
index cf86c8d..efdecca 100644
--- a/cargo/remote/BUILD.num-derive-0.3.3.bazel
+++ b/cargo/remote/BUILD.tracing-attributes-0.1.18.bazel
@@ -25,13 +25,13 @@ package(default_visibility = [
])
licenses([
- "notice", # MIT from expression "MIT OR Apache-2.0"
+ "notice", # MIT from expression "MIT"
])
# Generated Targets
rust_library(
- name = "num_derive",
+ name = "tracing_attributes",
srcs = glob(["**/*.rs"]),
crate_features = [
],
@@ -46,7 +46,7 @@ rust_library(
"cargo-raze",
"manual",
],
- version = "0.3.3",
+ version = "0.1.18",
# buildifier: leave-alone
deps = [
"@raze__proc_macro2__1_0_30//:proc_macro2",
@@ -55,20 +55,20 @@ rust_library(
],
)
-# Unsupported target "empty_enum" with type "test" omitted
+# Unsupported target "async_fn" with type "test" omitted
-# Unsupported target "issue-6" with type "test" omitted
+# Unsupported target "destructuring" with type "test" omitted
-# Unsupported target "issue-9" with type "test" omitted
+# Unsupported target "err" with type "test" omitted
-# Unsupported target "newtype" with type "test" omitted
+# Unsupported target "fields" with type "test" omitted
-# Unsupported target "newtype-2015" with type "test" omitted
+# Unsupported target "instrument" with type "test" omitted
-# Unsupported target "num_derive_without_num" with type "test" omitted
+# Unsupported target "levels" with type "test" omitted
-# Unsupported target "trivial" with type "test" omitted
+# Unsupported target "names" with type "test" omitted
-# Unsupported target "trivial-2015" with type "test" omitted
+# Unsupported target "support" with type "test" omitted
-# Unsupported target "with_custom_values" with type "test" omitted
+# Unsupported target "targets" with type "test" omitted
diff --git a/cargo/remote/BUILD.tungstenite-0.14.0.bazel b/cargo/remote/BUILD.tungstenite-0.13.0.bazel
index 55a7335..9292f39 100644
--- a/cargo/remote/BUILD.tungstenite-0.14.0.bazel
+++ b/cargo/remote/BUILD.tungstenite-0.13.0.bazel
@@ -30,8 +30,6 @@ licenses([
# Generated Targets
-# Unsupported target "buffer" with type "bench" omitted
-
# Unsupported target "autobahn-client" with type "example" omitted
# Unsupported target "autobahn-server" with type "example" omitted
@@ -49,9 +47,9 @@ rust_library(
srcs = glob(["**/*.rs"]),
crate_features = [
"rustls",
- "rustls-native-certs",
"rustls-tls",
"webpki",
+ "webpki-roots",
],
crate_root = "src/lib.rs",
crate_type = "lib",
@@ -64,7 +62,7 @@ rust_library(
"cargo-raze",
"manual",
],
- version = "0.14.0",
+ version = "0.13.0",
# buildifier: leave-alone
deps = [
"@raze__base64__0_13_0//:base64",
@@ -72,15 +70,16 @@ rust_library(
"@raze__bytes__1_1_0//:bytes",
"@raze__http__0_2_5//:http",
"@raze__httparse__1_5_1//:httparse",
+ "@raze__input_buffer__0_4_0//:input_buffer",
"@raze__log__0_4_14//:log",
"@raze__rand__0_8_4//:rand",
"@raze__rustls__0_19_1//:rustls",
- "@raze__rustls_native_certs__0_5_0//:rustls_native_certs",
"@raze__sha_1__0_9_8//:sha_1",
"@raze__thiserror__1_0_30//:thiserror",
"@raze__url__2_2_2//:url",
"@raze__utf_8__0_7_6//:utf_8",
"@raze__webpki__0_21_4//:webpki",
+ "@raze__webpki_roots__0_21_1//:webpki_roots",
],
)
diff --git a/cargo/remote/BUILD.twilight-gateway-0.6.5.bazel b/cargo/remote/BUILD.twilight-gateway-0.6.5.bazel
new file mode 100644
index 0000000..aace272
--- /dev/null
+++ b/cargo/remote/BUILD.twilight-gateway-0.6.5.bazel
@@ -0,0 +1,72 @@
+"""
+@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", # ISC from expression "ISC"
+])
+
+# Generated Targets
+
+rust_library(
+ name = "twilight_gateway",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ "compression",
+ "default",
+ "flate2",
+ "rustls",
+ "rustls-native-roots",
+ "tracing",
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.6.5",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__bitflags__1_3_2//:bitflags",
+ "@raze__flate2__1_0_22//:flate2",
+ "@raze__futures_util__0_3_17//:futures_util",
+ "@raze__once_cell__1_8_0//:once_cell",
+ "@raze__serde__1_0_130//:serde",
+ "@raze__serde_json__1_0_68//:serde_json",
+ "@raze__tokio__1_12_0//:tokio",
+ "@raze__tokio_tungstenite__0_14_0//:tokio_tungstenite",
+ "@raze__tracing__0_1_29//:tracing",
+ "@raze__twilight_gateway_queue__0_6_0//:twilight_gateway_queue",
+ "@raze__twilight_http__0_6_6//:twilight_http",
+ "@raze__twilight_model__0_6_5//:twilight_model",
+ "@raze__url__2_2_2//:url",
+ ],
+)
diff --git a/cargo/remote/BUILD.twilight-gateway-queue-0.6.0.bazel b/cargo/remote/BUILD.twilight-gateway-queue-0.6.0.bazel
new file mode 100644
index 0000000..7840285
--- /dev/null
+++ b/cargo/remote/BUILD.twilight-gateway-queue-0.6.0.bazel
@@ -0,0 +1,57 @@
+"""
+@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", # ISC from expression "ISC"
+])
+
+# Generated Targets
+
+rust_library(
+ name = "twilight_gateway_queue",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ "rustls-native-roots",
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.6.0",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__tokio__1_12_0//:tokio",
+ "@raze__tracing__0_1_29//:tracing",
+ "@raze__twilight_http__0_6_6//:twilight_http",
+ ],
+)
diff --git a/cargo/remote/BUILD.twilight-http-0.6.6.bazel b/cargo/remote/BUILD.twilight-http-0.6.6.bazel
new file mode 100644
index 0000000..05391e8
--- /dev/null
+++ b/cargo/remote/BUILD.twilight-http-0.6.6.bazel
@@ -0,0 +1,65 @@
+"""
+@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", # ISC from expression "ISC"
+])
+
+# Generated Targets
+
+# Unsupported target "application_command_permissions" with type "bench" omitted
+
+rust_library(
+ name = "twilight_http",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ "hyper-rustls",
+ "rustls-native-roots",
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.6.6",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__hyper__0_14_13//:hyper",
+ "@raze__hyper_rustls__0_22_1//:hyper_rustls",
+ "@raze__percent_encoding__2_1_0//:percent_encoding",
+ "@raze__rand__0_8_4//:rand",
+ "@raze__serde__1_0_130//:serde",
+ "@raze__serde_json__1_0_68//:serde_json",
+ "@raze__tokio__1_12_0//:tokio",
+ "@raze__twilight_model__0_6_5//:twilight_model",
+ ],
+)
diff --git a/cargo/remote/BUILD.twilight-model-0.6.5.bazel b/cargo/remote/BUILD.twilight-model-0.6.5.bazel
new file mode 100644
index 0000000..dbadd52
--- /dev/null
+++ b/cargo/remote/BUILD.twilight-model-0.6.5.bazel
@@ -0,0 +1,62 @@
+"""
+@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", # ISC from expression "ISC"
+])
+
+# Generated Targets
+
+# Unsupported target "deserialization" with type "bench" omitted
+
+rust_library(
+ name = "twilight_model",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ proc_macro_deps = [
+ "@raze__serde_repr__0_1_7//:serde_repr",
+ ],
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.6.5",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__bitflags__1_3_2//:bitflags",
+ "@raze__serde__1_0_130//:serde",
+ "@raze__serde_value__0_7_0//:serde_value",
+ "@raze__tracing__0_1_29//:tracing",
+ ],
+)
diff --git a/common/rust/Cargo.toml b/common/rust/Cargo.toml
index 234f1b1..07f9dd3 100644
--- a/common/rust/Cargo.toml
+++ b/common/rust/Cargo.toml
@@ -15,6 +15,8 @@ enumflags2 = { version = "0.7.1", features = ["serde"] }
prometheus = { version = "0.12.0", features = ["process"] }
nats = "0.15.2"
testcontainers = "0.12.0"
+twilight-model = { version = "0.6" }
+serde_json = { version = "1.0" }
[dependencies.redis]
version = "*"
diff --git a/common/rust/cargo/BUILD.bazel b/common/rust/cargo/BUILD.bazel
index f3778e2..387da21 100644
--- a/common/rust/cargo/BUILD.bazel
+++ b/common/rust/cargo/BUILD.bazel
@@ -94,6 +94,15 @@ alias(
)
alias(
+ name = "serde_json",
+ actual = "@raze__serde_json__1_0_68//:serde_json",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
+
+alias(
name = "serde_repr",
actual = "@raze__serde_repr__0_1_7//:serde_repr",
tags = [
@@ -119,3 +128,12 @@ alias(
"manual",
],
)
+
+alias(
+ name = "twilight_model",
+ actual = "@raze__twilight_model__0_6_5//:twilight_model",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
diff --git a/common/rust/src/discord_models/application.rs b/common/rust/src/discord_models/application.rs
deleted file mode 100644
index 65707d2..0000000
--- a/common/rust/src/discord_models/application.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-use enumflags2::{bitflags, BitFlags};
-use serde::{Deserialize, Serialize};
-
-use super::{teams::Team, user::User};
-
-#[bitflags]
-#[repr(u64)]
-#[derive(Debug, Clone, Copy)]
-pub enum ApplicationFlags {
- GatewayPresence = 1 << 12,
- GatewayPresenceLimit = 1 << 13,
- GatewayGuildMembers = 1 << 14,
- GatewayGuildMembersLimited = 1 << 15,
- VerificationPendingGuildLimit = 1 << 16,
- Embedded = 1 << 17,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Application {
- pub id: String,
- pub name: String,
- pub icon: Option<String>,
- pub description: String,
- pub rpc_origins: Option<Vec<String>>,
- pub bot_public: bool,
- pub bot_require_code_grant: bool,
- pub terms_of_service_url: Option<String>,
- pub privacy_policy_url: Option<String>,
- pub owner: Option<User>,
- pub summary: String,
- pub verify_key: String,
- pub team: Option<Team>,
- pub guild_id: Option<String>,
- pub primary_sku_id: Option<String>,
- pub slug: Option<String>,
- pub cover_image: Option<String>,
- pub flags: Option<BitFlags<ApplicationFlags>>,
-}
diff --git a/common/rust/src/discord_models/audit_log.rs b/common/rust/src/discord_models/audit_log.rs
deleted file mode 100644
index f223a2f..0000000
--- a/common/rust/src/discord_models/audit_log.rs
+++ /dev/null
@@ -1,214 +0,0 @@
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-use crate::discord_models::channel::Channel;
-
-use super::{guild::Integration, user::User, webhook::Webhook};
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum AuditLogEvents {
- GuildUpdate = 1,
- ChannelCreate = 10,
- ChannelUpdate = 11,
- ChannelDelete = 12,
- ChannelOverwriteCreate = 13,
- ChannelOverwriteUpdate = 14,
- ChannelOverwriteDelete = 15,
- MemberKick = 20,
- MemberPrune = 21,
- MemberBanAdd = 22,
- MemberBanRemove = 23,
- MemberUpdate = 24,
- MemberRoleUpdate = 25,
- MemberMove = 26,
- MemberDisconnect = 27,
- BotAdd = 28,
- RoleCreate = 30,
- RoleUpdate = 31,
- RoleDelete = 32,
- InviteCreate = 40,
- InviteUpdate = 41,
- InviteDelete = 42,
- WebhookCreate = 50,
- WebhookUpdate = 51,
- WebhookDelete = 52,
- EmojiCreate = 60,
- EmojiUpdate = 61,
- EmojiDelete = 62,
- MessageDelete = 72,
- MessageBulkDelete = 73,
- MessagePin = 74,
- MessageUnpin = 75,
- IntegrationCreate = 80,
- IntegrationUpdate = 81,
- IntegrationDelete = 82,
- StageInstanceCreate = 83,
- StageInstanceUpdate = 84,
- StageInstanceDelete = 85,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub enum OptionalAuditEntryInfoType {
- #[serde(rename = "0")]
- Role,
- #[serde(rename = "1")]
- Member,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct OptionalAuditEntryInfo {
- pub delete_member_days: Option<String>,
- pub members_removed: Option<String>,
- pub channel_id: Option<String>,
- pub message_id: Option<String>,
- pub count: Option<String>,
- pub id: Option<String>,
- #[serde(rename = "type")]
- pub type_: Option<Box<OptionalAuditEntryInfo>>,
- pub role_name: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub enum AuditLogChangeKey {
- #[serde(rename = "name")]
- Name,
- #[serde(rename = "description")]
- Description,
- #[serde(rename = "icon_hash")]
- IconHash,
- #[serde(rename = "splash_hash")]
- SplashHash,
- #[serde(rename = "discovery_splash_hash")]
- DiscoverySplashHash,
- #[serde(rename = "banner_hash")]
- BannerHash,
- #[serde(rename = "owner_id")]
- OwnerId,
- #[serde(rename = "region")]
- Region,
- #[serde(rename = "preferred_locale")]
- PreferredLocale,
- #[serde(rename = "afk_channel_id")]
- AfkChannelId,
- #[serde(rename = "afk_timeout")]
- AfkTimeout,
- #[serde(rename = "rules_channel_id")]
- RulesChannelId,
- #[serde(rename = "public_updates_channel_id")]
- PublicUpdatesChannelId,
- #[serde(rename = "mfa_level")]
- MfaLevel,
- #[serde(rename = "verification_level")]
- VerificationLevel,
- #[serde(rename = "explicit_content_filter")]
- ExplicitContentFilter,
- #[serde(rename = "default_message_notifications")]
- DefaultMessageNotifications,
- #[serde(rename = "vanity_url_code")]
- VanityUrlCode,
- #[serde(rename = "$add")]
- Add,
- #[serde(rename = "$remove")]
- Remove,
- #[serde(rename = "prune_delete_days")]
- PruneDeleteDays,
- #[serde(rename = "widget_enabled")]
- WidgetEnabled,
- #[serde(rename = "widget_channel_id")]
- WidgetChannelId,
- #[serde(rename = "system_channel_id")]
- SystemChannelId,
- #[serde(rename = "position")]
- Position,
- #[serde(rename = "topic")]
- Topic,
- #[serde(rename = "bitrate")]
- Bitrate,
- #[serde(rename = "permission_overwrites")]
- PermissionOverwrites,
- #[serde(rename = "nsfw")]
- Nsfw,
- #[serde(rename = "application_id")]
- ApplicationId,
- #[serde(rename = "rate_limit_per_user")]
- RateLimitPerUser,
- #[serde(rename = "permissions")]
- Permissions,
- #[serde(rename = "color")]
- Color,
- #[serde(rename = "hoist")]
- Hoist,
- #[serde(rename = "mentionable")]
- Mentionable,
- #[serde(rename = "allow")]
- Allow,
- #[serde(rename = "deny")]
- Deny,
- #[serde(rename = "code")]
- Code,
- #[serde(rename = "channel_id")]
- ChannelId,
- #[serde(rename = "inviter_id")]
- InviterId,
- #[serde(rename = "max_uses")]
- MaxUses,
- #[serde(rename = "uses")]
- Uses,
- #[serde(rename = "max_age")]
- MaxAge,
- #[serde(rename = "temporary")]
- Temporary,
- #[serde(rename = "deaf")]
- Deaf,
- #[serde(rename = "mute")]
- Mute,
- #[serde(rename = "nick")]
- Nick,
- #[serde(rename = "avatar_hash")]
- AvatarHash,
- #[serde(rename = "id")]
- Id,
- #[serde(rename = "type")]
- Type,
- #[serde(rename = "enable_emoticons")]
- EnableEmoticons,
- #[serde(rename = "expire_behavior")]
- ExpireBehavior,
- #[serde(rename = "expire_grace_period")]
- ExpireGracePeriod,
- #[serde(rename = "user_limit")]
- UserLimit,
- #[serde(rename = "privacy_level")]
- PrivacyLevel,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct AuditLogChange {
- pub new_value: Option<String>,
- pub old_value: Option<String>,
- pub key: AuditLogChangeKey,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct AuditLogEntry {
- pub target_id: Option<String>,
- pub changes: Option<Vec<AuditLogChange>>,
- pub user_id: Option<String>,
- pub id: String,
- pub action_type: AuditLogEvents,
- pub options: Option<OptionalAuditEntryInfo>,
- pub reason: Option<String>,
-}
-
-pub enum NewAuditLogEntry {
-
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct AuditLog {
- pub webhooks: Vec<Webhook>,
- pub users: Vec<User>,
- pub threads: Vec<Channel>,
- pub audit_log_entries: Vec<AuditLogEntry>,
- pub integrations: Vec<Integration>,
-}
diff --git a/common/rust/src/discord_models/channel.rs b/common/rust/src/discord_models/channel.rs
deleted file mode 100644
index ef31aa1..0000000
--- a/common/rust/src/discord_models/channel.rs
+++ /dev/null
@@ -1,341 +0,0 @@
-use enumflags2::{bitflags, BitFlags};
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::{
- application::Application, emoji::Emoji, guild::GuildMember, message_components::Component,
- slash_commands::MessageInteraction, user::User,
-};
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum ChannelTypes {
- GuildText = 0,
- Dm = 1,
- GuildVoice = 2,
- GroupDm = 3,
- GuildCategory = 4,
- GuildNews = 5,
- GuildStore = 6,
- GuildNewsThread = 10,
- GuildPublicThread = 11,
- GuildPrivateThread = 12,
- GuildStageVoice = 13,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum VideoQualityModes {
- Auto = 1,
- Full = 2,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum OverwriteTypes {
- Role = 0,
- Member = 1,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Overwrite {
- pub id: String,
- #[serde(rename = "type")]
- pub type_: OverwriteTypes,
- pub allow: String,
- pub deny: String,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ThreadMetadata {
- pub archived: bool,
- pub auto_archive_duration: i64,
- pub archive_timestamp: String,
- pub locked: Option<bool>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ThreadMember {
- pub id: Option<String>,
- pub user_id: Option<String>,
- pub join_timestamp: String,
- pub flags: i64,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Channel {
- pub id: String,
- #[serde(rename = "type")]
- pub type_: ChannelTypes,
- pub guild_id: Option<String>,
- pub position: Option<i64>,
- pub permission_overwrites: Option<Vec<Overwrite>>,
- pub name: Option<String>,
- pub topic: Option<String>,
- pub nsfw: Option<bool>,
- pub last_message_id: Option<String>,
- pub bitrate: Option<i64>,
- pub user_limit: Option<i64>,
- pub rate_limit_per_user: Option<i64>,
- pub recipients: Option<Vec<User>>,
- pub icon: Option<String>,
- pub owner_id: Option<String>,
- pub application_id: Option<String>,
- pub parent_id: Option<String>,
- pub last_pin_timestamp: Option<String>,
- pub rtc_region: Option<String>,
- pub video_quality_mode: Option<VideoQualityModes>,
- pub message_count: Option<i64>,
- pub member_count: Option<i64>,
- pub thread_metadata: Option<ThreadMetadata>,
- pub member: Option<ThreadMember>,
- pub default_auto_archive_duration: Option<i64>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Attachment {
- pub id: String,
- pub filename: String,
- pub content_type: String,
- pub size: i64,
- pub url: String,
- pub proxy_url: String,
- pub height: Option<i64>,
- pub width: Option<i64>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ChannelMention {
- pub id: String,
- pub guild_id: String,
- #[serde(rename = "type")]
- pub type_: ChannelTypes,
- pub name: String,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub enum EmbedTypes {
- #[serde(rename = "rich")]
- Rich,
- #[serde(rename = "image")]
- Image,
- #[serde(rename = "video")]
- Video,
- #[serde(rename = "gifv")]
- Gifv,
- #[serde(rename = "article")]
- Article,
- #[serde(rename = "link")]
- Link,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct EmbedThumbnail {
- pub url: Option<String>,
- pub proxy_url: Option<String>,
- pub height: Option<i64>,
- pub width: Option<i64>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct EmbedVideo {
- pub url: Option<String>,
- pub proxy_url: Option<String>,
- pub height: Option<i64>,
- pub width: Option<i64>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct EmbedImage {
- pub url: Option<String>,
- pub proxy_url: Option<String>,
- pub height: Option<i64>,
- pub width: Option<i64>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct EmbedProvider {
- pub name: Option<String>,
- pub url: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct EmbedAuthor {
- pub name: Option<String>,
- pub url: Option<String>,
- pub icon_url: Option<String>,
- pub proxy_icon_url: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct EmbedFooter {
- pub text: String,
- pub icon_url: Option<String>,
- pub proxy_icon_url: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct EmbedField {
- pub name: String,
- pub value: String,
- pub inline: Option<bool>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Embed {
- pub title: Option<String>,
- #[serde(rename = "type")]
- pub type_: Option<EmbedTypes>,
- pub description: Option<String>,
- pub url: Option<String>,
- pub timestamp: Option<String>,
- pub color: Option<i64>,
- pub footer: Option<EmbedFooter>,
- pub image: Option<EmbedImage>,
- pub thumbnail: Option<EmbedThumbnail>,
- pub video: Option<EmbedVideo>,
- pub provider: Option<EmbedProvider>,
- pub author: Option<EmbedAuthor>,
- pub fields: Option<Vec<EmbedField>>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Reaction {
- pub count: i64,
- pub me: bool,
- pub emoji: Emoji,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum MessageTypes {
- Default = 0,
- RecipientAdd = 1,
- RecipientRemove = 2,
- Call = 3,
- ChannelNameChange = 4,
- ChannelIconChange = 5,
- ChannelPinnedMessage = 6,
- GuildMemberJoin = 7,
- UserPremiumGuildSubscription = 8,
- UserPremiumGuildSubscriptionTier1 = 9,
- UserPremiumGuildSubscriptionTier2 = 10,
- UserPremiumGuildSubscriptionTier3 = 11,
- ChannelFollowAdd = 12,
- GuildDiscoveryDisqualified = 14,
- GuildDiscoveryRequalified = 15,
- GuildDiscoveryGracePeriodInitialWarning = 16,
- GuildDiscoveryGracePeriodFinalWarning = 17,
- ThreadCreated = 18,
- Reply = 19,
- ApplicationCommand = 20,
- ThreadStarterMessage = 21,
- GuildInviteReminder = 22,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum MessageActivityTypes {
- Join = 1,
- Spectate = 2,
- Listen = 3,
- JoinRequest = 5,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct MessageActivity {
- #[serde(rename = "type")]
- pub type_: MessageActivityTypes,
- pub party_id: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct MessageReference {
- pub message_id: Option<String>,
- pub channel_id: Option<String>,
- pub guild_id: Option<String>,
- pub fail_if_not_exists: Option<bool>,
-}
-
-#[bitflags]
-#[repr(u64)]
-#[derive(Debug, Clone, Copy)]
-pub enum MessageFlags {
- Crossposted = 1 << 0,
- IsCrosspost = 1 << 1,
- SuppressEmbeds = 1 << 2,
- SourceMessageDeleted = 1 << 3,
- Urgent = 1 << 4,
- HasThread = 1 << 5,
- Ephemeral = 1 << 6,
- Loading = 1 << 7,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum MessageStickerFormatTypes {
- Png = 1,
- Apng = 2,
- Lottie = 3,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct MessageStickerItem {
- pub id: String,
- pub name: String,
- pub format_type: MessageStickerFormatTypes,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct MessageSticker {
- pub id: String,
- pub pack_id: Option<String>,
- pub name: String,
- pub description: String,
- pub tags: String,
- // deprecated
- // pub asset: String,
- pub format_type: MessageStickerFormatTypes,
- pub available: Option<bool>,
- pub guild_id: Option<String>,
- pub user: Option<User>,
- pub sort_value: Option<i64>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Message {
- pub id: String,
- pub channel_id: String,
- pub guild_id: Option<String>,
- pub author: User,
- pub member: Option<GuildMember>,
- pub content: String,
- pub timestamp: String,
- pub edited_timestamp: String,
- pub tts: bool,
- pub mention_everyone: bool,
- pub mentions: Vec<User>, // todo: It is a Vector of User objects, with an additional partial member field (GuildMember)
- pub mentions_roles: Vec<String>,
- pub mention_channels: Option<Vec<Channel>>,
- pub attachments: Vec<Attachment>,
- pub embeds: Vec<Embed>,
- pub reactions: Option<Vec<Reaction>>,
- /// ! Can be a String or an int !
- pub nonce: Option<String>,
- pub pinned: bool,
- pub webhook_id: Option<String>,
- #[serde(rename = "type")]
- pub type_: MessageTypes,
- pub activity: Option<MessageActivity>,
- pub application: Option<Application>,
- pub application_id: Option<String>,
- pub message_reference: Option<MessageReference>,
- pub flags: Option<BitFlags<MessageFlags>>,
- pub referenced_message: Option<Box<Message>>,
- pub interaction: Option<MessageInteraction>,
- pub thread: Option<Channel>,
- pub components: Option<Component>,
- pub sticker_items: Option<Vec<MessageStickerItem>>,
- // deprecated
- // pub stickers: Option<Vec<MessageSticker>>,
-}
diff --git a/common/rust/src/discord_models/emoji.rs b/common/rust/src/discord_models/emoji.rs
deleted file mode 100644
index eec02e7..0000000
--- a/common/rust/src/discord_models/emoji.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-use serde::{Deserialize, Serialize};
-
-use super::user::User;
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Emoji {
- pub id: Option<String>,
- pub name: Option<String>,
- pub roles: Vec<String>,
- pub user: Option<User>,
- pub require_colons: Option<bool>,
- pub managed: Option<bool>,
- pub animated: Option<bool>,
- pub available: Option<bool>,
-}
diff --git a/common/rust/src/discord_models/gateway.rs b/common/rust/src/discord_models/gateway.rs
deleted file mode 100644
index a886d99..0000000
--- a/common/rust/src/discord_models/gateway.rs
+++ /dev/null
@@ -1,124 +0,0 @@
-use enumflags2::{bitflags, BitFlags};
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::user::User;
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub enum PresenceUpdateStatus {
- #[serde(rename = "online")]
- Online,
- #[serde(rename = "idle")]
- Idle,
- #[serde(rename = "dnd")]
- Dnd,
- #[serde(rename = "offline")]
- Offline,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ClientStatus {
- pub desktop: Option<String>,
- pub mobile: Option<String>,
- pub web: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct PresenceUpdate {
- pub user: User,
- pub guild_id: String,
- pub status: PresenceUpdateStatus,
- pub activities: Vec<Activity>,
- pub client_status: ClientStatus,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum ActivityTypes {
- Game = 0,
- Streaming = 1,
- Listening = 2,
- Watching = 3,
- Custom = 4,
- Competing = 5,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ActivityTimestamps {
- pub start: Option<i64>,
- pub end: Option<i64>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ActivityEmoji {
- pub name: String,
- pub id: Option<String>,
- pub animated: Option<bool>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ActivityParty {
- pub id: Option<String>,
- /// [current_size, max_size]
- pub size: Option<Vec<i64>>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ActivityAssets {
- pub large_image: Option<String>,
- pub large_text: Option<String>,
- pub small_image: Option<String>,
- pub small_text: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ActivitySecrets {
- pub join: Option<String>,
- pub spectate: Option<String>,
- #[serde(rename = "match")]
- pub match_: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ActivityButtons {
- pub label: String,
- pub url: String,
-}
-
-#[bitflags]
-#[repr(u64)]
-#[derive(Debug, Clone, Copy)]
-pub enum ActivityFlags {
- Instance = 1 << 0,
- Join = 1 << 1,
- Spectate = 1 << 2,
- JoinRequest = 1 << 3,
- Sync = 1 << 4,
- Play = 1 << 5,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Activity {
- pub name: String,
- #[serde(rename = "type")]
- pub type_: ActivityTypes,
- pub url: Option<String>,
- pub created_at: String,
- pub timestamps: Option<ActivityTimestamps>,
- pub application_id: Option<String>,
- pub details: Option<String>,
- pub state: Option<String>,
- pub emoji: Option<ActivityEmoji>,
- pub party: Option<ActivityParty>,
- pub assets: Option<ActivityAssets>,
- pub secrets: Option<ActivitySecrets>,
- pub instance: Option<bool>,
- pub flags: Option<BitFlags<ActivityFlags>>,
- pub buttons: Option<Vec<ActivityButtons>>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-#[serde(tag = "type")]
-pub enum NewActivity {
-
-} \ No newline at end of file
diff --git a/common/rust/src/discord_models/guild.rs b/common/rust/src/discord_models/guild.rs
deleted file mode 100644
index 85da5b2..0000000
--- a/common/rust/src/discord_models/guild.rs
+++ /dev/null
@@ -1,255 +0,0 @@
-use enumflags2::{bitflags, BitFlags};
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::{
- channel::Channel, emoji::Emoji, gateway::PresenceUpdate, permissions::Role,
- stage_instance::StageInstance, user::User, voice::VoiceState,
-};
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum IntegrationExpireBehavior {
- RemoveRole = 0,
- Kick = 1,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct IntegrationAccount {
- pub id: String,
- pub name: String,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct IntegrationApplication {
- pub id: String,
- pub name: String,
- pub icon: Option<String>,
- pub description: String,
- pub summary: Option<String>,
- pub bot: Option<User>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Integration {
- pub id: String,
- pub name: String,
- #[serde(rename = "type")]
- pub type_: String,
- pub enabled: bool,
- pub syncing: Option<bool>,
- pub role_id: Option<String>,
- pub enable_emoticons: Option<bool>,
- pub expire_behavior: Option<IntegrationExpireBehavior>,
- pub expire_grace_period: Option<i64>,
- pub user: Option<User>,
- pub account: IntegrationAccount,
- pub synced_at: Option<String>,
- pub subscriber_count: Option<i64>,
- pub revoked: Option<bool>,
- pub application: Option<IntegrationApplication>,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum VerificationLevel {
- None = 0,
- Low = 1,
- Medium = 2,
- High = 3,
- VeryHigh = 4,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum PremiumTier {
- None = 0,
- Tier1 = 1,
- Tier2 = 2,
- Tier3 = 3,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum ExplicitContentFilter {
- Disabled = 0,
- MembersWithoutRoles = 1,
- AllMembers = 2,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum MfaLevel {
- None = 0,
- Elevated = 1,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum DefaultMessageNotificationLevel {
- AllMessages = 0,
- OnlyMentions = 1,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum GuildNsfwLevel {
- Default = 0,
- Explicit = 1,
- Safe = 2,
- AgeRestricted = 3,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub enum GuildFeatures {
- #[serde(rename = "ANIMATED_ICON")]
- AnimatedIcon,
- #[serde(rename = "BANNER")]
- Banner,
- #[serde(rename = "COMMERCE")]
- Commerce,
- #[serde(rename = "COMMUNITY")]
- Community,
- #[serde(rename = "DISCOVERABLE")]
- Discoverable,
- #[serde(rename = "FEATURABLE")]
- Featurable,
- #[serde(rename = "INVITE_SPLASH")]
- InviteSplash,
- #[serde(rename = "MEMBER_VERIFICATION_GATE_ENABLED")]
- MemberVerificationGateEnabled,
- #[serde(rename = "NEWS")]
- News,
- #[serde(rename = "PARTNERED")]
- Partnered,
- #[serde(rename = "PREVIEW_ENABLED")]
- PreviewEnabled,
- #[serde(rename = "VANITY_URL")]
- VanityUrl,
- #[serde(rename = "VERIFIED")]
- Verified,
- #[serde(rename = "VIP_REGIONS")]
- VipRegions,
- #[serde(rename = "WELCOME_SCREEN_ENABLED")]
- WelcomeScreenEnabled,
- #[serde(rename = "TICKETED_EVENTS_ENABLED")]
- TicketedEventsEnabled,
- #[serde(rename = "MONETIZATION_ENABLED")]
- MonetizationEnabled,
- #[serde(rename = "MORE_STICKERS")]
- MoreStickers,
- #[serde(rename = "THREE_DAY_THREAD_ARCHIVE")]
- ThreeDayThreadArchive,
- #[serde(rename = "SEVEN_DAY_THREAD_ARCHIVE")]
- SevenDayThreadArchive,
- #[serde(rename = "PRIVATE_THREADS")]
- PrivateThreads,
-}
-
-#[bitflags]
-#[repr(u64)]
-#[derive(Debug, Clone, Copy)]
-pub enum SystemChannelFlags {
- SuppressJoinNotifications = 1 << 0,
- SuppressPremiumSubscriptions = 1 << 1,
- SuppressGuildReminderNotifications = 1 << 2,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct WelcomeScreenChannel {
- pub channel_id: String,
- pub description: String,
- pub emoji_id: Option<String>,
- pub emoji_name: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct WelcomeScreen {
- pub description: String,
- pub welcome_channels: Vec<WelcomeScreenChannel>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Guild {
- pub id: String,
- pub name: String,
- pub icon: Option<String>,
- pub icon_hash: Option<String>,
- pub splash: Option<String>,
- pub discovery_splash: Option<String>,
- pub owner: Option<bool>,
- pub owner_id: String,
- pub permissions: Option<String>,
- /// DEPRECATED
- pub region: Option<String>,
- pub afk_channel_id: Option<String>,
- pub afk_timeout: i64,
- pub widget_enabled: Option<bool>,
- pub widget_channel_id: Option<String>,
- pub verification_level: VerificationLevel,
- pub default_message_notifications: DefaultMessageNotificationLevel,
- pub explicit_content_filter: ExplicitContentFilter,
- pub roles: Vec<Role>,
- pub emojis: Vec<Emoji>,
- pub features: Vec<GuildFeatures>,
- pub mfa_level: MfaLevel,
- pub application_id: Option<String>,
- pub system_channel_id: Option<String>,
- pub system_channel_flags: BitFlags<SystemChannelFlags>,
- pub rules_channel_id: Option<String>,
- pub joined_at: Option<String>,
- pub large: Option<bool>,
- pub unavailable: Option<bool>,
- pub member_count: Option<i64>,
- pub voice_states: Option<Vec<VoiceState>>,
- pub members: Option<Vec<GuildMember>>,
- pub channels: Option<Vec<Channel>>,
- pub threads: Option<Vec<Channel>>,
- pub presences: Option<Vec<PresenceUpdate>>,
- pub max_presences: Option<i64>,
- pub vanity_url_code: Option<String>,
- pub description: Option<String>,
- pub banner: Option<String>,
- pub premium_tier: PremiumTier,
- pub premium_subscription_count: i64,
- pub preferred_locale: String,
- pub public_updates_channel_id: Option<String>,
- pub max_video_channel_users: Option<i64>,
- pub approximate_member_count: Option<i64>,
- pub welcome_screen: Option<WelcomeScreen>,
- pub nsfw_level: GuildNsfwLevel,
- pub stage_instances: Option<Vec<StageInstance>>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct GuildMember {
- pub user: Option<User>,
- pub nick: Option<String>,
- pub roles: Vec<String>,
- pub joined_at: String,
- pub premium_since: Option<String>,
- pub deaf: bool,
- pub mute: bool,
- pub pending: Option<bool>,
- pub permissions: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct GuildPreview {
- pub id: String,
- pub name: String,
- pub icon: Option<String>,
- pub splash: Option<String>,
- pub discovery_splash: Option<String>,
- pub emojis: Vec<Emoji>,
- pub features: Vec<GuildFeatures>,
- pub approximate_member_count: i64,
- pub approximate_presence_count: i64,
- pub description: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct GuildWidget {
- pub enabled: bool,
- pub channel_id: Option<String>,
-}
diff --git a/common/rust/src/discord_models/guild_template.rs b/common/rust/src/discord_models/guild_template.rs
deleted file mode 100644
index 960631d..0000000
--- a/common/rust/src/discord_models/guild_template.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-use serde::{Deserialize, Serialize};
-
-use super::{guild::Guild, user::User};
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct GuildTemplate {
- pub code: String,
- pub name: String,
- pub description: Option<String>,
- pub usage_count: i64,
- pub creator_id: String,
- pub creator: User,
- pub created_at: String,
- pub updated_at: String,
- pub source_guild_ild: String,
- pub serialized_source_guild: Guild,
- pub is_dirty: Option<bool>,
-}
diff --git a/common/rust/src/discord_models/invite.rs b/common/rust/src/discord_models/invite.rs
deleted file mode 100644
index 639278c..0000000
--- a/common/rust/src/discord_models/invite.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::{
- application::Application,
- channel::Channel,
- guild::{Guild, GuildMember},
- user::User,
-};
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum InviteTargetTypes {
- Stream = 1,
- EmbeddedApplication = 2,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct InviteStageInstance {
- pub members: Vec<GuildMember>,
- pub participant_count: i64,
- pub speaker_count: i64,
- pub topic: String,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Invite {
- pub code: String,
- pub guild: Option<Guild>,
- pub channel: Channel,
- pub inviter: Option<User>,
- pub target_type: Option<InviteTargetTypes>,
- pub target_user: Option<User>,
- pub target_application: Option<Application>,
- pub approximate_presence_count: Option<i64>,
- pub approximate_member_count: Option<i64>,
- pub expires_at: Option<String>,
- pub stage_instance: Option<InviteStageInstance>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct InviteMetadata {
- pub uses: i64,
- pub max_uses: i64,
- pub max_age: i64,
- pub temporary: bool,
- pub created_at: String,
-}
diff --git a/common/rust/src/discord_models/message_components.rs b/common/rust/src/discord_models/message_components.rs
deleted file mode 100644
index f71d7ed..0000000
--- a/common/rust/src/discord_models/message_components.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::emoji::Emoji;
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum ComponentTypes {
- ActionRow = 1,
- Button = 2,
- SelectMenu = 3,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-/// Global representation of a Component, more detailed are Button (if button) and Select Menu (if select menu)
-/// Action Rows are just type: 1, content + components
-pub struct Component {
- #[serde(rename = "type")]
- pub type_: ComponentTypes,
- pub custom_id: Option<String>,
- pub disabled: Option<bool>,
- pub style: Option<ButtonStyles>,
- pub label: Option<String>,
- pub emoji: Option<Emoji>,
- pub url: Option<String>,
- pub options: Vec<SelectOption>,
- pub placeholder: Option<String>,
- pub min_values: Option<u8>,
- pub max_values: Option<u8>,
- pub components: Option<Vec<Component>>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Button {
- #[serde(rename = "type")]
- /// it should be `2`
- pub type_: ComponentTypes,
- pub style: ButtonStyles,
- pub label: Option<String>,
- pub emoji: Option<Emoji>,
- pub custom_id: Option<String>,
- pub url: Option<String>,
- pub disabled: Option<bool>,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum ButtonStyles {
- Primary = 1,
- Secondary = 2,
- Success = 3,
- Danger = 4,
- Link = 5,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct SelectOption {
- pub label: String,
- pub value: String,
- pub description: Option<String>,
- pub emoji: Option<Emoji>,
- pub default: Option<bool>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct SelectMenu {
- /// it should be 3
- pub type_: ComponentTypes,
- pub custom_id: String,
- pub options: Vec<SelectOption>,
- pub placeholder: Option<String>,
- pub min_values: Option<u8>,
- pub max_values: Option<u8>,
- pub disabled: Option<bool>,
-}
diff --git a/common/rust/src/discord_models/mod.rs b/common/rust/src/discord_models/mod.rs
deleted file mode 100644
index 8017e2a..0000000
--- a/common/rust/src/discord_models/mod.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-pub mod application;
-pub mod audit_log;
-pub mod channel;
-pub mod emoji;
-pub mod gateway;
-pub mod guild;
-pub mod guild_template;
-pub mod invite;
-pub mod message_components;
-pub mod permissions;
-pub mod slash_commands;
-pub mod stage_instance;
-pub mod teams;
-pub mod user;
-pub mod voice;
-pub mod webhook;
diff --git a/common/rust/src/discord_models/permissions.rs b/common/rust/src/discord_models/permissions.rs
deleted file mode 100644
index 76fa34a..0000000
--- a/common/rust/src/discord_models/permissions.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-use serde::{Deserialize, Serialize};
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct RoleTags {
- pub bot_id: Option<String>,
- pub integration_id: Option<String>,
- pub premium_subscriber: Option<bool>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Role {
- pub id: String,
- pub name: String,
- pub color: i64,
- pub hoist: bool,
- pub position: i64,
- pub permissions: String,
- pub managed: bool,
- pub mentionable: bool,
- pub tags: Option<RoleTags>,
-}
diff --git a/common/rust/src/discord_models/slash_commands.rs b/common/rust/src/discord_models/slash_commands.rs
deleted file mode 100644
index 181a622..0000000
--- a/common/rust/src/discord_models/slash_commands.rs
+++ /dev/null
@@ -1,104 +0,0 @@
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::{channel::Message, guild::GuildMember, user::User};
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum ApplicationCommandOptionType {
- SubCommand = 1,
- SubCommandGroup = 2,
- String = 3,
- Integer = 4,
- Boolean = 5,
- User = 6,
- Channel = 7,
- Role = 8,
- Mentionable = 9,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ApplicationCommandOptionChoice {
- pub name: String,
- /// todo: Can also be a String!!!!
- pub value: i64,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ApplicationCommandOption {
- #[serde(rename = "type")]
- pub type_: ApplicationCommandOptionType,
- pub name: String,
- pub description: String,
- pub required: Option<bool>,
- pub choices: Option<Vec<ApplicationCommandOptionChoice>>,
- pub options: Option<Vec<ApplicationCommandOption>>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ApplicationCommand {
- pub id: String,
- pub application_id: String,
- pub guild_id: Option<String>,
- pub name: String,
- pub description: String,
- pub options: Option<Vec<ApplicationCommandOption>>,
- pub default_permission: Option<bool>,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum ApplicationCommandPermissionType {
- Role = 1,
- User = 2,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct GuildApplicationCommandPermissions {
- pub id: String,
- pub application_id: String,
- pub guild_id: String,
- pub permissions: Vec<ApplicationCommandPermissions>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ApplicationCommandPermissions {
- pub id: String,
- #[serde(rename = "type")]
- pub type_: ApplicationCommandPermissionType,
- pub permission: bool,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum InteractionRequestType {
- Ping = 1,
- ApplicationCommand = 2,
- MessageComponent = 3,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct MessageInteraction {
- pub id: String,
- #[serde(rename = "type")]
- pub type_: InteractionRequestType,
- pub name: String,
- pub user: User,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Interaction {
- pub id: String,
- pub application_id: String,
- #[serde(rename = "type")]
- pub type_: InteractionRequestType,
- /// i am not sure about this one https://canary.discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data
- pub data: Option<ApplicationCommand>,
- pub guild_id: Option<String>,
- pub channel_id: Option<String>,
- pub member: Option<GuildMember>,
- pub user: Option<User>,
- pub token: String,
- pub version: i64,
- pub message: Option<Message>,
-}
diff --git a/common/rust/src/discord_models/stage_instance.rs b/common/rust/src/discord_models/stage_instance.rs
deleted file mode 100644
index 1eee1c2..0000000
--- a/common/rust/src/discord_models/stage_instance.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum PrivacyLevel {
- Public = 1,
- GuildOnly = 2,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct StageInstance {
- pub id: String,
- pub guild_id: String,
- pub channel_id: String,
- pub topic: String,
- pub privacy_level: PrivacyLevel,
- pub discoverable_disabled: bool,
-}
diff --git a/common/rust/src/discord_models/teams.rs b/common/rust/src/discord_models/teams.rs
deleted file mode 100644
index 369b3cd..0000000
--- a/common/rust/src/discord_models/teams.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::user::User;
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum MembershipState {
- Invited = 0,
- Accepted = 1,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct TeamMembers {
- pub membership_state: MembershipState,
- pub permissions: Vec<String>,
- pub team_id: String,
- pub user: User,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Team {
- pub icon: Option<String>,
- pub id: String,
- pub members: Vec<TeamMembers>,
- pub name: String,
- pub owner_user_id: String,
-}
diff --git a/common/rust/src/discord_models/user.rs b/common/rust/src/discord_models/user.rs
deleted file mode 100644
index 36914ce..0000000
--- a/common/rust/src/discord_models/user.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-use enumflags2::{bitflags, BitFlags};
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::guild::Integration;
-
-#[bitflags]
-#[repr(u64)]
-#[derive(Debug, Clone, Copy)]
-pub enum UserFlags {
- // None = 0 << 0,
- DiscordEmployee = 1 << 0,
- PartneredServerOwner = 1 << 1,
- HypesquadEvents = 1 << 2,
- BugHunterLevel1 = 1 << 3,
- HouseBravery = 1 << 6,
- HouseBrilliance = 1 << 7,
- HouseBalance = 1 << 8,
- EarlySupporter = 1 << 9,
- TeamUser = 1 << 10,
- BugHunterLevel2 = 1 << 14,
- VerifiedBot = 1 << 16,
- EarlyVerifiedBotDeveloper = 1 << 17,
- DiscordCertifiedModerator = 1 << 18,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum PremiumTypes {
- None = 0,
- NitroClassic = 1,
- Nitro = 2,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-/// Represents a User within Discord
-pub struct User {
- pub id: String,
- pub username: String,
- pub discriminator: String,
- pub avatar: Option<String>,
- pub bot: Option<bool>,
- pub system: Option<bool>,
- pub mfa_enabled: Option<bool>,
- pub locale: Option<String>,
- pub verified: Option<bool>,
- pub email: Option<String>,
- pub flags: Option<BitFlags<UserFlags>>,
- pub premium_type: Option<PremiumTypes>,
- pub public_flags: Option<BitFlags<UserFlags>>,
-}
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum VisibilityTypes {
- None = 0,
- Everyone = 1,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-/// The connection object that the user has attached.
-pub struct Connection {
- pub id: String,
- pub name: String,
- #[serde(rename = "type")]
- pub type_: String,
- pub revoked: Option<bool>,
- pub integrations: Option<Vec<Integration>>,
- pub verified: bool,
- pub friend_sync: bool,
- pub show_activity: bool,
- pub visibility: VisibilityTypes,
-}
diff --git a/common/rust/src/discord_models/voice.rs b/common/rust/src/discord_models/voice.rs
deleted file mode 100644
index 8263af5..0000000
--- a/common/rust/src/discord_models/voice.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-use serde::{Deserialize, Serialize};
-
-use super::guild::GuildMember;
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct VoiceState {
- pub guild_id: Option<String>,
- pub channel_id: Option<String>,
- pub user_id: String,
- pub member: Option<GuildMember>,
- pub session_id: String,
- pub deaf: bool,
- pub mute: bool,
- pub self_deaf: bool,
- pub self_mute: bool,
- pub self_stream: Option<bool>,
- pub self_video: bool,
- pub suppress: bool,
- pub request_to_speak_timestamp: Option<String>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct VoiceRegion {
- pub id: String,
- pub name: String,
- pub vip: bool,
- pub optimal: bool,
- pub deprecated: bool,
- pub custom: bool,
-}
diff --git a/common/rust/src/discord_models/webhook.rs b/common/rust/src/discord_models/webhook.rs
deleted file mode 100644
index 4648772..0000000
--- a/common/rust/src/discord_models/webhook.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-use super::{channel::Channel, guild::Guild, user::User};
-
-#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
-#[repr(u8)]
-pub enum WebhookTypes {
- Incoming = 1,
- ChannelFollower = 2,
- Application = 3,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct Webhook {
- pub id: String,
- #[serde(rename = "type")]
- pub type_: WebhookTypes,
- pub guild_id: Option<String>,
- pub channel_id: Option<String>,
- pub user: Option<User>,
- pub name: Option<String>,
- pub avatar: Option<String>,
- pub token: Option<String>,
- pub application_id: Option<String>,
- pub source_guild: Option<Guild>,
- pub source_channel: Option<Channel>,
- pub url: String,
-}
diff --git a/common/rust/src/lib.rs b/common/rust/src/lib.rs
index fa2c6fc..cbe6934 100644
--- a/common/rust/src/lib.rs
+++ b/common/rust/src/lib.rs
@@ -9,10 +9,10 @@ pub use testcontainers;
/// This crate is all the utilities shared by the nova rust projects
/// It includes logging, config and protocols.
pub mod config;
-pub mod discord_models;
pub mod error;
pub mod monitoring;
pub mod nats;
pub mod payloads;
pub mod redis;
+mod serializable_event;
diff --git a/common/rust/src/payloads.rs b/common/rust/src/payloads.rs
index fd7717d..454baf1 100644
--- a/common/rust/src/payloads.rs
+++ b/common/rust/src/payloads.rs
@@ -1,27 +1,19 @@
use std::fmt::Debug;
use serde::{Deserialize, Serialize};
+use twilight_model::gateway::event::Event;
+use crate::serializable_event::SerializableEvent;
-use crate::discord_models::{
- application::Application,
- channel::{Channel, Message, ThreadMember},
- emoji::Emoji,
- gateway::PresenceUpdate,
- guild::{Guild, GuildMember, Integration},
- invite::InviteTargetTypes,
- permissions::Role,
- slash_commands::{ApplicationCommand, Interaction},
- stage_instance::StageInstance,
- user::User,
- voice::VoiceState,
-};
+#[derive(Deserialize, Serialize, Debug, Clone)]
+pub struct SerializeHelper(#[serde(with = "SerializableEvent")] pub Event);
/// Payload send to the nova cache queues
#[derive(Serialize, Deserialize, Debug, Clone)]
// #[serde(bound(deserialize = "T: Deserialize<'de> + std::default::Default + Clone"))]
pub struct CachePayload {
pub tracing: Tracing,
- pub data: CacheData,
+ #[serde(flatten)]
+ pub data: SerializeHelper,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -29,242 +21,3 @@ pub struct Tracing {
pub node_id: String,
pub span: Option<String>,
}
-
-#[derive(Serialize, Deserialize, Debug, Clone)]
-pub enum CacheData {
- Ready {
- version: u8,
- user: User,
- guilds: Vec<Guild>,
- session_id: String,
- shard: Option<Vec<i64>>,
- application: Application,
- },
- ApplicationCommandCreate {
- guild_id: Option<String>,
- command: ApplicationCommand,
- },
- ApplicationCommandUpdate {
- guild_id: Option<String>,
- command: ApplicationCommand,
- },
- ApplicationCommandDelete {
- guild_id: Option<String>,
- command: ApplicationCommand,
- },
- ChannelCreate {
- channel: Channel,
- },
- ChannelUpdate {
- channel: Channel,
- },
- ChannelDelete {
- channel: Channel,
- },
- ThreadCreate {
- channel: Channel,
- },
- ThreadUpdate {
- channel: Channel,
- },
- ThreadDelete {
- channel: Channel,
- },
- ThreadListSync {
- guild_id: String,
- channel_ids: Option<Vec<String>>,
- threads: Vec<Channel>,
- members: Vec<ThreadMember>,
- },
- ThreadMemberUpdate {
- member: ThreadMember,
- },
- ThreadMembersUpdate {
- id: String,
- guild_id: String,
- member_count: i64,
- added_members: Option<Vec<ThreadMember>>,
- removed_member_ids: Option<Vec<String>>,
- },
- ChannelPinsUpdate {
- guild_id: Option<String>,
- channel_id: String,
- last_pin_timestamp: Option<String>,
- },
- GuildCreate {
- guild: Guild,
- },
- GuildUpdate {
- guild: Guild,
- },
- GuildDelete {
- guild: Guild,
- },
- GuildBanAdd {
- guild_id: String,
- user: User,
- },
- GuildBanRemove {
- guild_id: String,
- user: User,
- },
- GuildEmojisUpdate {
- guild_id: String,
- emojis: Vec<Emoji>,
- },
- GuildIntegrationsUpdate {
- guild_id: String,
- },
- GuildMemberAdd {
- guild_id: String,
- member: GuildMember,
- },
- GuildMemberRemove {
- guild_id: String,
- user: User,
- },
- GuildMemberUpdate {
- guild_id: String,
- roles: Vec<String>,
- user: User,
- nick: Option<String>,
- joined_at: Option<String>,
- premium_since: Option<String>,
- deaf: Option<bool>,
- mute: Option<bool>,
- pending: Option<bool>,
- },
- GuildMembersChunk {
- guild_id: String,
- members: Vec<GuildMember>,
- chunk_index: i64,
- chunk_count: i64,
- not_found: Option<Vec<String>>,
- presences: Option<Vec<PresenceUpdate>>,
- nonce: Option<String>,
- },
- GuildRoleCreate {
- guild_id: String,
- role: Role,
- },
- GuildRoleUpdate {
- guild_id: String,
- role: Role,
- },
- GuildRoleDelete {
- guild_id: String,
- role_id: String,
- },
- IntegrationCreate {
- guild_id: String,
- integration: Integration,
- },
- IntegrationUpdate {
- guild_id: String,
- integration: Integration,
- },
- IntegrationDelete {
- id: String,
- guild_id: String,
- application_id: Option<String>,
- },
- InviteCreate {
- channel_id: String,
- code: String,
- created_at: String,
- guild_id: Option<String>,
- inviter: Option<User>,
- max_age: i64,
- max_uses: i64,
- target_type: Option<InviteTargetTypes>,
- target_user: Option<User>,
- target_application: Option<Application>,
- temporary: bool,
- uses: i64,
- },
- InviteDelete {
- channel_id: String,
- guild_id: Option<String>,
- code: String,
- },
- InteractionCreate {
- // boxed to avoid a large difference size between variants (https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant)
- interaction: Box<Interaction>,
- },
- MessageCreate {
- message: Message,
- },
- MessageUpdate {
- message: Message,
- },
- MessageDelete {
- id: String,
- channel_id: String,
- guild_id: Option<String>,
- },
- MessageDeleteBulk {
- ids: Vec<String>,
- channel_id: String,
- guild_id: Option<String>,
- },
- MessageReactionAdd {
- user_id: String,
- channel_id: String,
- message_id: String,
- guild_id: Option<String>,
- member: Option<GuildMember>,
- emoji: Emoji,
- },
- MessageReactionRemove {
- user_id: String,
- channel_id: String,
- message_id: String,
- guild_id: Option<String>,
- emoji: Emoji,
- },
- MessageReactionRemoveAll {
- channel_id: String,
- message_id: String,
- guild_id: Option<String>,
- },
- MessageReactionRemoveEmoji {
- channel_id: String,
- message_id: String,
- guild_id: Option<String>,
- emoji: Emoji,
- },
- PresenceUpdate {
- presence: PresenceUpdate,
- },
- TypingStart {
- channel_id: String,
- guild_id: Option<String>,
- user_id: String,
- timestamp: i64,
- member: Option<GuildMember>,
- },
- UserUpdate {
- user: User,
- },
- VoiceStateUpdate {
- state: VoiceState,
- },
- VoiceServerUpdate {
- token: String,
- guild_id: String,
- endpoint: Option<String>,
- },
- WebhookUpdate {
- guild_id: String,
- channel_id: String,
- },
- StageInstanceCreate {
- instance: StageInstance,
- },
- StageInstanceUpdate {
- instance: StageInstance,
- },
- StageInstanceDelete {
- instance: StageInstance,
- },
-}
diff --git a/common/rust/src/serializable_event.rs b/common/rust/src/serializable_event.rs
new file mode 100644
index 0000000..269b0aa
--- /dev/null
+++ b/common/rust/src/serializable_event.rs
@@ -0,0 +1,165 @@
+use serde::{Deserialize, Serialize};
+use twilight_model::gateway::{
+ event::{
+ shard::{
+ Connected, Connecting, Disconnected, Identifying, Payload, Reconnecting, Resuming,
+ },
+ Event,
+ },
+ payload::{
+ BanAdd, BanRemove, ChannelCreate, ChannelDelete, ChannelPinsUpdate, ChannelUpdate,
+ GuildCreate, GuildDelete, GuildEmojisUpdate, GuildIntegrationsUpdate, GuildUpdate,
+ IntegrationCreate, IntegrationDelete, IntegrationUpdate, InteractionCreate, InviteCreate,
+ InviteDelete, MemberAdd, MemberChunk, MemberRemove, MemberUpdate, MessageCreate,
+ MessageDelete, MessageDeleteBulk, MessageUpdate, PresenceUpdate, ReactionAdd,
+ ReactionRemove, ReactionRemoveAll, ReactionRemoveEmoji, Ready, RoleCreate, RoleDelete,
+ RoleUpdate, StageInstanceCreate, StageInstanceDelete, StageInstanceUpdate, ThreadCreate,
+ ThreadDelete, ThreadListSync, ThreadMemberUpdate, ThreadMembersUpdate, ThreadUpdate,
+ TypingStart, UnavailableGuild, UserUpdate, VoiceServerUpdate, VoiceStateUpdate,
+ WebhooksUpdate,
+ },
+};
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(remote = "Event")]
+#[serde(rename_all = "snake_case")]
+#[serde(tag = "t", content = "c")]
+pub enum SerializableEvent {
+ /// A user was banned from a guild.
+ BanAdd(BanAdd),
+ /// A user's ban from a guild was removed.
+ BanRemove(BanRemove),
+ /// A channel was created.
+ ChannelCreate(ChannelCreate),
+ /// A channel was deleted.
+ ChannelDelete(ChannelDelete),
+ /// A channel's pins were updated.
+ ChannelPinsUpdate(ChannelPinsUpdate),
+ /// A channel was updated.
+ ChannelUpdate(ChannelUpdate),
+ /// A heartbeat was sent to or received from the gateway.
+ GatewayHeartbeat(u64),
+ /// A heartbeat acknowledgement was received from the gateway.
+ GatewayHeartbeatAck,
+ /// A "hello" packet was received from the gateway.
+ GatewayHello(u64),
+ /// A shard's session was invalidated.
+ ///
+ /// `true` if resumeable. If not, then the shard must do a full reconnect.
+ GatewayInvalidateSession(bool),
+ /// The gateway is indicating to perform a reconnect.
+ GatewayReconnect,
+ /// Undocumented event, should be ignored
+ GiftCodeUpdate,
+ /// A guild was created.
+ GuildCreate(Box<GuildCreate>),
+ /// A guild was deleted or the current user was removed from a guild.
+ GuildDelete(Box<GuildDelete>),
+ /// A guild's emojis were updated.
+ GuildEmojisUpdate(GuildEmojisUpdate),
+ /// A guild's integrations were updated.
+ GuildIntegrationsUpdate(GuildIntegrationsUpdate),
+ /// A guild was updated.
+ GuildUpdate(Box<GuildUpdate>),
+ /// A guild integration was created.
+ IntegrationCreate(Box<IntegrationCreate>),
+ /// A guild integration was updated.
+ IntegrationDelete(IntegrationDelete),
+ /// A guild integration was deleted.
+ IntegrationUpdate(Box<IntegrationUpdate>),
+ /// An interaction was invoked by a user.
+ InteractionCreate(Box<InteractionCreate>),
+ /// A invite was made.
+ InviteCreate(Box<InviteCreate>),
+ /// A invite was deleted.
+ InviteDelete(InviteDelete),
+ /// A user was added to a guild.
+ MemberAdd(Box<MemberAdd>),
+ /// A user was removed from a guild.
+ MemberRemove(MemberRemove),
+ /// A user's member object in a guild was updated.
+ MemberUpdate(Box<MemberUpdate>),
+ /// A chunk of members were received from the gateway.
+ MemberChunk(MemberChunk),
+ /// A message was created in a channel.
+ MessageCreate(Box<MessageCreate>),
+ /// A message was deleted in a channel.
+ MessageDelete(MessageDelete),
+ /// Multiple messages were deleted in a channel.
+ MessageDeleteBulk(MessageDeleteBulk),
+ /// A message was updated in a channel.
+ MessageUpdate(Box<MessageUpdate>),
+ /// A user's active presence (such as game or online status) was updated.
+ PresenceUpdate(Box<PresenceUpdate>),
+ /// Multiple presences outside of a guild were updated.
+ ///
+ /// For bots this is always empty and useless.
+ PresencesReplace,
+ /// A reaction was added to a message.
+ ReactionAdd(Box<ReactionAdd>),
+ /// A reaction was removed from a message.
+ ReactionRemove(Box<ReactionRemove>),
+ /// All reactions were removed from a message.
+ ReactionRemoveAll(ReactionRemoveAll),
+ /// All instances of a given emoji from the reactions of a message were
+ /// removed.
+ ReactionRemoveEmoji(ReactionRemoveEmoji),
+ /// A shard is now "ready" and fully connected.
+ Ready(Box<Ready>),
+ /// A shard has successfully resumed.
+ Resumed,
+ /// A role was created in a guild.
+ RoleCreate(RoleCreate),
+ /// A role was deleted in a guild.
+ RoleDelete(RoleDelete),
+ /// A role was updated in a guild.
+ RoleUpdate(RoleUpdate),
+ /// A shard is now in a connected stage after being fully connected to the
+ /// gateway.
+ ShardConnected(Connected),
+ /// A shard is now in a connecting stage after starting to connect to the
+ /// gateway.
+ ShardConnecting(Connecting),
+ /// A shard is now in a disconnected stage after the connection was closed.
+ ShardDisconnected(Disconnected),
+ /// A shard is now in a identifying stage after starting a new session.
+ ShardIdentifying(Identifying),
+ /// A shard is now in a reconnecting stage after a disconnect or session was
+ /// ended.
+ ShardReconnecting(Reconnecting),
+ /// A payload of bytes came in through the shard's connection.
+ ShardPayload(Payload),
+ /// A shard is now in a Resuming stage after a disconnect.
+ ShardResuming(Resuming),
+ /// A stage instance was created in a stage channel.
+ StageInstanceCreate(StageInstanceCreate),
+ /// A stage instance was deleted in a stage channel.
+ StageInstanceDelete(StageInstanceDelete),
+ /// A stage instance was updated in a stage channel.
+ StageInstanceUpdate(StageInstanceUpdate),
+ /// A thread has been created, relevant to the current user,
+ /// or the current user has been added to a thread.
+ ThreadCreate(ThreadCreate),
+ /// A thread, relevant to the current user, has been deleted.
+ ThreadDelete(ThreadDelete),
+ /// The current user has gained access to a thread.
+ ThreadListSync(ThreadListSync),
+ /// The thread member object for the current user has been updated.
+ ThreadMemberUpdate(ThreadMemberUpdate),
+ /// A user has been added to or removed from a thread.
+ ThreadMembersUpdate(ThreadMembersUpdate),
+ /// A thread has been updated.
+ ThreadUpdate(ThreadUpdate),
+ /// A user started typing in a channel.
+ TypingStart(Box<TypingStart>),
+ /// A guild is now unavailable.
+ UnavailableGuild(UnavailableGuild),
+ /// The current user was updated.
+ UserUpdate(UserUpdate),
+ /// A voice server update was sent.
+ VoiceServerUpdate(VoiceServerUpdate),
+ /// A voice state in a voice channel was updated.
+ VoiceStateUpdate(Box<VoiceStateUpdate>),
+ /// A webhook was updated.
+ WebhooksUpdate(WebhooksUpdate),
+}
diff --git a/gateway/BUILD b/gateway/BUILD
index d65c913..c71c12e 100644
--- a/gateway/BUILD
+++ b/gateway/BUILD
@@ -7,10 +7,6 @@ test_suite(name = "tests")
rust_binary(
name = "gateway",
srcs = glob(["src/**/*.rs"]),
- proc_macro_deps = crate_deps([
- "serde_repr",
- "num-derive",
- ]),
visibility = ["//visibility:public"],
deps = all_crate_deps() + ["//common/rust:common"],
)
diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml
index 4afdbc2..e1e6894 100644
--- a/gateway/Cargo.toml
+++ b/gateway/Cargo.toml
@@ -5,18 +5,8 @@ edition = "2018"
[dependencies]
common = { path = "../common/rust" }
-tokio-tungstenite = { version = "*", features = ["rustls-tls"] }
tokio = { version = "1", features = ["full"] }
-
-url = "2.2.2"
-futures-util = "0.3.17"
-futures = "0.3.17"
-
-serde_json = { version = "1.0" }
-serde = { version = "1.0", features = ["derive"] }
-serde_repr = "0.1"
-enumflags2 = { version = "0.7.1", features = ["serde"] }
-
-num-traits = "0.2"
-num-derive = "0.3"
-num = "0.4"
+twilight-gateway = { version = "0.6" }
+serde = { version = "1.0.8", features = ["derive"] }
+futures = "0.3"
+serde_json = { version = "1.0" } \ No newline at end of file
diff --git a/gateway/cargo/BUILD.bazel b/gateway/cargo/BUILD.bazel
index e5271e2..8606080 100644
--- a/gateway/cargo/BUILD.bazel
+++ b/gateway/cargo/BUILD.bazel
@@ -13,15 +13,6 @@ licenses([
# Aliased targets
alias(
- name = "enumflags2",
- actual = "@raze__enumflags2__0_7_1//:enumflags2",
- tags = [
- "cargo-raze",
- "manual",
- ],
-)
-
-alias(
name = "futures",
actual = "@raze__futures__0_3_17//:futures",
tags = [
@@ -31,42 +22,6 @@ alias(
)
alias(
- name = "futures_util",
- actual = "@raze__futures_util__0_3_17//:futures_util",
- tags = [
- "cargo-raze",
- "manual",
- ],
-)
-
-alias(
- name = "num",
- actual = "@raze__num__0_4_0//:num",
- tags = [
- "cargo-raze",
- "manual",
- ],
-)
-
-alias(
- name = "num_derive",
- actual = "@raze__num_derive__0_3_3//:num_derive",
- tags = [
- "cargo-raze",
- "manual",
- ],
-)
-
-alias(
- name = "num_traits",
- actual = "@raze__num_traits__0_2_14//:num_traits",
- tags = [
- "cargo-raze",
- "manual",
- ],
-)
-
-alias(
name = "serde",
actual = "@raze__serde__1_0_130//:serde",
tags = [
@@ -85,15 +40,6 @@ alias(
)
alias(
- name = "serde_repr",
- actual = "@raze__serde_repr__0_1_7//:serde_repr",
- tags = [
- "cargo-raze",
- "manual",
- ],
-)
-
-alias(
name = "tokio",
actual = "@raze__tokio__1_12_0//:tokio",
tags = [
@@ -103,17 +49,8 @@ alias(
)
alias(
- name = "tokio_tungstenite",
- actual = "@raze__tokio_tungstenite__0_15_0//:tokio_tungstenite",
- tags = [
- "cargo-raze",
- "manual",
- ],
-)
-
-alias(
- name = "url",
- actual = "@raze__url__2_2_2//:url",
+ name = "twilight_gateway",
+ actual = "@raze__twilight_gateway__0_6_5//:twilight_gateway",
tags = [
"cargo-raze",
"manual",
diff --git a/gateway/src/config.rs b/gateway/src/config.rs
new file mode 100644
index 0000000..999892b
--- /dev/null
+++ b/gateway/src/config.rs
@@ -0,0 +1,14 @@
+use common::serde::{Deserialize, Serialize};
+use twilight_gateway::Intents;
+
+#[derive(Serialize, Deserialize, Clone)]
+pub struct Config {
+ pub token: String,
+ pub intents: Intents
+}
+
+impl Default for Config {
+ fn default() -> Self {
+ Self { intents: Intents::empty(), token: String::default() }
+ }
+}
diff --git a/gateway/src/connection/mod.rs b/gateway/src/connection/mod.rs
deleted file mode 100644
index c60068a..0000000
--- a/gateway/src/connection/mod.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use tokio::net::TcpStream;
-use tokio_tungstenite::{MaybeTlsStream, WebSocketStream, connect_async, tungstenite::http::Request};
-
-use crate::{error::GatewayError, utils::get_gateway_url};
-
-mod stream;
-mod utils;
-
-/// Underlying representation of a Discord event stream
-/// that streams the Event payloads to the shard structure
-pub struct Connection {
- /// The channel given by tokio_tungstenite that represents the websocket connection
- connection: Option<WebSocketStream<MaybeTlsStream<TcpStream>>>,
-}
-
-impl Connection {
- pub fn new() -> Self {
- Connection { connection: None }
- }
-
- pub async fn start(&mut self) -> Result<(), GatewayError> {
- let request = Request::builder()
- .uri(get_gateway_url(false, "json", 9))
- .body(())
- .unwrap();
-
- let connection_result = connect_async(request).await;
- // we connect outselves to the websocket server
- if let Err(err) = connection_result {
- Err(GatewayError::from(err))
- } else {
- self.connection = Some(connection_result.unwrap().0);
- Ok(())
- }
- }
-} \ No newline at end of file
diff --git a/gateway/src/connection/stream.rs b/gateway/src/connection/stream.rs
deleted file mode 100644
index 5a12daf..0000000
--- a/gateway/src/connection/stream.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-use crate::{error::GatewayError, payloads::gateway::BaseMessage};
-
-use super::Connection;
-use futures::{FutureExt, Sink, SinkExt, Stream, StreamExt};
-use common::log::info;
-use serde::Serialize;
-use std::{
- pin::Pin,
- task::{Context, Poll},
-};
-use tokio_tungstenite::tungstenite::Message;
-
-/// Implementation of the Stream trait for the Connection
-impl Stream for Connection {
- type Item = Result<crate::payloads::gateway::Message, GatewayError>;
-
- fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
- // first, when a poll is called, we check if the connection is still open
- if let Some(conn) = &mut self.connection {
- // we need to wait poll the message using the tokio_tungstenite stream
- let message = conn.poll_next_unpin(cx);
-
- match message {
- Poll::Ready(packet) => {
- // if data is available, we can continue
- match packet {
- Some(result) => match result {
- Ok(message) => {
- match Box::pin(self._handle_message(&message)).poll_unpin(cx) {
- Poll::Ready(data) => match data {
- Ok(d) => Poll::Ready(Some(Ok(d))),
- Err(e) => Poll::Ready(Some(Err(e))),
- },
- // unknown behaviour?
- Poll::Pending => unreachable!(),
- }
- }
- Err(e) => Poll::Ready(Some(Err(GatewayError::from(e)))),
- },
- // if no message is available, we return none, it's the end of the stream
- None => {
- info!("tokio_tungstenite stream finished successfully");
- let _ = Box::pin(conn.close(None)).poll_unpin(cx);
- self.connection = None;
- Poll::Ready(None)
- }
- }
- }
- // if the message is pending, we return the same result
- Poll::Pending => Poll::Pending,
- }
- } else {
- Poll::Ready(None)
- }
- }
-}
-
-/// Implementation of the Sink trait for the Connection
-impl<T: Serialize> Sink<BaseMessage<T>> for Connection {
- type Error = tokio_tungstenite::tungstenite::Error;
-
- #[allow(dead_code)]
- fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
- if let Some(conn) = &mut self.connection {
- // a connection exists, we can send data
- conn.poll_ready_unpin(cx)
- } else {
- Poll::Pending
- }
- }
-
- #[allow(dead_code)]
- fn start_send(mut self: Pin<&mut Self>, item: BaseMessage<T>) -> Result<(), Self::Error> {
- if let Some(conn) = &mut self.connection {
- let message = serde_json::to_string(&item);
- conn.start_send_unpin(Message::Text(message.unwrap()))
- .unwrap();
- }
- Ok(())
- }
-
- #[allow(dead_code)]
- fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
- if let Some(conn) = &mut self.connection {
- conn.poll_flush_unpin(cx)
- } else {
- Poll::Pending
- }
- }
-
- #[allow(dead_code)]
- fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
- if let Some(conn) = &mut self.connection {
- conn.poll_close_unpin(cx)
- } else {
- Poll::Pending
- }
- }
-}
diff --git a/gateway/src/connection/utils.rs b/gateway/src/connection/utils.rs
deleted file mode 100644
index bb425da..0000000
--- a/gateway/src/connection/utils.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-use std::str::from_utf8;
-use tokio_tungstenite::tungstenite::Message;
-use common::log::info;
-
-use crate::error::GatewayError;
-
-use super::Connection;
-
-impl Connection {
-
- /// Handles the websocket events and calls the _handle_discord_message function for the deserialization.
- pub(super) async fn _handle_message(
- &mut self,
- data: &Message,
- ) -> Result<crate::payloads::gateway::Message, GatewayError> {
- match data {
- Message::Text(text) => self._handle_discord_message(&text).await,
- Message::Binary(message) => {
- match from_utf8(message) {
- Ok(data) => self._handle_discord_message(data).await,
- Err(err) => Err(GatewayError::from(err.to_string())),
- }
- },
- Message::Close(close_frame) => {
- info!("Discord connection closed {:?}", close_frame);
- Err(GatewayError::from("connection closed".to_string()))
- },
- _ => Err(GatewayError::from(format!("unknown variant of message specified to the handler {}", data).to_string())),
- }
- }
-
- /// Handle the decompression and deserialization process of a discord payload.
- pub(super) async fn _handle_discord_message(
- &mut self,
- raw_message: &str,
- ) -> Result<crate::payloads::gateway::Message, GatewayError> {
- match serde_json::from_str(raw_message) {
- Ok(message) => Ok(message),
- Err(err) => Err(GatewayError::from(err.to_string())),
- }
- }
-}
diff --git a/gateway/src/error.rs b/gateway/src/error.rs
deleted file mode 100644
index eb3a245..0000000
--- a/gateway/src/error.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-use common::error::NovaError;
-
-#[derive(Debug)]
-pub struct GatewayError(NovaError);
-
-impl From<tokio_tungstenite::tungstenite::Error> for GatewayError {
- fn from(e: tokio_tungstenite::tungstenite::Error) -> Self {
- GatewayError {
- 0: NovaError {
- message: e.to_string(),
- },
- }
- }
-}
-
-impl From<String> for GatewayError {
- fn from(e: String) -> Self {
- GatewayError {
- 0: NovaError { message: e },
- }
- }
-}
diff --git a/gateway/src/main.rs b/gateway/src/main.rs
index 4c42c7a..4f67183 100644
--- a/gateway/src/main.rs
+++ b/gateway/src/main.rs
@@ -1,19 +1,60 @@
-use common::config::Settings;
-use shard::{Shard, ShardConfig};
-#[macro_use]
-extern crate num_derive;
+use common::{
+ config::Settings,
+ log::{debug, info},
+ nats_crate::Connection,
+ payloads::{CachePayload, SerializeHelper, Tracing},
+};
+use config::Config;
+use std::error::Error;
+use twilight_gateway::{Event, Shard};
+mod config;
+use futures::StreamExt;
-pub mod connection;
-mod error;
-mod utils;
-mod shard;
-mod payloads;
+#[tokio::main]
+async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
+ let settings: Settings<Config> = Settings::new("gateway").unwrap();
+ let (shard, mut events) = Shard::new(settings.config.token, settings.config.intents);
+ let nats: Connection = settings.nats.into();
+ shard.start().await?;
+ while let Some(event) = events.next().await {
+ match event {
+ Event::Ready(ready) => {
+ info!("Logged in as {}", ready.user.name);
+ }
+ Event::Resumed => {}
+ Event::GatewayHeartbeat(_) => {}
+ Event::GatewayHeartbeatAck => {}
+ Event::GatewayInvalidateSession(_) => {}
+ Event::GatewayReconnect => {}
+ Event::GatewayHello(_) => {}
-#[tokio::main]
-async fn main() {
- let settings: Settings<ShardConfig> = Settings::new("gateway").unwrap();
- let mut shard = Shard::new(settings.config);
- shard.start().await;
+ Event::ShardConnected(_) => {}
+ Event::ShardConnecting(_) => {}
+ Event::ShardDisconnected(_) => {}
+ Event::ShardIdentifying(_) => {}
+ Event::ShardReconnecting(_) => {}
+ Event::ShardPayload(_) => {}
+ Event::ShardResuming(_) => {}
+
+ _ => {
+ let data = CachePayload {
+ tracing: Tracing {
+ node_id: "".to_string(),
+ span: None,
+ },
+ data: SerializeHelper(event),
+ };
+ let value = serde_json::to_string(&data)?;
+ debug!("nats send: {}", value);
+ nats.request(
+ &format!("nova.cache.discord.{}", data.data.0.kind().name().unwrap()),
+ value,
+ )?;
+ }
+ }
+ }
+
+ Ok(())
}
diff --git a/gateway/src/payloads/dispatch.rs b/gateway/src/payloads/dispatch.rs
deleted file mode 100644
index 9eca9c5..0000000
--- a/gateway/src/payloads/dispatch.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-use serde::{Deserialize, Deserializer, Serialize};
-
-use serde_json::Value;
-
-use super::gateway::BaseMessage;
-
-#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
-pub struct Ready {
- #[serde(rename = "v")]
- pub version: u64,
- pub user: Value,
- pub guilds: Vec<Value>,
- pub session_id: String,
- pub shard: Option<[i64;2]>,
- pub application: Value,
-}
-
-#[derive(Clone, Debug, PartialEq, Deserialize)]
-#[serde(tag = "t", content = "d")]
-pub enum FakeDispatch {
- #[serde(rename = "READY")]
- Ready(Ready),
- Other(Value),
-}
-
-#[derive(Clone, Debug, PartialEq)]
-pub enum Dispatch {
- Ready(Ready),
- Other(BaseMessage<Value>)
-}
-
-impl<'de> Deserialize<'de> for Dispatch {
- fn deserialize<D>(d: D) -> Result<Self, D::Error>
- where
- D: Deserializer<'de>,
- {
- // todo: error handling
- let value = Value::deserialize(d)?;
-
- if value.get("t").unwrap() == "READY" {
- Ok(Dispatch::Ready(Ready::deserialize(value.get("d").unwrap()).unwrap()))
- } else {
- Ok(Dispatch::Other(BaseMessage::deserialize(value).unwrap()))
- }
- }
-} \ No newline at end of file
diff --git a/gateway/src/payloads/events/mod.rs b/gateway/src/payloads/events/mod.rs
deleted file mode 100644
index 3fef2d9..0000000
--- a/gateway/src/payloads/events/mod.rs
+++ /dev/null
@@ -1 +0,0 @@
-pub mod ready; \ No newline at end of file
diff --git a/gateway/src/payloads/events/ready.rs b/gateway/src/payloads/events/ready.rs
deleted file mode 100644
index a5ec291..0000000
--- a/gateway/src/payloads/events/ready.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-use serde::Deserialize;
-use serde_json::Value;
-
-#[derive(Deserialize, Clone, Debug, PartialEq)]
-pub struct Ready {
- #[serde(rename = "v")]
- pub version: u64,
- pub user: Value,
- pub guilds: Vec<Value>,
- pub session_id: String,
- pub shard: Option<[i64;2]>,
- pub application: Value,
-}
diff --git a/gateway/src/payloads/gateway.rs b/gateway/src/payloads/gateway.rs
deleted file mode 100644
index 4f24890..0000000
--- a/gateway/src/payloads/gateway.rs
+++ /dev/null
@@ -1,78 +0,0 @@
-use super::{
- dispatch::Dispatch,
- opcodes::{hello::Hello, OpCodes},
-};
-use serde::de::Error;
-use serde::{Deserialize, Serialize};
-use serde_json::Value;
-
-#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
-#[serde(bound(deserialize = "T: Deserialize<'de> + std::fmt::Debug"))]
-pub struct BaseMessage<T> {
- pub t: Option<String>,
- #[serde(rename = "s")]
- pub sequence: Option<u64>,
- pub op: OpCodes,
- #[serde(rename = "d")]
- pub data: T,
-}
-
-#[derive(Debug)]
-pub enum Message {
- Dispatch(BaseMessage<Dispatch>),
- Reconnect(BaseMessage<()>),
- InvalidSession(BaseMessage<bool>),
- Hello(BaseMessage<Hello>),
- HeartbeatACK(BaseMessage<()>),
-}
-
-impl<'de> serde::Deserialize<'de> for Message {
- fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error>
- where
- D::Error: Error,
- {
- let value = Value::deserialize(d)?;
- let val = value.get("op").and_then(Value::as_u64).unwrap();
-
- if let Some(op) = num::FromPrimitive::from_u64(val) {
- match op {
- OpCodes::Dispatch => {
- // todo: remove unwrap
- let t = Some(value.get("t").unwrap().to_string());
- let sequence = value.get("s").unwrap().as_u64();
-
- // we need to find a better solution than clone
- match Dispatch::deserialize(value) {
- Ok(data) => Ok(Message::Dispatch(BaseMessage {
- op,
- t,
- sequence,
- data,
- })),
- Err(e) => Err(Error::custom(e)),
- }
- }
-
- OpCodes::Reconnect => match BaseMessage::deserialize(value) {
- Ok(data) => Ok(Message::Reconnect(data)),
- Err(e) => Err(Error::custom(e)),
- },
- OpCodes::InvalidSession => match BaseMessage::deserialize(value) {
- Ok(data) => Ok(Message::InvalidSession(data)),
- Err(e) => Err(Error::custom(e)),
- },
- OpCodes::Hello => match BaseMessage::deserialize(value) {
- Ok(data) => Ok(Message::Hello(data)),
- Err(e) => Err(Error::custom(e)),
- },
- OpCodes::HeartbeatACK => match BaseMessage::deserialize(value) {
- Ok(data) => Ok(Message::HeartbeatACK(data)),
- Err(e) => Err(Error::custom(e)),
- },
- _ => panic!("Cannot convert"),
- }
- } else {
- Err(Error::custom("unknown opcode"))
- }
- }
-}
diff --git a/gateway/src/payloads/mod.rs b/gateway/src/payloads/mod.rs
deleted file mode 100644
index e9849a7..0000000
--- a/gateway/src/payloads/mod.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-pub mod opcodes;
-pub mod dispatch;
-pub mod gateway;
-pub mod events;
diff --git a/gateway/src/payloads/opcodes/hello.rs b/gateway/src/payloads/opcodes/hello.rs
deleted file mode 100644
index 3d8fd0f..0000000
--- a/gateway/src/payloads/opcodes/hello.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-use serde::{Serialize, Deserialize};
-
-/// The first message sent by the gateway to initialize the heartbeating
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Hello {
- #[serde(rename = "heartbeat_interval")]
- pub heartbeat_interval: u64
-}
diff --git a/gateway/src/payloads/opcodes/identify.rs b/gateway/src/payloads/opcodes/identify.rs
deleted file mode 100644
index 5929c33..0000000
--- a/gateway/src/payloads/opcodes/identify.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use enumflags2::{BitFlags, bitflags};
-use serde::{Deserialize, Serialize};
-use super::presence::PresenceUpdate;
-
-
-#[bitflags]
-#[repr(u16)]
-#[derive(Clone, Copy, Debug)]
-pub enum Intents {
- Guilds = 1 << 0,
- GuildMembers = 1 << 1,
- GuildBans = 1 << 2,
- GuildEmojisAndStickers = 1 << 3,
- GuildIntegrations = 1 << 4,
- GuildWebhoks = 1 << 5,
- GuildInvites = 1 << 6,
- GuildVoiceStates = 1 << 7,
- GuildPresences = 1 << 8,
- GuildMessages = 1 << 9,
- GuildMessagesReactions = 1 << 10,
- GuildMessageTyping = 1 << 11,
- DirectMessages = 1 << 12,
- DirectMessagesReactions = 1 << 13,
- DirectMessageTyping = 1 << 14,
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct IdentifyProprerties {
- #[serde(rename = "$os")]
- pub os: String,
- #[serde(rename = "$browser")]
- pub browser: String,
- #[serde(rename = "$device")]
- pub device: String,
-}
-
-/// Messages sent by the shard to log-in to the gateway.
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Identify {
- pub token: String,
- pub properties: IdentifyProprerties,
- pub compress: Option<bool>,
- pub large_threshold: Option<u64>,
- pub shard: Option<[u64; 2]>,
- pub presence: Option<PresenceUpdate>,
- pub intents: BitFlags<Intents>,
-} \ No newline at end of file
diff --git a/gateway/src/payloads/opcodes/mod.rs b/gateway/src/payloads/opcodes/mod.rs
deleted file mode 100644
index cfa453a..0000000
--- a/gateway/src/payloads/opcodes/mod.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-pub mod hello;
-pub mod identify;
-pub mod resume;
-pub mod presence;
-use serde_repr::{Deserialize_repr, Serialize_repr};
-
-#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone, FromPrimitive, ToPrimitive)]
-#[repr(u8)]
-
-pub enum OpCodes {
- Dispatch = 0,
- Heartbeat = 1,
- Identify = 2,
- PresenceUpdate = 3,
- VoiceStateUpdate = 4,
- Resume = 6,
- Reconnect = 7,
- RequestGuildMembers = 8,
- InvalidSession = 9,
- Hello = 10,
- HeartbeatACK = 11,
-} \ No newline at end of file
diff --git a/gateway/src/payloads/opcodes/presence.rs b/gateway/src/payloads/opcodes/presence.rs
deleted file mode 100644
index a6c5773..0000000
--- a/gateway/src/payloads/opcodes/presence.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-use serde_repr::{Deserialize_repr, Serialize_repr};
-use serde::{Deserialize, Serialize};
-#[derive(Serialize_repr, Deserialize_repr, Debug)]
-#[repr(u8)]
-pub enum ActivityType {
- Game = 0,
- Streaming = 1,
- Listening = 2,
- Watching = 3,
- Custom = 4,
- Competing = 5
-}
-
-#[derive(Serialize, Deserialize, Debug)]
-pub struct ActivityTimestamps {
- start: u64,
- end: u64,
-}
-
-#[derive(Serialize, Deserialize, Debug)]
-pub struct ActivityEmoji {
- name: String,
- id: Option<String>,
- animated: Option<bool>
-}
-
-#[derive(Serialize, Deserialize, Debug)]
-pub struct Activity {
- name: String,
- #[serde(rename = "type")]
- t: ActivityType,
-
- url: Option<String>,
- created_at: i64,
- timestamp: Option<ActivityTimestamps>,
- application_id: Option<String>,
- details: Option<String>,
- state: Option<String>,
- emoji: Option<ActivityEmoji>,
- // todo: implement more
-}
-
-#[derive(Serialize, Deserialize, Debug)]
-pub enum PresenceStatus {
- #[serde(rename = "online")]
- Online,
- #[serde(rename = "dnd")]
- Dnd,
- #[serde(rename = "idle")]
- Idle,
- #[serde(rename = "invisible")]
- Invisible,
- #[serde(rename = "offline")]
- Offline
-}
-
-#[derive(Serialize, Deserialize, Debug)]
-pub struct PresenceUpdate {
- since: u64,
- activities: Vec<Activity>,
- status: PresenceStatus,
- afk: bool,
-}
diff --git a/gateway/src/payloads/opcodes/resume.rs b/gateway/src/payloads/opcodes/resume.rs
deleted file mode 100644
index e1bba91..0000000
--- a/gateway/src/payloads/opcodes/resume.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-use serde::{Deserialize, Serialize};
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Resume {
- pub token: String,
- pub session_id: String,
- pub seq: u64,
-} \ No newline at end of file
diff --git a/gateway/src/shard/actions.rs b/gateway/src/shard/actions.rs
deleted file mode 100644
index 39a7ca2..0000000
--- a/gateway/src/shard/actions.rs
+++ /dev/null
@@ -1,132 +0,0 @@
-use std::env;
-
-use futures::SinkExt;
-use common::log::{debug, error, info};
-use serde::Serialize;
-use serde_json::Value;
-use std::fmt::Debug;
-
-use crate::{
- error::GatewayError,
- payloads::{
- gateway::BaseMessage,
- opcodes::{
- identify::{Identify, IdentifyProprerties},
- presence::PresenceUpdate,
- resume::Resume,
- OpCodes,
- },
- },
-};
-
-use super::Shard;
-
-/// Implement the available actions for nova in the gateway.
-impl Shard {
- /// sends a message through the websocket
- pub async fn _send<T: Serialize + Debug>(
- &mut self,
- message: BaseMessage<T>,
- ) -> Result<(), GatewayError> {
- debug!("Senging message {:?}", message);
- if let Some(connection) = &mut self.connection {
- if let Err(e) = connection.conn.send(message).await {
- error!("failed to send message {:?}", e);
- Err(GatewayError::from(e))
- } else {
- Ok(())
- }
- } else {
- Err(GatewayError::from("no open connection".to_string()))
- }
- }
-
- pub async fn _identify(&mut self) -> Result<(), GatewayError> {
- if let Some(state) = self.state.clone() {
- info!("Using session");
- self._send(BaseMessage {
- t: None,
- sequence: None,
- op: OpCodes::Resume,
- data: Resume {
- token: self.config.token.clone(),
- seq: state.sequence,
- session_id: state.session_id.clone(),
- },
- })
- .await
- } else {
- info!("Sending login");
- let mut shards: Option<[u64; 2]> = None;
- if let Some(sharding) = self.config.shard.as_ref() {
- shards = Some([sharding.current_shard, sharding.total_shards]);
- }
- self._send(BaseMessage {
- t: None,
- sequence: None,
- op: OpCodes::Identify,
- data: Identify {
- token: self.config.token.clone(),
- intents: self.config.intents,
- properties: IdentifyProprerties {
- os: env::consts::OS.to_string(),
- browser: "Nova".to_string(),
- device: "Nova".to_string(),
- },
- shard: shards,
- compress: Some(false),
- large_threshold: Some(500),
- presence: None,
- },
- })
- .await
- }
- }
-
- pub async fn _disconnect(&mut self) {}
-
- /// Updates the presence of the current shard.
- #[allow(dead_code)]
- pub async fn presence_update(&mut self, update: PresenceUpdate) -> Result<(), GatewayError> {
- self._send(BaseMessage {
- t: None,
- sequence: None,
- op: OpCodes::PresenceUpdate,
- data: update,
- })
- .await
- }
- /// Updates the voice status of the current shard in a certain channel.
- #[allow(dead_code)]
- pub async fn voice_state_update(&mut self) -> Result<(), GatewayError> {
- self._send(BaseMessage {
- t: None,
- sequence: None,
- op: OpCodes::VoiceStateUpdate,
- // todo: proper payload for this
- data: Value::Null,
- })
- .await
- }
- /// Ask discord for more informations about offline guild members.
- #[allow(dead_code)]
- pub async fn request_guild_members(&mut self) -> Result<(), GatewayError> {
- self._send(BaseMessage {
- t: None,
- sequence: None,
- op: OpCodes::RequestGuildMembers,
- // todo: proper payload for this
- data: Value::Null,
- })
- .await
- }
-
- pub async fn _send_heartbeat(&mut self) -> Result<(), GatewayError> {
- self._send(BaseMessage {
- t: None,
- sequence: None,
- op: OpCodes::Heartbeat,
- data: self.state.as_ref().unwrap().sequence
- }).await
- }
-}
diff --git a/gateway/src/shard/connection.rs b/gateway/src/shard/connection.rs
deleted file mode 100644
index 8f8ddc6..0000000
--- a/gateway/src/shard/connection.rs
+++ /dev/null
@@ -1,193 +0,0 @@
-use std::{cmp::min, convert::TryInto, time::Duration};
-
-use crate::{connection::Connection, error::GatewayError, payloads::{
- dispatch::Dispatch,
- gateway::{BaseMessage, Message},
- }, shard::state::SessionState};
-
-use super::{state::ConnectionState, ConnectionWithState, Shard};
-use futures::StreamExt;
-use common::log::{error, info};
-use tokio::{select, time::{Instant, interval_at, sleep}};
-
-impl Shard {
- pub async fn start(self: &mut Self) {
- let mut reconnects = 1;
- info!("Starting shard");
-
- while reconnects < self.config.max_reconnects {
- info!("Starting connection for shard");
- if let Err(e) = self._shard_task().await {
- error!("Gateway status: {:?}", e);
- }
- // when the shard got disconnected, the shard task ends
- reconnects += 1;
-
- // wait reconnects min(max(reconnects * reconnect_delay_growth_factor, reconnect_delay_minimum),reconnect_delay_maximum)
- if reconnects < self.config.max_reconnects {
- let time = min(
- self.config.reconnect_delay_maximum,
- self.config.reconnect_delay_minimum * (((reconnects - 1) as f32) * self.config.reconnect_delay_growth_factor) as usize,
- );
- info!(
- "The shard got disconnected, waiting for reconnect ({}ms)",
- time
- );
- sleep(Duration::from_millis(time.try_into().unwrap())).await;
- }
- }
- info!(
- "The shard got disconnected too many times and reached the maximum {}",
- self.config.max_reconnects
- );
- }
-
- async fn _shard_task(&mut self) -> Result<(), GatewayError> {
- // create the new connection
- let mut connection = Connection::new();
- connection.start().await.unwrap();
- self.connection = Some(ConnectionWithState {
- conn: connection,
- state: ConnectionState::new(),
- });
-
- loop {
- if let Some(connection) = &mut self.connection {
- if let Some(timer) = &mut connection.state.interval {
- select!(
- payload = connection.conn.next() => {
- match payload {
- Some(data) => match data {
- Ok(message) => self._handle(&message).await,
- Err(error) => {
- return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string()));
- },
- },
- None => {
- return Err(GatewayError::from("Connection terminated".to_string()));
- },
- }
- },
- _ = timer.tick() => match self._do_heartbeat().await {
- Ok(_) => {},
- Err(error) => {
- return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string()));
- },
- }
- )
- } else {
- select!(
- payload = connection.conn.next() => {
- match payload {
- Some(data) => match data {
- Ok(message) => self._handle(&message).await,
- Err(error) => {
- return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string()));
- },
- },
- None => {
- return Err(GatewayError::from("Connection terminated".to_string()));
- },
- }
- }
- )
- }
-
- }
- }
- }
-
- async fn _do_heartbeat(&mut self) -> Result<(), GatewayError> {
- info!("heartbeat sent");
- if let Some(conn) = &mut self.connection {
- if !conn.state.last_heartbeat_acknowledged {
- error!("we missed a hertbeat");
- Err(GatewayError::from("a hertbeat was dropped, we need to restart the connection".to_string()))
- } else {
- conn.state.last_heartbeat_acknowledged = false;
- conn.state.last_heartbeat_time = Instant::now();
- self._send_heartbeat().await
- }
- } else {
- unreachable!()
- }
- }
-
- fn _util_set_seq(&mut self, seq: Option<u64>) {
- if let Some(seq) = seq {
- if let Some(state) = &mut self.state {
- state.sequence = seq;
- }
- }
- }
-
- async fn _handle(&mut self, message: &Message) {
- match message {
- Message::Dispatch(msg) => {
- self._util_set_seq(msg.sequence);
- self._dispatch(&msg).await;
- }
- // we need to reconnect to the gateway
- Message::Reconnect(msg) => {
- self._util_set_seq(msg.sequence);
- info!("Gateway disconnect requested");
- self._disconnect().await;
- }
- Message::InvalidSession(msg) => {
- self._util_set_seq(msg.sequence);
- info!("invalid session");
- let data = msg.data;
- if !data {
- info!("Session removed");
- // reset the session data
- self.state = None;
- if let Err(e) = self._identify().await {
- error!("Error while sending identify: {:?}", e);
- }
- }
- }
- Message::HeartbeatACK(msg) => {
- info!("Heartbeat ack received");
- self._util_set_seq(msg.sequence);
- if let Some(conn) = &mut self.connection {
- conn.state.last_heartbeat_acknowledged = true;
- let latency = Instant::now() - conn.state.last_heartbeat_time;
- info!("Latency updated {}ms", latency.as_millis());
- }
- }
- Message::Hello(msg) => {
- info!("Server hello received");
- self._util_set_seq(msg.sequence);
- if let Some(conn) = &mut self.connection {
- conn.state.interval = Some(interval_at(
- Instant::now() + Duration::from_millis(msg.data.heartbeat_interval),
- Duration::from_millis(msg.data.heartbeat_interval),
- ));
- }
-
- if let Err(e) = self._identify().await {
- error!("error while sending identify: {:?}", e);
- }
- },
- }
- }
-
- async fn _dispatch(&mut self, dispatch: &BaseMessage<Dispatch>) {
- match &dispatch.data {
- Dispatch::Ready(ready) => {
- info!("Received gateway dispatch ready");
- info!(
- "Logged in as {}",
- ready.user.get("username").unwrap().to_string()
- );
- self.state = Some(SessionState {
- sequence: dispatch.sequence.unwrap(),
- session_id: ready.session_id.clone(),
- });
- }
- Dispatch::Other(_data) => {
- // todo: build dispatch & forward to nats
- }
- }
- }
-}
diff --git a/gateway/src/shard/mod.rs b/gateway/src/shard/mod.rs
deleted file mode 100644
index 55828d0..0000000
--- a/gateway/src/shard/mod.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-use enumflags2::BitFlags;
-use serde::{Deserialize, Serialize};
-use crate::{connection::Connection, payloads::opcodes::identify::Intents};
-use self::state::{ConnectionState, SessionState};
-mod actions;
-mod connection;
-mod state;
-
-#[derive(Debug, Deserialize, Serialize, Default, Clone)]
-pub struct Sharding {
- pub total_shards: u64,
- pub current_shard: u64
-}
-
-#[derive(Debug, Deserialize, Serialize, Default, Clone)]
-pub struct ShardConfig {
- pub max_reconnects: usize,
- pub reconnect_delay_growth_factor: f32,
- pub reconnect_delay_minimum: usize,
- pub reconnect_delay_maximum: usize,
- pub token: String,
-
- pub large_threshold: Option<u64>,
- pub shard: Option<Sharding>,
- pub intents: BitFlags<Intents>
-}
-
-struct ConnectionWithState {
- conn: Connection,
- state: ConnectionState,
-}
-
-/// Represents a shard & all the reconnection logic related to it
-pub struct Shard {
- connection: Option<ConnectionWithState>,
- state: Option<SessionState>,
- config: ShardConfig
-}
-
-impl Shard {
- /// Creates a new shard instance
- pub fn new(config: ShardConfig) -> Self {
- Shard {
- connection: None,
- state: None,
- config,
- }
- }
-}
diff --git a/gateway/src/shard/state.rs b/gateway/src/shard/state.rs
deleted file mode 100644
index 34b7acc..0000000
--- a/gateway/src/shard/state.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-use tokio::time::{Instant, Interval};
-
-/// This struct represents the state of a session
-#[derive(Clone, Debug)]
-pub struct SessionState {
- pub sequence: u64,
- pub session_id: String,
-}
-
-impl Default for SessionState {
- fn default() -> Self {
- Self {
- sequence: Default::default(),
- session_id: Default::default(),
- }
- }
-}
-
-/// This struct represents the state of a connection
-#[derive(Debug)]
-pub struct ConnectionState {
- pub last_heartbeat_acknowledged: bool,
- pub last_heartbeat_time: Instant,
- pub interval: Option<Interval>,
-
-}
-impl ConnectionState {
- pub fn new() -> Self {
- Self {
- last_heartbeat_acknowledged: true,
- last_heartbeat_time: Instant::now(),
- interval: None,
- }
- }
-} \ No newline at end of file
diff --git a/gateway/src/utils.rs b/gateway/src/utils.rs
deleted file mode 100644
index 48a9aed..0000000
--- a/gateway/src/utils.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-/// Formats a url of connection to the gateway
-pub fn get_gateway_url (compress: bool, encoding: &str, v: i16) -> String {
- return format!(
- "wss://gateway.discord.gg/?v={}&encoding={}&compress={}",
- v, encoding,
- if compress { "zlib-stream" } else { "" }
- );
-} \ No newline at end of file
diff --git a/webhook/Cargo.toml b/webhook/Cargo.toml
index 24c68f8..e4c8075 100644
--- a/webhook/Cargo.toml
+++ b/webhook/Cargo.toml
@@ -14,6 +14,7 @@ libc = "0.2.101"
lazy_static = "1.4.0"
ctor = "0.1.21"
ed25519-dalek = "1"
+twilight-model = { version = "0.6" }
rand = "0.7"
[[bin]]
diff --git a/webhook/cargo/BUILD.bazel b/webhook/cargo/BUILD.bazel
index 77bc34f..0d8caf1 100644
--- a/webhook/cargo/BUILD.bazel
+++ b/webhook/cargo/BUILD.bazel
@@ -101,3 +101,12 @@ alias(
"manual",
],
)
+
+alias(
+ name = "twilight_model",
+ actual = "@raze__twilight_model__0_6_5//:twilight_model",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
diff --git a/webhook/src/handler/error.rs b/webhook/src/handler/error.rs
index f998b84..d4fee07 100644
--- a/webhook/src/handler/error.rs
+++ b/webhook/src/handler/error.rs
@@ -1,4 +1,4 @@
-use hyper::{Body, Response, StatusCode};
+use hyper::{header::ToStrError, Body, Response, StatusCode};
pub struct WebhookError {
pub code: StatusCode,
@@ -22,3 +22,15 @@ impl Into<Response<Body>> for WebhookError {
.unwrap()
}
}
+
+impl From<hyper::Error> for WebhookError {
+ fn from(_: hyper::Error) -> Self {
+ WebhookError::new(StatusCode::BAD_REQUEST, "invalid request")
+ }
+}
+
+impl From<ToStrError> for WebhookError {
+ fn from(_: ToStrError) -> Self {
+ WebhookError::new(StatusCode::BAD_REQUEST, "invalid request")
+ }
+}
diff --git a/webhook/src/handler/handler.rs b/webhook/src/handler/handler.rs
index e54b5ee..97300e4 100644
--- a/webhook/src/handler/handler.rs
+++ b/webhook/src/handler/handler.rs
@@ -1,10 +1,10 @@
use super::error::WebhookError;
use super::signature::validate_signature;
use crate::config::Config;
-use common::discord_models::slash_commands::{Interaction, InteractionRequestType};
use common::log::{debug, error};
use common::nats_crate::Connection;
-use common::payloads::CacheData;
+use common::payloads::SerializeHelper;
+use ed25519_dalek::PublicKey;
use hyper::{
body::{to_bytes, Bytes},
service::Service,
@@ -19,54 +19,50 @@ use std::{
task::{Context, Poll},
time::Duration,
};
-use ed25519_dalek::PublicKey;
+use twilight_model::application::interaction::Interaction;
+use twilight_model::gateway::event::Event;
+use twilight_model::gateway::payload::InteractionCreate;
/// Hyper service used to handle the discord webhooks
#[derive(Clone)]
pub struct HandlerService {
pub config: Arc<Config>,
pub nats: Arc<Connection>,
- pub public_key: Arc<PublicKey>
+ pub public_key: Arc<PublicKey>,
}
impl HandlerService {
async fn check_request(&self, req: Request<Body>) -> Result<Bytes, WebhookError> {
if req.method() == Method::POST {
- let headers = req.headers().clone();
- let signature = headers.get("X-Signature-Ed25519");
- let timestamp = headers.get("X-Signature-Timestamp");
- if let (Some(timestamp), Some(signature)) = (timestamp, signature) {
- if let Ok(data) = to_bytes(req.into_body()).await {
- let contatenated_data = [timestamp.as_bytes().to_vec(), data.to_vec()].concat();
- if let Ok(signature_str) = &signature.to_str() {
- if validate_signature(
- &self.public_key,
- &contatenated_data,
- signature_str,
- ) {
- Ok(data)
- } else {
- Err(WebhookError::new(
- StatusCode::UNAUTHORIZED,
- "invalid signature",
- ))
- }
- } else {
- Err(WebhookError::new(
- StatusCode::BAD_REQUEST,
- "failed to read signature",
- ))
- }
- } else {
- Err(WebhookError::new(
- StatusCode::BAD_REQUEST,
- "unable to read body",
- ))
- }
+ let signature = if let Some(sig) = req.headers().get("X-Signature-Ed25519") {
+ sig.to_owned()
+ } else {
+ return Err(WebhookError::new(
+ StatusCode::BAD_REQUEST,
+ "missing signature header",
+ ));
+ };
+
+ let timestamp = if let Some(timestamp) = req.headers().get("X-Signature-Timestamp") {
+ timestamp.to_owned()
+ } else {
+ return Err(WebhookError::new(
+ StatusCode::BAD_REQUEST,
+ "missing timestamp header",
+ ));
+ };
+ let data = to_bytes(req.into_body()).await?;
+
+ if validate_signature(
+ &self.public_key,
+ &[timestamp.as_bytes().to_vec(), data.to_vec()].concat(),
+ signature.to_str()?,
+ ) {
+ Ok(data)
} else {
Err(WebhookError::new(
StatusCode::UNAUTHORIZED,
- "missing signature headers",
+ "invalid signature",
))
}
} else {
@@ -83,8 +79,8 @@ impl HandlerService {
let utf8 = from_utf8(&data);
match utf8 {
Ok(data) => match serde_json::from_str::<Interaction>(data) {
- Ok(value) => match value.type_ {
- InteractionRequestType::Ping => Ok(Response::builder()
+ Ok(value) => match value {
+ Interaction::Ping(_) => Ok(Response::builder()
.header("Content-Type", "application/json")
.body(serde_json::to_string(&Ping { t: 1 }).unwrap().into())
.unwrap()),
@@ -97,9 +93,9 @@ impl HandlerService {
node_id: "".to_string(),
span: None,
},
- data: CacheData::InteractionCreate {
- interaction: Box::new(value),
- },
+ data: SerializeHelper(Event::InteractionCreate(
+ Box::new(InteractionCreate(value)),
+ )),
})
.unwrap();
@@ -127,10 +123,10 @@ impl HandlerService {
Err(error) => {
error!("invalid json body: {}", error);
Err(WebhookError::new(
- StatusCode::BAD_REQUEST,
- "invalid json body",
+ StatusCode::BAD_REQUEST,
+ "invalid json body",
))
- },
+ }
},
Err(_) => Err(WebhookError::new(StatusCode::BAD_REQUEST, "not utf-8 body")),
diff --git a/webhook/src/handler/tests/handler_integration.rs b/webhook/src/handler/tests/handler_integration.rs
index 906b347..b5204fb 100644
--- a/webhook/src/handler/tests/handler_integration.rs
+++ b/webhook/src/handler/tests/handler_integration.rs
@@ -101,7 +101,7 @@ unsafe fn destroy() {
#[tokio::test]
async fn respond_to_pings() {
- let ping = json!({ "type": 1, "id": "0", "application_id": "0", "token": "random token", "version": 1 }).to_string();
+ let ping = json!({ "type": 1, "id": "0", "application_id": "0", "token": "random token", "version": 1, "channel_id": "123" }).to_string();
let timestamp = "my datetime :)";
let signature_data = [timestamp.as_bytes().to_vec(), ping.as_bytes().to_vec()].concat();
let signature = sign_message(signature_data, &TEST_KEYPAIR);
@@ -113,6 +113,7 @@ async fn respond_to_pings() {
.header("X-Signature-Timestamp", timestamp)
.body(Body::from(ping.clone()))
.expect("request builder");
+
let client = hyper::client::Client::new();
let result = client.request(req).await.unwrap();
@@ -121,7 +122,7 @@ async fn respond_to_pings() {
#[tokio::test]
async fn deny_invalid_signatures() {
- let ping = json!({ "type": 1, "id": "0", "application_id": "0", "token": "random token", "version": 1 }).to_string();
+ let ping = json!({ "type": 1, "id": "0", "application_id": "0", "token": "random token", "version": 1, "channel_id": "123" }).to_string();
let timestamp = "my datetime :)";
let req = Request::builder()
@@ -138,7 +139,19 @@ async fn deny_invalid_signatures() {
#[tokio::test]
async fn response_500_when_no_nats_response() {
- let ping = json!({ "type": 2, "id": "0", "application_id": "0", "token": "random token", "version": 1 }).to_string();
+ let ping = json!({
+ "type": 2,
+ "id": "0",
+ "application_id": "0",
+ "token": "random token",
+ "version": 1,
+ "channel_id": "123",
+ "data": {
+ "id": "0",
+ "name": "command"
+ }
+ }).to_string();
+
let timestamp = "my datetime :)";
let signature_data = [timestamp.as_bytes().to_vec(), ping.as_bytes().to_vec()].concat();
let signature = sign_message(signature_data, &TEST_KEYPAIR);
@@ -164,7 +177,19 @@ async fn respond_from_nats_response() {
nats = SETTINGS.clone().unwrap().nats.into();
}
let sub = nats.subscribe("nova.cache.dispatch.interaction").unwrap();
- let ping = json!({ "type": 2, "id": "0", "application_id": "0", "token": "random token", "version": 1 }).to_string();
+ let ping = json!({
+ "type": 2,
+ "id": "0",
+ "application_id": "0",
+ "token": "random token",
+ "version": 1,
+ "channel_id": "123",
+ "data": {
+ "id": "0",
+ "name": "command"
+ }
+ }).to_string();
+
let timestamp = "my datetime :)";
let signature_data = [timestamp.as_bytes().to_vec(), ping.as_bytes().to_vec()].concat();
let signature = sign_message(signature_data, &TEST_KEYPAIR);
@@ -182,6 +207,7 @@ async fn respond_from_nats_response() {
.header("X-Signature-Timestamp", timestamp)
.body(Body::from(ping.clone()))
.expect("request builder");
+
let client = hyper::client::Client::new();
let result = client.request(req).await.unwrap();
assert_eq!(result.status(), StatusCode::OK);
@@ -201,6 +227,7 @@ async fn response_400_when_invalid_json_body() {
.header("X-Signature-Timestamp", timestamp)
.body(Body::from(ping.clone()))
.expect("request builder");
+
let client = hyper::client::Client::new();
let result = client.request(req).await.unwrap();
assert_eq!(result.status(), StatusCode::BAD_REQUEST);