+
Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

weak auras fixes #470

Merged
merged 3 commits into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ and `Removed`.

## [Unreleased]

### Fixed

- Parsing error causing WeakAuras to fail parsing due to missing "version" field
- Incorrect percent encoding in WeakAuras API calls causing auras to not display

## [0.6.1] - 2021-01-02

### Added
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/weak_auras/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async-std = { version = "1.6", features = ["unstable"] }
futures = "0.3"
isahc = { version = "0.9.6", features = ["json"] }
mlua = { version = "0.4", features = ["lua53", "vendored"] }
percent-encoding = "2.1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1.0"
Expand Down
19 changes: 12 additions & 7 deletions crates/weak_auras/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use futures::future;
use isahc::http;
use isahc::ResponseExt;
use mlua::{prelude::*, Value};
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use serde::Deserialize;

use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -97,16 +98,16 @@ pub async fn parse_auras(wtf_path: impl AsRef<Path>, account: String) -> Result<
return Ok(vec![]);
}

let slugs = displays
let encoded_slugs = displays
.iter()
.map(|a| a.slug.clone())
.map(|a| utf8_percent_encode(&a.slug, NON_ALPHANUMERIC).to_string())
.collect::<HashSet<_>>()
.into_iter()
.collect::<Vec<_>>();

let url = format!(
"https://data.wago.io/api/check/weakauras?ids={}",
slugs.join(",")
encoded_slugs.join(",")
);

let mut response = request_async(url, vec![], Some(30)).await?;
Expand Down Expand Up @@ -159,7 +160,8 @@ pub async fn get_aura_updates(auras: &[Aura]) -> Result<Vec<AuraUpdate>, Error>
}

async fn get_encoded_update(slug: &str) -> Result<String, Error> {
let url = format!("https://data.wago.io/api/raw/encoded?id={}", slug);
let encoded_slug = utf8_percent_encode(slug, NON_ALPHANUMERIC);
let url = format!("https://data.wago.io/api/raw/encoded?id={}", encoded_slug);

Ok(request_async(url, vec![], Some(30))
.await?
Expand Down Expand Up @@ -311,7 +313,7 @@ impl Aura {
}

pub fn installed_version(&self) -> Option<u16> {
self.parent_display().map(|d| d.version)
self.parent_display().and_then(|d| d.version)
}

pub fn remote_version(&self) -> u16 {
Expand Down Expand Up @@ -378,7 +380,7 @@ struct AuraChangelog {
struct AuraDisplay {
url: String,
slug: String,
version: u16,
version: Option<u16>,
version_string: Option<String>,
parent: Option<String>,
id: String,
Expand All @@ -405,12 +407,15 @@ impl<'lua> FromLua<'lua> for MaybeAuraDisplay {
path.next();

let slug = path.next();
let version = path.next().map(str::parse::<u16>).and_then(Result::ok);

if let Some(slug) = slug {
let parent = table.get("parent")?;
let id = table.get("id")?;
let uid = table.get("uid")?;
let version = table.get("version")?;
let version = table
.get::<_, Option<u16>>("version")?
.map_or(version, Option::Some);
let version_string = table.get("semver")?;
let ignore_updates = table
.get::<_, Option<bool>>("ignoreWagoUpdate")?
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载