Skip to content

Commit 2e07180

Browse files
authored
Merge pull request #131 from dscottboggs/fix/notification-dismiss-route
Fix: notification dismiss route
2 parents b0b620f + f22ee6a commit 2e07180

File tree

11 files changed

+24
-37
lines changed

11 files changed

+24
-37
lines changed

.github/workflows/rust.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- uses: swatinem/rust-cache@v2
4040
- uses: dtolnay/rust-toolchain@master
4141
with:
42-
toolchain: 1.65.0
42+
toolchain: 1.67.0
4343
components: clippy
4444
- run: cargo clippy --all-features -- -D warnings
4545

@@ -51,7 +51,7 @@ jobs:
5151
- uses: swatinem/rust-cache@v2
5252
- uses: dtolnay/rust-toolchain@master
5353
with:
54-
toolchain: 1.65.0
54+
toolchain: 1.67.0
5555
components: rustfmt
5656
- run: cargo fmt --check
5757

entities/src/visibility.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde::Deserialize;
33
use serde::Serialize;
44

55
/// The visibility of a status.
6-
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq, is_enum_variant)]
6+
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq, is_enum_variant)]
77
#[serde(rename_all = "lowercase")]
88
pub enum Visibility {
99
/// A Direct message to a user
@@ -13,15 +13,10 @@ pub enum Visibility {
1313
/// Not shown in public timelines
1414
Unlisted,
1515
/// Posted to public timelines
16+
#[default]
1617
Public,
1718
}
1819

19-
impl Default for Visibility {
20-
fn default() -> Self {
21-
Visibility::Public
22-
}
23-
}
24-
2520
impl std::str::FromStr for Visibility {
2621
type Err = crate::error::Error;
2722

examples/log_events.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ async fn run() -> Result<()> {
1616
info!("watching mastodon for events. This will run forever, press Ctrl+C to kill the program.");
1717
stream
1818
.try_for_each(|(event, _client)| async move {
19-
match event {
20-
// fill in how you want to handle events here.
21-
_ => warn!(event = as_serde!(event); "unrecognized event received"),
22-
}
19+
warn!(event = as_serde!(event); "unrecognized event received");
2320
Ok(())
2421
})
2522
.await?;

src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub struct ApiError {
119119

120120
impl fmt::Display for ApiError {
121121
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
122-
write!(f, "{:?}", self)
122+
write!(f, "{self:?}")
123123
}
124124
}
125125

src/event_stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ pub(crate) fn make_event(lines: &[String]) -> Result<Event> {
8383
Event::Delete(data)
8484
}
8585
"filters_changed" => Event::FiltersChanged,
86-
_ => return Err(Error::Other(format!("Unknown event `{}`", event))),
86+
_ => return Err(Error::Other(format!("Unknown event `{event}`"))),
8787
})
8888
}

src/helpers/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub async fn authenticate(registration: Registered) -> Result<Mastodon> {
1414
let mut stdout = stdout.lock();
1515
let mut stdin = stdin.lock();
1616

17-
writeln!(&mut stdout, "Click this link to authorize: {}", url)?;
17+
writeln!(&mut stdout, "Click this link to authorize: {url}")?;
1818
write!(&mut stdout, "Paste the returned authorization code: ")?;
1919
stdout.flush()?;
2020

src/helpers/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mod tests {
5050

5151
#[test]
5252
fn test_from_env_no_prefix() {
53-
let desered = withenv(None, || from_env()).expect("Couldn't deser");
53+
let desered = withenv(None, from_env).expect("Couldn't deser");
5454
assert_eq!(
5555
desered,
5656
Data {

src/helpers/json.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mod tests {
7979
use std::{fs::OpenOptions, io::Cursor};
8080
use tempfile::{tempdir, NamedTempFile};
8181

82-
const DOC: &'static str = indoc!(
82+
const DOC: &str = indoc!(
8383
r#"
8484
{
8585
"base": "https://example.com",
@@ -108,7 +108,7 @@ mod tests {
108108
#[test]
109109
fn test_from_slice() {
110110
let doc = DOC.as_bytes();
111-
let desered = from_slice(&doc).expect("Couldn't deserialize Data");
111+
let desered = from_slice(doc).expect("Couldn't deserialize Data");
112112
assert_eq!(
113113
desered,
114114
Data {

src/helpers/toml.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mod tests {
7979
use std::{fs::OpenOptions, io::Cursor};
8080
use tempfile::{tempdir, NamedTempFile};
8181

82-
const DOC: &'static str = indoc!(
82+
const DOC: &str = indoc!(
8383
r#"
8484
base = "https://example.com"
8585
client_id = "adbc01234"
@@ -106,7 +106,7 @@ mod tests {
106106
#[test]
107107
fn test_from_slice() {
108108
let doc = DOC.as_bytes();
109-
let desered = from_slice(&doc).expect("Couldn't deserialize Data");
109+
let desered = from_slice(doc).expect("Couldn't deserialize Data");
110110
assert_eq!(
111111
desered,
112112
Data {

src/mastodon.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ impl Mastodon {
8787
(get (local: bool,)) get_public_timeline: "timelines/public" => Vec<Status>,
8888
(post (uri: Cow<'static, str>,)) follows: "follows" => Account,
8989
(post) clear_notifications: "notifications/clear" => Empty,
90-
(post (id: &str,)) dismiss_notification: "notifications/dismiss" => Empty,
9190
(get) get_push_subscription: "push/subscription" => Subscription,
9291
(delete) delete_push_subscription: "push/subscription" => Empty,
9392
(get) get_filters: "filters" => Vec<Filter>,
@@ -109,6 +108,7 @@ impl Mastodon {
109108
(get) mute[AccountId]: "accounts/{}/mute" => Relationship,
110109
(get) unmute[AccountId]: "accounts/{}/unmute" => Relationship,
111110
(get) get_notification[NotificationId]: "notifications/{}" => Notification,
111+
(post) dismiss_notification[NotificationId]: "notifications/{}/dismiss" => Empty,
112112
(get) get_status[StatusId]: "statuses/{}" => Status,
113113
(get) get_context[StatusId]: "statuses/{}/context" => Context,
114114
(get) get_card[StatusId]: "statuses/{}/card" => Card,
@@ -171,7 +171,7 @@ impl Mastodon {
171171

172172
/// PUT /api/v1/filters/:id
173173
pub async fn update_filter(&self, id: &str, request: &mut AddFilterRequest) -> Result<Filter> {
174-
let url = self.route(format!("/api/v1/filters/{}", id));
174+
let url = self.route(format!("/api/v1/filters/{id}"));
175175
let response = self.client.put(&url).json(&request).send().await?;
176176

177177
read_response(response).await
@@ -207,9 +207,9 @@ impl Mastodon {
207207
pub async fn get_tagged_timeline(&self, hashtag: String, local: bool) -> Result<Vec<Status>> {
208208
let base = "/api/v1/timelines/tag/";
209209
let url = if local {
210-
self.route(format!("{}{}?local=1", base, hashtag))
210+
self.route(format!("{base}{hashtag}?local=1"))
211211
} else {
212-
self.route(format!("{}{}", base, hashtag))
212+
self.route(format!("{base}{hashtag}"))
213213
};
214214

215215
self.get(url).await

src/scopes.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Serialize for Scopes {
5050
where
5151
S: Serializer,
5252
{
53-
let repr = format!("{}", self);
53+
let repr = format!("{self}");
5454
serializer.serialize_str(&repr)
5555
}
5656
}
@@ -178,12 +178,7 @@ impl Scopes {
178178
/// let read_write = read.and(write);
179179
/// ```
180180
pub fn and(self, other: Scopes) -> Scopes {
181-
let new_set: HashSet<_> = self
182-
.scopes
183-
.union(&other.scopes)
184-
.into_iter()
185-
.copied()
186-
.collect();
181+
let new_set: HashSet<_> = self.scopes.union(&other.scopes).copied().collect();
187182
Scopes { scopes: new_set }
188183
}
189184

@@ -342,7 +337,7 @@ impl fmt::Display for Scope {
342337
Follow => "follow",
343338
Push => "push",
344339
};
345-
write!(f, "{}", s)
340+
write!(f, "{s}")
346341
}
347342
}
348343

@@ -419,8 +414,8 @@ impl PartialOrd for Read {
419414

420415
impl Ord for Read {
421416
fn cmp(&self, other: &Read) -> Ordering {
422-
let a = format!("{:?}", self);
423-
let b = format!("{:?}", other);
417+
let a = format!("{self:?}");
418+
let b = format!("{other:?}");
424419
a.cmp(&b)
425420
}
426421
}
@@ -514,8 +509,8 @@ impl PartialOrd for Write {
514509

515510
impl Ord for Write {
516511
fn cmp(&self, other: &Write) -> Ordering {
517-
let a = format!("{:?}", self);
518-
let b = format!("{:?}", other);
512+
let a = format!("{self:?}");
513+
let b = format!("{other:?}");
519514
a.cmp(&b)
520515
}
521516
}

0 commit comments

Comments
 (0)