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

Add Deserialize impls, a new Client constructor, and some QoL features #49

Conversation

AzureMarker
Copy link
Contributor

  • Serde's Deserialize is implemented for APS and its sub-structs.
  • Added Client::certificate_parts for creating a client from the raw certificate and private key data.
  • Made the properties of LocalizedAlert public (and all fields optional), to make constructing notifications easier.
  • Implemented Default for some APS structs, to make constructing notifications easier.

@AzureMarker
Copy link
Contributor Author

@pimeys Can you look into merging these PRs? We currently have to rely on a fork.

@pimeys
Copy link
Contributor

pimeys commented Aug 10, 2020

Hey! Sorry for delay, I've been (and still will be) on vacation with only an old openbsd laptop with me. I can try to test and release a new version, but it might be complex...

#[serde(rename_all = "kebab-case")]
pub struct LocalizedAlert<'a> {
title: &'a str,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having these as public fields, we should utilize the builders as we do with notifications. The API to set optional fields directly is never that great, and will pollute the code with None if not needing to set the fields.

Could you add these as builders instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you utilize Default, it is pretty concise:

LocalizedAlert {
    title_loc_key: Some("SentTab.NoTabArrivingNotification.title"),
    loc_key: Some("SentTab.NoTabArrivingNotification.body"),
    ..Default::default()
}

The whole point of these structs are to map 1:1 to the JSON that APNS expects. It makes sense to at least make the fields public.

@@ -84,8 +87,8 @@ impl<'a> LocalizedNotificationBuilder<'a> {
{
LocalizedNotificationBuilder {
alert: LocalizedAlert {
title: title,
body: body,
title: Some(title),
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these actually optional fields? If so, they should be separate builder methods...

/// Create a connection to APNs using the raw PEM-formatted certificate and
/// key, extracted from the provider client certificate you obtain from your
/// [Apple developer account](https://developer.apple.com/account/).
pub fn certificate_parts(cert: &[u8], key: &[u8], endpoint: Endpoint) -> Result<Client, Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could the cert and key be impl Read instead, allowing one to load them directly from files? &[u8] should also implement Read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AlpnConnector::with_client_cert takes in &[u8] so we don't benefit from using impl Read here.

@pimeys
Copy link
Contributor

pimeys commented Aug 12, 2020

So... I'll be back to Berlin to my work computer on 26.8. I don't have a good enough computer to review and test this. Could some other long-time a2 user like @dbrgn maybe see if this makes sense?

@AzureMarker
Copy link
Contributor Author

@pimeys Are you still interested in these changes?

@jrconlin
Copy link
Contributor

jrconlin commented Dec 7, 2020

Is this PR blocked? I see that there are changes requested, are those still valid?

jrconlin added a commit to mozilla-services/autopush-rs that referenced this pull request Dec 7, 2020
There has been no action on reown-com/a2#49 since
Aug 12 2020. Using a moz controlled branch for now.

Closes #236
jrconlin added a commit to mozilla-services/autopush-rs that referenced this pull request Dec 15, 2020
* chore: move a2 under mozilla-services

There has been no action on reown-com/a2#49 since
Aug 12 2020. Using a moz controlled branch for now.

Closes #236
@pimeys
Copy link
Contributor

pimeys commented Dec 22, 2020

As you probably noticed, I'm quite busy currently and not really having time on older crates that I'm not working with anymore. Sorry about that. I'm still not convinced we should make the fields of the struct public. And also not using this crate anymore, but I know there are active users such as @dbrgn, who'd be much better saying should we change the API or not.

@dbrgn
Copy link
Contributor

dbrgn commented Dec 22, 2020

I haven't touched the codebase that uses a2 in a while. I may be able to take a look in early January (I made a note for that), but at the moment I'm quite busy as well 🙂

@pimeys
Copy link
Contributor

pimeys commented Dec 22, 2020

Haha, no worries! Like, also first vacation for me in ages. I'm a bit worried merging and touching a codebase I'm not actively using anymore, especially when it changes a public-facing api...

@dbrgn
Copy link
Contributor

dbrgn commented Dec 22, 2020

Yeah, and I'm wary of updating dependencies on a service that's been running perfectly fine for months 😅

However, I should be able to judge the API changes independently from that (this PR only changes the API, not how network events are handled or anything like that).

@pimeys
Copy link
Contributor

pimeys commented Dec 22, 2020

What, you aren't excited about upgrading to Tokio 0.3 or 1.0 already?-)

Jokes aside, what would be cool to do here is what we did in Tiberius, make it runtime-independent. Although it's quite off-topic already... :D

@jrconlin
Copy link
Contributor

heh, well, first off, FOR THE LOVE OF WHATEVER YOU DEEM HOLY, PLEASE GO ENJOY YOUR BREAKS!

(Sorry, I do a lot of back end work and may be a bit triggered about seeing folks doing work when there's other, more enriching things to do.)

Next: Honestly, this gives me a lot more info to work with. We're using this library as part of our back-end service. We've already vendored a fork of it, so no worries about any blocks. Also totally fine if y'all treat this as semi-abandonware or archive it. I kinda had the feeling that was the case anyway.

In anycase, go, shoo, have a festive Yule, Happy Saturnalia, Merry Christmas, Joyous Hanukkah, reasonably OK Festivus or whatever else y'all want to have, and all the best in the New Year.

@pimeys
Copy link
Contributor

pimeys commented Dec 22, 2020

If you made a fork of it, what about taking the ownership of the whole crate?

@jrconlin
Copy link
Contributor

jrconlin commented Dec 22, 2020 via email

@pimeys
Copy link
Contributor

pimeys commented Dec 22, 2020

I mean, I doubt there will be that much of changes to a2, at least when tokio stabilizes finally.

We did the same thing as an organization to tiberius, basically rewrote it and negotiated with the original author to get access to the crates.io crate and make our fork the main one. I'd be willing to do the same for this and my fcm + web-push crates, if there'd be an interested community keeping them alive and moving.

@HarryET
Copy link
Contributor

HarryET commented Aug 15, 2022

👋🏼 The project has new maintainers now. I'm getting up-to speed with everything and trying to tidy up the PRs and Issues; are the changes here still relevant?

@jrconlin
Copy link
Contributor

@HarryET Welcome! (And thank you!)

Yes, these are still valid, in that we still use them in our fork and it might improve things for others.

@HarryET
Copy link
Contributor

HarryET commented Aug 15, 2022

Hey @jrconlin, thanks! Can you move the PR to point into v0.7 instead of master? and I'll get these reviewed asap.

@jrconlin
Copy link
Contributor

hrm... I don't have access to AsureMarker's account, so I can't post from that. I'll close this PR and open a new one from ours.

@HarryET
Copy link
Contributor

HarryET commented Aug 15, 2022

@jrconlin looks like I can switch it don't worry. But if it would be easier long term I can close this and work on a new PR with you?

@jrconlin
Copy link
Contributor

Yeah, I think it would.

Mark did this original work while he was an intern. He's now off to better things. The other repo has shared ownership.

@HarryET
Copy link
Contributor

HarryET commented Aug 15, 2022

Yeah, I think it would.

Mark did this original work while he was an intern. He's now off to better things. The other repo has shared ownership.

👌🏼 I'll close this out and will review a new PR once open

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.

5 participants