Skip to content

Commit

Permalink
Now doing outbound message filtering (much easier than anticipated)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaspianA1 committed Dec 31, 2024
1 parent 33429fc commit fa2ef3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/dashboard_defs/funky_remake_transitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn update_as_texture_with_funky_remake_transition(
rand_generator.gen_range(0.0..1.0) < intermediate_info.percent_chance_to_show_rand_intermediate_texture {

let random_path = pick_from_slice(&INTERMEDIATE_TRANSITION_TEXTURE_PATHS, rand_generator);
let intermediate_texture_creation_info = TextureCreationInfo::from_path(&random_path);
let intermediate_texture_creation_info = TextureCreationInfo::from_path(random_path);

let range = intermediate_info.rand_duration_range_for_intermediate;
let rand_duration_secs = rand_generator.gen_range(range.0..range.1);
Expand Down
14 changes: 8 additions & 6 deletions src/dashboard_defs/twilio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ struct TwilioStateData {

// Mutable fields:
curr_messages: SyncedMessageMap<MessageInfo>,
formatted_phone_number: String
unformatted_phone_number: String,
formatted_phone_number_with_title: String
}

// TODO: put the non-continually-updated fields in their own struct
Expand Down Expand Up @@ -242,7 +243,8 @@ impl TwilioStateData {
}),

curr_messages: SyncedMessageMap::new(max_num_messages_in_history),
formatted_phone_number: String::new()
unformatted_phone_number: String::new(),
formatted_phone_number_with_title: String::new()
};

////////// Finding the phone number
Expand All @@ -255,7 +257,8 @@ impl TwilioStateData {
assert!(phone_numbers.len() == 1);

let number = phone_numbers[0]["phone_number"].as_str().expect("Expected the phone number to be a string!");
data.formatted_phone_number = TwilioStateData::format_phone_number(number, "Messages to ", ":", "");
data.unformatted_phone_number = number.to_owned();
data.formatted_phone_number_with_title = TwilioStateData::format_phone_number(number, "Messages to ", ":", "");

//////////

Expand Down Expand Up @@ -347,10 +350,9 @@ impl Updatable for TwilioStateData {

let max_messages = self.immutable.max_num_messages_in_history;

/* TODO: re-request if not enough inbound messages were gotten. Filtering out outbound
messages will give you less messages than you requested if there are any outbound ones. */
let json = self.do_twilio_request("Messages", &[],
&[
("To", Cow::Borrowed(self.unformatted_phone_number.as_str())), // Adding this filters out all outbound messages
("PageSize", Cow::Borrowed(&max_messages.to_string())),
("DateSent%3E", Cow::Borrowed(&history_cutoff_day.to_string())) // Note: the '%3E' is a URL-encoded '>'
]
Expand Down Expand Up @@ -673,7 +675,7 @@ pub fn make_twilio_window(
Cow::Borrowed(inner_shared_state.font_info),

TextDisplayInfo {
text: DisplayText::new(&twilio_state.formatted_phone_number).with_padding(" ", ""),
text: DisplayText::new(&twilio_state.formatted_phone_number_with_title).with_padding(" ", ""),
color: text_color,
pixel_area: params.area_drawn_to_screen,
scroll_easer: easing_fns::scroll::STAY_PUT,
Expand Down

0 comments on commit fa2ef3e

Please sign in to comment.