summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Boggs <scott@tams.tech>2023-10-21 09:53:05 -0400
committerGitHub <noreply@github.com>2023-10-21 09:53:05 -0400
commit2e0718036756aadca281ab1fe4cb5845e673ea66 (patch)
tree0cd7cfb46a8b0d89adfe35647471c23bbe4d90ff
parentb0b620fe52c31f890fcd32da169cb42612b58d64 (diff)
parentf22ee6aed4b71a74f03f3af492dafa62f4218d28 (diff)
Merge pull request #131 from dscottboggs/fix/notification-dismiss-routev1.3.1
Fix: notification dismiss route
-rw-r--r--.github/workflows/rust.yml4
-rw-r--r--entities/src/visibility.rs9
-rw-r--r--examples/log_events.rs5
-rw-r--r--src/errors.rs2
-rw-r--r--src/event_stream.rs2
-rw-r--r--src/helpers/cli.rs2
-rw-r--r--src/helpers/env.rs2
-rw-r--r--src/helpers/json.rs4
-rw-r--r--src/helpers/toml.rs4
-rw-r--r--src/mastodon.rs8
-rw-r--r--src/scopes.rs19
11 files changed, 24 insertions, 37 deletions
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index e5f9399..db11e23 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -39,7 +39,7 @@ jobs:
- uses: swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@master
with:
- toolchain: 1.65.0
+ toolchain: 1.67.0
components: clippy
- run: cargo clippy --all-features -- -D warnings
@@ -51,7 +51,7 @@ jobs:
- uses: swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@master
with:
- toolchain: 1.65.0
+ toolchain: 1.67.0
components: rustfmt
- run: cargo fmt --check
diff --git a/entities/src/visibility.rs b/entities/src/visibility.rs
index d5e14c6..43d0afe 100644
--- a/entities/src/visibility.rs
+++ b/entities/src/visibility.rs
@@ -3,7 +3,7 @@ use serde::Deserialize;
use serde::Serialize;
/// The visibility of a status.
-#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq, is_enum_variant)]
+#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq, is_enum_variant)]
#[serde(rename_all = "lowercase")]
pub enum Visibility {
/// A Direct message to a user
@@ -13,15 +13,10 @@ pub enum Visibility {
/// Not shown in public timelines
Unlisted,
/// Posted to public timelines
+ #[default]
Public,
}
-impl Default for Visibility {
- fn default() -> Self {
- Visibility::Public
- }
-}
-
impl std::str::FromStr for Visibility {
type Err = crate::error::Error;
diff --git a/examples/log_events.rs b/examples/log_events.rs
index 8858f4d..cfac8d2 100644
--- a/examples/log_events.rs
+++ b/examples/log_events.rs
@@ -16,10 +16,7 @@ async fn run() -> Result<()> {
info!("watching mastodon for events. This will run forever, press Ctrl+C to kill the program.");
stream
.try_for_each(|(event, _client)| async move {
- match event {
- // fill in how you want to handle events here.
- _ => warn!(event = as_serde!(event); "unrecognized event received"),
- }
+ warn!(event = as_serde!(event); "unrecognized event received");
Ok(())
})
.await?;
diff --git a/src/errors.rs b/src/errors.rs
index 7d4b707..0c16d55 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -119,7 +119,7 @@ pub struct ApiError {
impl fmt::Display for ApiError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{:?}", self)
+ write!(f, "{self:?}")
}
}
diff --git a/src/event_stream.rs b/src/event_stream.rs
index d6cb7c0..42d762f 100644
--- a/src/event_stream.rs
+++ b/src/event_stream.rs
@@ -83,6 +83,6 @@ pub(crate) fn make_event(lines: &[String]) -> Result<Event> {
Event::Delete(data)
}
"filters_changed" => Event::FiltersChanged,
- _ => return Err(Error::Other(format!("Unknown event `{}`", event))),
+ _ => return Err(Error::Other(format!("Unknown event `{event}`"))),
})
}
diff --git a/src/helpers/cli.rs b/src/helpers/cli.rs
index b48d88f..fdd1583 100644
--- a/src/helpers/cli.rs
+++ b/src/helpers/cli.rs
@@ -14,7 +14,7 @@ pub async fn authenticate(registration: Registered) -> Result<Mastodon> {
let mut stdout = stdout.lock();
let mut stdin = stdin.lock();
- writeln!(&mut stdout, "Click this link to authorize: {}", url)?;
+ writeln!(&mut stdout, "Click this link to authorize: {url}")?;
write!(&mut stdout, "Paste the returned authorization code: ")?;
stdout.flush()?;
diff --git a/src/helpers/env.rs b/src/helpers/env.rs
index df44028..b13e5f0 100644
--- a/src/helpers/env.rs
+++ b/src/helpers/env.rs
@@ -50,7 +50,7 @@ mod tests {
#[test]
fn test_from_env_no_prefix() {
- let desered = withenv(None, || from_env()).expect("Couldn't deser");
+ let desered = withenv(None, from_env).expect("Couldn't deser");
assert_eq!(
desered,
Data {
diff --git a/src/helpers/json.rs b/src/helpers/json.rs
index 7bde457..ef7c6fd 100644
--- a/src/helpers/json.rs
+++ b/src/helpers/json.rs
@@ -79,7 +79,7 @@ mod tests {
use std::{fs::OpenOptions, io::Cursor};
use tempfile::{tempdir, NamedTempFile};
- const DOC: &'static str = indoc!(
+ const DOC: &str = indoc!(
r#"
{
"base": "https://example.com",
@@ -108,7 +108,7 @@ mod tests {
#[test]
fn test_from_slice() {
let doc = DOC.as_bytes();
- let desered = from_slice(&doc).expect("Couldn't deserialize Data");
+ let desered = from_slice(doc).expect("Couldn't deserialize Data");
assert_eq!(
desered,
Data {
diff --git a/src/helpers/toml.rs b/src/helpers/toml.rs
index abf2415..b3f4061 100644
--- a/src/helpers/toml.rs
+++ b/src/helpers/toml.rs
@@ -79,7 +79,7 @@ mod tests {
use std::{fs::OpenOptions, io::Cursor};
use tempfile::{tempdir, NamedTempFile};
- const DOC: &'static str = indoc!(
+ const DOC: &str = indoc!(
r#"
base = "https://example.com"
client_id = "adbc01234"
@@ -106,7 +106,7 @@ mod tests {
#[test]
fn test_from_slice() {
let doc = DOC.as_bytes();
- let desered = from_slice(&doc).expect("Couldn't deserialize Data");
+ let desered = from_slice(doc).expect("Couldn't deserialize Data");
assert_eq!(
desered,
Data {
diff --git a/src/mastodon.rs b/src/mastodon.rs
index 1d512a8..ee9e60d 100644
--- a/src/mastodon.rs
+++ b/src/mastodon.rs
@@ -87,7 +87,6 @@ impl Mastodon {
(get (local: bool,)) get_public_timeline: "timelines/public" => Vec<Status>,
(post (uri: Cow<'static, str>,)) follows: "follows" => Account,
(post) clear_notifications: "notifications/clear" => Empty,
- (post (id: &str,)) dismiss_notification: "notifications/dismiss" => Empty,
(get) get_push_subscription: "push/subscription" => Subscription,
(delete) delete_push_subscription: "push/subscription" => Empty,
(get) get_filters: "filters" => Vec<Filter>,
@@ -109,6 +108,7 @@ impl Mastodon {
(get) mute[AccountId]: "accounts/{}/mute" => Relationship,
(get) unmute[AccountId]: "accounts/{}/unmute" => Relationship,
(get) get_notification[NotificationId]: "notifications/{}" => Notification,
+ (post) dismiss_notification[NotificationId]: "notifications/{}/dismiss" => Empty,
(get) get_status[StatusId]: "statuses/{}" => Status,
(get) get_context[StatusId]: "statuses/{}/context" => Context,
(get) get_card[StatusId]: "statuses/{}/card" => Card,
@@ -171,7 +171,7 @@ impl Mastodon {
/// PUT /api/v1/filters/:id
pub async fn update_filter(&self, id: &str, request: &mut AddFilterRequest) -> Result<Filter> {
- let url = self.route(format!("/api/v1/filters/{}", id));
+ let url = self.route(format!("/api/v1/filters/{id}"));
let response = self.client.put(&url).json(&request).send().await?;
read_response(response).await
@@ -207,9 +207,9 @@ impl Mastodon {
pub async fn get_tagged_timeline(&self, hashtag: String, local: bool) -> Result<Vec<Status>> {
let base = "/api/v1/timelines/tag/";
let url = if local {
- self.route(format!("{}{}?local=1", base, hashtag))
+ self.route(format!("{base}{hashtag}?local=1"))
} else {
- self.route(format!("{}{}", base, hashtag))
+ self.route(format!("{base}{hashtag}"))
};
self.get(url).await
diff --git a/src/scopes.rs b/src/scopes.rs
index 4ae7620..c4b5fd8 100644
--- a/src/scopes.rs
+++ b/src/scopes.rs
@@ -50,7 +50,7 @@ impl Serialize for Scopes {
where
S: Serializer,
{
- let repr = format!("{}", self);
+ let repr = format!("{self}");
serializer.serialize_str(&repr)
}
}
@@ -178,12 +178,7 @@ impl Scopes {
/// let read_write = read.and(write);
/// ```
pub fn and(self, other: Scopes) -> Scopes {
- let new_set: HashSet<_> = self
- .scopes
- .union(&other.scopes)
- .into_iter()
- .copied()
- .collect();
+ let new_set: HashSet<_> = self.scopes.union(&other.scopes).copied().collect();
Scopes { scopes: new_set }
}
@@ -342,7 +337,7 @@ impl fmt::Display for Scope {
Follow => "follow",
Push => "push",
};
- write!(f, "{}", s)
+ write!(f, "{s}")
}
}
@@ -419,8 +414,8 @@ impl PartialOrd for Read {
impl Ord for Read {
fn cmp(&self, other: &Read) -> Ordering {
- let a = format!("{:?}", self);
- let b = format!("{:?}", other);
+ let a = format!("{self:?}");
+ let b = format!("{other:?}");
a.cmp(&b)
}
}
@@ -514,8 +509,8 @@ impl PartialOrd for Write {
impl Ord for Write {
fn cmp(&self, other: &Write) -> Ordering {
- let a = format!("{:?}", self);
- let b = format!("{:?}", other);
+ let a = format!("{self:?}");
+ let b = format!("{other:?}");
a.cmp(&b)
}
}