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

msgid Support #571

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Added:
- Ability to include or exclude channels for server messages (join, part, etc.). See [configuration](https://halloy.squidowl.org/configuration/buffer/server_messages/index.html).
- Ability to color nicknames within channel messages. See [configuration](https://halloy.squidowl.org/configuration/buffer/channel/message.html#nickname_color)
- Ability to define a shell command for loading a server password. See [configuration](https://halloy.squidowl.org/configuration/servers/index.html#password_command)
- Enable support for IRCv3 `msgid`

Fixed:

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Halloy is also available from [Flathub](https://flathub.org/apps/org.squidowl.ha
* [labeled-response](https://ircv3.net/specs/extensions/labeled-response)
* [message-tags](https://ircv3.net/specs/extensions/message-tags)
* [Monitor](https://ircv3.net/specs/extensions/monitor)
* [msgid](https://ircv3.net/specs/extensions/message-ids)
* [multi-prefix](https://ircv3.net/specs/extensions/multi-prefix)
* [sasl-3.1](https://ircv3.net/specs/extensions/sasl-3.1)
* [server-time](https://ircv3.net/specs/extensions/server-time)
Expand Down
1 change: 1 addition & 0 deletions book/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* [labeled-response](https://ircv3.net/specs/extensions/labeled-response)
* [message-tags](https://ircv3.net/specs/extensions/message-tags)
* [Monitor](https://ircv3.net/specs/extensions/monitor)
* [msgid](https://ircv3.net/specs/extensions/message-ids)
* [multi-prefix](https://ircv3.net/specs/extensions/multi-prefix)
* [sasl-3.1](https://ircv3.net/specs/extensions/sasl-3.1)
* [server-time](https://ircv3.net/specs/extensions/server-time)
Expand Down
2 changes: 2 additions & 0 deletions data/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl Input {
direction: message::Direction::Sent,
target,
content: message::parse_fragments(text.clone(), channel_users),
id: None,
})
.collect(),
),
Expand All @@ -105,6 +106,7 @@ impl Input {
direction: message::Direction::Sent,
target: to_target(&target, message::Source::Action)?,
content: message::action_text(user.nickname(), Some(&action)),
id: None,
}]),
_ => None,
}
Expand Down
16 changes: 16 additions & 0 deletions data/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub struct Message {
pub direction: Direction,
pub target: Target,
pub content: Content,
pub id: Option<String>,
}

impl Message {
Expand Down Expand Up @@ -175,6 +176,7 @@ impl Message {
channel_users: impl Fn(&str) -> &'a [User],
) -> Option<Message> {
let server_time = server_time(&encoded);
let id = message_id(&encoded);
let content = content(
&encoded,
&our_nick,
Expand All @@ -190,6 +192,7 @@ impl Message {
direction: Direction::Received,
target,
content,
id,
})
}

Expand All @@ -203,6 +206,7 @@ impl Message {
source: Source::Action,
},
content: plain(format!("{from} wants to send you \"{filename}\"")),
id: None,
}
}

Expand All @@ -216,6 +220,7 @@ impl Message {
source: Source::Action,
},
content: plain(format!("offering to send {to} \"{filename}\"")),
id: None,
}
}

Expand Down Expand Up @@ -276,6 +281,7 @@ impl<'de> Deserialize<'de> for Message {
content: Option<Content>,
// Old field before we had fragments
text: Option<String>,
id: Option<String>,
}

let Data {
Expand All @@ -285,6 +291,7 @@ impl<'de> Deserialize<'de> for Message {
target,
content,
text,
id,
} = Data::deserialize(deserializer)?;

let content = if let Some(content) = content {
Expand All @@ -303,6 +310,7 @@ impl<'de> Deserialize<'de> for Message {
direction,
target,
content,
id,
})
}
}
Expand Down Expand Up @@ -692,6 +700,14 @@ fn target(
}
}

pub fn message_id(message: &Encoded) -> Option<String> {
message
.tags
.iter()
.find(|tag| &tag.key == "msgid")
.and_then(|tag| tag.value.clone())
}

pub fn server_time(message: &Encoded) -> DateTime<Utc> {
message
.tags
Expand Down
1 change: 1 addition & 0 deletions data/src/message/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fn expand(
direction: Direction::Received,
target,
content,
id: None,
}
};

Expand Down
Loading