Skip to content

Conversation

@jrconlin
Copy link
Member

Allow clients to define the minimum urgency of messages they wish to receive. For example, a client with low battery can request a high urgency message only until their battery is good again.

Note: this is a resubmit of
#815.

cc https://github.com/p1gp1g

Allow clients to define the minimum urgency of messages they wish to receive. For example, a client with low battery can request a high urgency message only until their battery is good again.

Note: this is a resubmit of
#815.
@p1gp1g
Copy link

p1gp1g commented Mar 20, 2025

Anything is blocking ?

@jrconlin
Copy link
Member Author

Yes, there was a minor conflict in Cargo.toml. Just resolved it.

We're a little thin right now, so getting review time is a challenge. I'll poke the other two again to see if they've got time.

@wrenix
Copy link

wrenix commented Apr 28, 2025

Forgetten? Could you take another look for a timeslot?

Copy link
Member Author

@jrconlin jrconlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I am probably seeming like a stickler about it, but putting the urgency elements behind a non-default feature flag means that it's not supported, meaning that we do not need to have unit and integration tests for this since it's not part of the critical code path.

use autoconnect_settings::{AppState, Settings};
use autopush_common::{
db::User,
db::{Urgency, User},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fully isolated:

Suggested change
db::{Urgency, User},
#[cfg(feature = "urgency" )]
use autopush_common::Urgency;
use autopush_common::{
db::User,
notification::Notification,
util::{ms_since_epoch, user_agent::UserAgentInfo},
};

/// First time a user has connected "today"
pub emit_channel_metrics: bool,
/// Minimum urgency
pub min_urgency: Urgency,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub min_urgency: Urgency,
#[cfg(feature = "urgency")]
pub min_urgency: Urgency,

check_storage: false,
old_record_version: false,
emit_channel_metrics: false,
min_urgency: Urgency::VeryLow,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
min_urgency: Urgency::VeryLow,
#[cfg(feature = "urgency")]
min_urgency: Urgency::VeryLow,

use crate::error::{SMError, SMErrorKind};
use crate::{
error::{SMError, SMErrorKind},
identified::Urgency,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[cfg(feature = "urgency")]
use crate::identified::Urgency;

messages.retain(|msg| {
if !msg.expired(now_sec) {
return true;
if let Some(headers) = msg.headers.as_ref() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

               #[cfg(feature = "urgency")]
               if let Some(headers) = msg.headers.as_ref() {
                    return Urgency::from(headers.get("urgency")) >= self.flags.min_urgency;
                } else {
                    return true;
                }
            }
           #[cfg(not(feature="urgency"))]
           return true;

use autoconnect_settings::{AppState, Settings};
use autopush_common::{
db::{User, USER_RECORD_VERSION},
db::{Urgency, User, USER_RECORD_VERSION},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[cfg(feature = "urgency")]
use autopush_common::db::Urgency
use autopush_common::{
    db::{User, USER_RECORD_VERSION},

.record_version
.is_none_or(|rec_ver| rec_ver < USER_RECORD_VERSION),
emit_channel_metrics: user.connected_at < ms_utc_midnight(),
min_urgency: user.urgency.unwrap_or(Urgency::VeryLow),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
min_urgency: user.urgency.unwrap_or(Urgency::VeryLow),
#[cfg(feature = "urgency")]
min_urgency: user.urgency.unwrap_or(Urgency::VeryLow),

use std::cmp::min;
use std::collections::HashMap;
use validator::Validate;
use validator::{Validate, ValidationError};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, we want to isolate the urgency stuff to a feature flag, so the bits that are urgency based need to be behind that flag.

@wrenix
Copy link

wrenix commented Jun 5, 2025

Thank for the work on this feature.

PS: I believe it is not mergeable since reliable_report with #778 and #826 (on v1.74.0) is merged.

So please rebase.

EDIT/PSS: Sorry i believe i mix it up with #813

@wrenix
Copy link

wrenix commented Aug 8, 2025

Sorry that i am so annoying. Is there anything blocking? Could i somewhere help to get this over the finish line?

Is there any reason why this is not merged?

@jrconlin
Copy link
Member Author

jrconlin commented Aug 8, 2025

Well, currently, one of the biggest blockers is probably just me. Mostly because I've got a few higher priority things I am working on that I really need to get resolved. (I'm very close to doing that, and yes, I'm also very frustrated that I'm not able to get them finished, but complex systems are complex and there are blockers outside of my control).

Once those things are done, I can look at the conflicts and try to resolve them (or you can, I don't expect any other conflicts), and after that's done I can merge, tag, and hopefully release shortly afterward.

@jrconlin
Copy link
Member Author

Hmm, so circling back on this and it looks like the redis library changed how it recommends async connections, which will require redoing some of the reliability stuff as well.
This might take a bit.

@wrenix
Copy link

wrenix commented Aug 12, 2025

Thank you for this feedback.

@jrconlin jrconlin marked this pull request as draft August 12, 2025 23:33
@jrconlin
Copy link
Member Author

Ok, so took a swing at merging and updating a few things to get this up. I'm going to convert to a draft because I'm not sure that I got things right, and I'd like to have some testing as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants