Skip to content

Commit

Permalink
feat: Misc Changes from Mozilla Services
Browse files Browse the repository at this point in the history
Most changes have been captured in this PR, however some might have been missed if so please open a new PR and I'll review ASAP

Co-authored-by: Mark Drobnak <mdrobnak@mozilla.com>
Co-authored-by: Julius de Bruijn <bruijn@prisma.io>
Co-authored-by: Julius de Bruijn <julius+github@nauk.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rich Neswold <neswold@fnal.gov>
Co-authored-by: Alex Hortopan <alex@hortopan.com>
Co-authored-by: Harry Bairstow <h.bairstow22@gmail.com>
Co-authored-by: Austin Evans <austinjevans@me.com>
Co-authored-by: Harry Bairstow <me@harryet.xyz>
  • Loading branch information
10 people committed Dec 22, 2022
1 parent e975867 commit c08f146
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/certificate_client.rs
Expand Up @@ -54,7 +54,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let client = new_client()?;

let options = NotificationOptions {
apns_topic: topic.as_ref().map(|s| &**s),
apns_topic: topic.as_deref(),
..Default::default()
};

Expand Down
2 changes: 1 addition & 1 deletion examples/token_client.rs
Expand Up @@ -51,7 +51,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let client = Client::token(&mut private_key, key_id, team_id, endpoint).unwrap();

let options = NotificationOptions {
apns_topic: topic.as_ref().map(|s| &**s),
apns_topic: topic.as_deref(),
..Default::default()
};

Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Expand Up @@ -149,7 +149,7 @@ impl Client {
builder = builder.header("apns-expiration", apns_expiration.to_string().as_bytes());
}
if let Some(ref apns_collapse_id) = payload.options.apns_collapse_id {
builder = builder.header("apns-collapse-id", apns_collapse_id.value.to_string().as_bytes());
builder = builder.header("apns-collapse-id", apns_collapse_id.value.as_bytes());
}
if let Some(apns_topic) = payload.options.apns_topic {
builder = builder.header("apns-topic", apns_topic.as_bytes());
Expand Down
3 changes: 1 addition & 2 deletions src/error.rs
@@ -1,5 +1,4 @@
//! Error and result module

///! Error and result module
use crate::{response::Response, signer::SignerError};
use std::io;
use thiserror::Error;
Expand Down
3 changes: 1 addition & 2 deletions src/request/notification.rs
@@ -1,5 +1,4 @@
//! The `aps` notification content builders

///! The `aps` notification content builders
mod default;
mod options;
mod web;
Expand Down
2 changes: 1 addition & 1 deletion src/request/notification/default.rs
Expand Up @@ -3,7 +3,7 @@ use crate::request::payload::{APSAlert, Payload, APS};

use std::{borrow::Cow, collections::BTreeMap};

#[derive(Serialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct DefaultAlert<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
2 changes: 1 addition & 1 deletion src/request/notification/options.rs
Expand Up @@ -20,7 +20,7 @@ impl<'a> CollapseId<'a> {
}

/// Headers to specify options to the notification.
#[derive(Debug, Clone, Default)]
#[derive(Debug, Default, Clone)]
pub struct NotificationOptions<'a> {
/// A canonical UUID that identifies the notification. If there is an error
/// sending the notification, APNs uses this value to identify the
Expand Down
4 changes: 2 additions & 2 deletions src/request/notification/web.rs
Expand Up @@ -2,7 +2,7 @@ use crate::request::notification::{NotificationBuilder, NotificationOptions};
use crate::request::payload::{APSAlert, Payload, APS};
use std::collections::BTreeMap;

#[derive(Serialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct WebPushAlert<'a> {
pub title: &'a str,
Expand Down Expand Up @@ -104,7 +104,7 @@ mod tests {
title: "Hello",
body: "world",
},
&vec!["arg1"],
&["arg1"],
)
.build("device-token", Default::default())
.to_json_string()
Expand Down
5 changes: 2 additions & 3 deletions src/request/payload.rs
@@ -1,5 +1,4 @@
//! Payload with `aps` and custom data

///! Payload with `aps` and custom data
use crate::error::Error;
use crate::request::notification::{DefaultAlert, NotificationOptions, WebPushAlert};
use erased_serde::Serialize;
Expand Down Expand Up @@ -91,7 +90,7 @@ impl<'a> Payload<'a> {
}

/// The pre-defined notification data.
#[derive(Serialize, Debug, Clone)]
#[derive(Serialize, Default, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
#[allow(clippy::upper_case_acronyms)]
pub struct APS<'a> {
Expand Down

0 comments on commit c08f146

Please sign in to comment.