Skip to content

Commit

Permalink
Merge pull request #571 from squidowl/feat/msgid
Browse files Browse the repository at this point in the history
`msgid` Support
  • Loading branch information
andymandias authored Sep 17, 2024
2 parents 44dd44a + 5069479 commit ad6ccf9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
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

0 comments on commit ad6ccf9

Please sign in to comment.