From 8c6b8e87f5da11e725b0fbf70e248e73a314a6b1 Mon Sep 17 00:00:00 2001 From: Daniel Sockwell Date: Thu, 19 Mar 2020 19:40:01 -0400 Subject: [PATCH] Remove language filter from home timeline (#97) Previously, the language filter was incorrectly applied to all `update` messages. With this change, it is only applied to public timelines (i.e., the local timeline and the federated timeline) which is the behavior described in the docs. --- src/redis_to_client_stream/client_agent.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/redis_to_client_stream/client_agent.rs b/src/redis_to_client_stream/client_agent.rs index ee1fe4f..ae81e09 100644 --- a/src/redis_to_client_stream/client_agent.rs +++ b/src/redis_to_client_stream/client_agent.rs @@ -18,7 +18,7 @@ use super::{message::Message, receiver::Receiver}; use crate::{ config, - parse_client_request::user::{PgPool, Subscription}, + parse_client_request::user::{PgPool, Stream::Public, Subscription, Timeline}, }; use futures::{ Async::{self, NotReady, Ready}, @@ -34,7 +34,6 @@ use uuid::Uuid; pub struct ClientAgent { receiver: sync::Arc>, id: uuid::Uuid, - // pub current_timeline: String, subscription: Subscription, } @@ -108,13 +107,15 @@ impl futures::stream::Stream for ClientAgent { use Message::*; match result { Ok(Async::Ready(Some(json))) => match Message::from_json(json) { - Update(status) if status.language_not_allowed(allowed_langs) => block, - Update(status) if status.involves_blocked_user(blocked_users) => block, - Update(status) if status.from_blocked_domain(blocked_domains) => block, - Update(status) if status.from_blocking_user(blocking_users) => block, - Update(status) => send(Update(status)), - Notification(notification) => send(Notification(notification)), - Conversation(notification) => send(Conversation(notification)), + Update(status) => match self.subscription.timeline { + _ if status.involves_blocked_user(blocked_users) => block, + _ if status.from_blocked_domain(blocked_domains) => block, + _ if status.from_blocking_user(blocking_users) => block, + Timeline(Public, _, _) if status.language_not_allowed(allowed_langs) => block, + _ => send(Update(status)), + }, + Notification(payload) => send(Notification(payload)), + Conversation(payload) => send(Conversation(payload)), Delete(status_id) => send(Delete(status_id)), FiltersChanged => send(FiltersChanged), Announcement(content) => send(Announcement(content)),