aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreta <hi@theta.eu.org>2019-10-05 15:01:18 +0100
committereta <hi@theta.eu.org>2019-10-05 15:01:18 +0100
commit72c7799505034d7638b49301209582bf42c97935 (patch)
treeba7353fc36ac7c609ff49029ec59d6c0f1691794
parentd8b5e71fbdcea677b1fb89e274b868c97ba21481 (diff)
downloadsms-irc-72c7799505034d7638b49301209582bf42c97935.tar.gz
sms-irc-72c7799505034d7638b49301209582bf42c97935.tar.bz2
sms-irc-72c7799505034d7638b49301209582bf42c97935.zip
Use Unidecode library to handle non-Unicode nicks (0.2.0 bump)
- The version number was changed to 0.2.0, purely because rpm doesn't like '0.2.0-pre' and I got tired of switching it around. - We now use the Unidecode library to produce ASCII representations of non-ASCII names, making life easier for people with umlauts and such in their contact names.
-rw-r--r--Cargo.lock9
-rw-r--r--Cargo.toml3
-rw-r--r--src/util.rs2
-rw-r--r--src/whatsapp.rs2
4 files changed, 14 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8233e86..67283de 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1953,7 +1953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "sms-irc"
-version = "0.2.0-pre"
+version = "0.1.0"
dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1983,6 +1983,7 @@ dependencies = [
"tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unidecode 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"whatsappweb-eta 0.5.0-pre1 (git+https://git.theta.eu.org/whatsappweb-rs.git/)",
]
@@ -2466,6 +2467,11 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "unidecode"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "untrusted"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2882,6 +2888,7 @@ dependencies = [
"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
+"checksum unidecode 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "402bb19d8e03f1d1a7450e2bd613980869438e0666331be3e073089124aa1adc"
"checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f"
"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
"checksum utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba"
diff --git a/Cargo.toml b/Cargo.toml
index 59df1cf..2c02842 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
authors = ["eeeeeta <eeeeeta@users.noreply.github.com>"]
name = "sms-irc"
edition = "2018"
-version = "0.2.0-pre"
+version = "0.2.0"
description = "A WhatsApp/SMS to IRC bridge"
license = "AGPL-3.0"
@@ -32,6 +32,7 @@ tokio-signal = "0.2.7"
tokio-timer = "0.2"
toml = "0.5"
unicode-segmentation = "1.3"
+unidecode = "0.3"
[dependencies.chrono]
features = ["serde"]
diff --git a/src/util.rs b/src/util.rs
index 467c5e9..f2b33ba 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -63,6 +63,7 @@ pub fn un_normalize_address(addr: &str) -> Option<PduAddress> {
}
pub fn string_to_irc_chan(inp: &str) -> String {
let mut ret = String::new();
+ let inp = unidecode::unidecode(inp);
for ch in inp.chars() {
match ch {
'_' => ret.push('_'),
@@ -77,6 +78,7 @@ pub fn string_to_irc_chan(inp: &str) -> String {
}
pub fn string_to_irc_nick(inp: &str) -> String {
let mut ret = "S".to_string();
+ let inp = unidecode::unidecode(inp);
for ch in inp.chars() {
match ch {
'+' => ret.push('I'),
diff --git a/src/whatsapp.rs b/src/whatsapp.rs
index bc856a0..3f2da80 100644
--- a/src/whatsapp.rs
+++ b/src/whatsapp.rs
@@ -717,6 +717,8 @@ impl WhatsappManager {
(Recipient::NICKSRC_WA_NOTIFY, Recipient::NICKSRC_WA_CONTACT) => true,
// Allow users to update their address book names.
(Recipient::NICKSRC_WA_CONTACT, Recipient::NICKSRC_WA_CONTACT) => true,
+ // Update WA notify values as well.
+ (Recipient::NICKSRC_WA_NOTIFY, Recipient::NICKSRC_WA_NOTIFY) => true,
// Other changes are probably unwanted.
_ => false
};