Skip to content

Commit

Permalink
Fix: filter out blank block words. (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhzy0077 authored Jun 8, 2020
1 parent 26caf3d commit 853c450
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub type DbPool = r2d2::Pool<ConnectionManager<PgConnection>>;
pub type DbConnection = PooledConnection<ConnectionManager<PgConnection>>;
pub type AccessTokenCache = DashMap<i64, WeChatAccessToken>;
const HINT: &str =
"If you believe it's unexpected. Please help us by creating an issue with this response at https://github.com/zhzy0077/pipehub.";
"If you believe it's unexpected, please help us by creating an issue with this response at https://github.com/zhzy0077/pipehub.";

embed_migrations!("./migrations");

Expand Down
12 changes: 6 additions & 6 deletions server/src/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ pub async fn send(
return Err(Error::User("No message is provided.").into());
};

if tenant.block_list != ""
&& tenant
.block_list
.split(',')
.map(|word| word.trim())
.any(|block_word| text.contains(block_word))
if tenant
.block_list
.split(',')
.map(|word| word.trim())
.filter(|word| !word.is_empty())
.any(|block_word| text.contains(block_word))
{
return Err(Error::User("Message blocked.").into());
}
Expand Down

0 comments on commit 853c450

Please sign in to comment.