Disable push notificaiton on certain errors
This commit is contained in:
4 files changed
+32
-11
No files matched your search
Generated
+7
-5
@@ -1697,6 +1697,7 @@ dependencies = [
|
||||
"md5",
|
||||
"neolink_core",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"rumqttc",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -2251,9 +2252,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.18"
|
||||
version = "0.11.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55"
|
||||
checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1"
|
||||
dependencies = [
|
||||
"base64 0.21.2",
|
||||
"bytes",
|
||||
@@ -3500,11 +3501,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.10.1"
|
||||
version = "0.50.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||
checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
"cfg-if",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -32,6 +32,7 @@ log = { version = "0.4.17", features = [ "release_max_level_debug" ] }
|
||||
md5 = "0.7.0"
|
||||
neolink_core = { path = "crates/core", version = "0.6.2" }
|
||||
regex = "1.7.3"
|
||||
reqwest = "0.11.20"
|
||||
rumqttc = "0.22.0"
|
||||
serde = { version = "1.0.160", features = ["derive"] }
|
||||
serde_json = "1.0.96"
|
||||
|
||||
+11
@@ -14,6 +14,15 @@ WORKDIR /usr/local/src/neolink
|
||||
COPY . /usr/local/src/neolink
|
||||
|
||||
# Build the main program or copy from artifact
|
||||
#
|
||||
# We prefer building from artifact to reduce
|
||||
# build time on the github runners
|
||||
#
|
||||
# Because of this through, during normal
|
||||
# github runner ops we are not testing the
|
||||
# docker to see if it will build from scratch
|
||||
# so if it is failing please make a PR
|
||||
#
|
||||
# hadolint ignore=DL3008
|
||||
RUN echo "TARGETPLATFORM: ${TARGETPLATFORM}"; \
|
||||
if [ -f "${TARGETPLATFORM}/neolink" ]; then \
|
||||
@@ -25,6 +34,8 @@ RUN echo "TARGETPLATFORM: ${TARGETPLATFORM}"; \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
openssl \
|
||||
ca-certificates \
|
||||
libgstrtspserver-1.0-dev \
|
||||
libgstreamer1.0-dev \
|
||||
libgtk2.0-dev \
|
||||
|
||||
+13
-6
@@ -113,19 +113,26 @@ impl PushNotiThread {
|
||||
v = async {
|
||||
let r = listener.connect().await;
|
||||
if let Err(e) = r {
|
||||
// Wipe data so next call is a new token
|
||||
token_path.map(|token_path|
|
||||
fs::write(token_path, "")
|
||||
);
|
||||
use fcm_push_listener::Error::*;
|
||||
match &e {
|
||||
MissingMessagePayload | MissingCryptoMetadata | ProtobufDecode(_) | Base64Decode(_) => {
|
||||
// Wipe data so next call is a new token
|
||||
token_path.map(|token_path|
|
||||
fs::write(token_path, "")
|
||||
);
|
||||
log::debug!("Error on push notification listener: {:?}. Clearing token", e);
|
||||
AnyResult::Ok(()) // Allow to restart
|
||||
},
|
||||
Http(e) if e.is_request() || e.is_connect() || e.is_timeout() => {
|
||||
log::debug!("Error on push notification listener: {:?}", e);
|
||||
AnyResult::Ok(()) // Allow to restart
|
||||
}
|
||||
_ => {
|
||||
log::warn!("Error on push notification listener: {:?}. Clearing token", e);
|
||||
Err(e.into()) // Propegate error so it breaks
|
||||
log::warn!("Error on push notification listener: {:?}", e);
|
||||
// Err(e.into()) // Propegate error so it breaks
|
||||
// Wait forever since it will not work
|
||||
// we just leave the push notificaitons as disabled
|
||||
futures::future::pending().await
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user