Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Delay push notifications as we do with emails #11574

Closed
wants to merge 1 commit into from

Conversation

xfalcox
Copy link
Member

@xfalcox xfalcox commented Dec 23, 2020

@tgxworld What is your opinion here?

My problem is that while actively navigating Meta I get push notifications for replies I already read and replied.

Screenshot_20201223-183903.png

In my opinion, mirroring our email delay would solve this problem cheaply.

I could also check if the target post of a notifications was already read, but that depends on the notification type and it's expensive to query post_timings.

@tgxworld
Copy link
Contributor

Does this mean if a notification is created in Discourse, we might delay or not send out the push notification?

@xfalcox
Copy link
Member Author

xfalcox commented Dec 24, 2020

Does this mean if a notification is created in Discourse, we might delay or not send out the push notification?

The idea is that we delay it, and after the delay we check if the user wasn't on the site during the delay, which means he already saw the discourse notification and don't need a push one to go for the mobile device.

@tgxworld
Copy link
Contributor

Ah icic. This is a good change to have but I kind of wished we had some way to centralise the logic of sending out "external" notifications like push and emails.

@xfalcox
Copy link
Member Author

xfalcox commented Dec 28, 2020

Ah icic. This is a good change to have but I kind of wished we had some way to centralise the logic of sending out "external" notifications like push and emails.

Yes, that would be cool, but also a larger change.

@tgxworld
Copy link
Contributor

tgxworld commented Dec 28, 2020 via email

@eviltrout
Copy link
Contributor

I agree with @tgxworld - it is counter intuitive that the site setting refers to email when it's not.

@tgxworld tgxworld added Changes Requested ruby Pull requests that update Ruby code labels Feb 1, 2021
@SamSaffron
Copy link
Member

so sorry I am closing this, I think we got to do the bigger change here if we are going down this path.

Also we don't delay this one...

def push_notification(user, payload)
return if user.do_not_disturb?
if user.push_subscriptions.exists?
Jobs.enqueue(:send_push_notification, user_id: user.id, payload: payload)
end
if SiteSetting.allow_user_api_key_scopes.split("|").include?("push") && SiteSetting.allowed_user_api_push_urls.present?
clients = user.user_api_keys
.joins(:scopes)
.where("user_api_key_scopes.name IN ('push', 'notifications')")
.where("push_url IS NOT NULL AND push_url <> ''")
.where("position(push_url IN ?) > 0", SiteSetting.allowed_user_api_push_urls)
.where("revoked_at IS NULL")
.order(client_id: :asc)
.pluck(:client_id, :push_url)
if clients.length > 0
Jobs.enqueue(:push_notification, clients: clients, payload: payload, user_id: user.id)
end
end
end

We should be consistent here if we are making a change.

Maybe a push_notification_delay site setting. It would be a bit complex cause when it eventually pushed you have to double confirm the user did not already read it in the intervening time.

Probably worth a dev TODO so we can scope it out.

@SamSaffron SamSaffron closed this May 20, 2021
@xfalcox xfalcox deleted the delay-push-notifications branch December 22, 2022 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes Requested ruby Pull requests that update Ruby code
Development

Successfully merging this pull request may close these issues.

4 participants