Skip to content

Commit

Permalink
invite-notify
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm committed Aug 3, 2023
1 parent a813268 commit 3f42b8d
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Unreleased

Added:

- IRCv3 capability `userhost-in-names` support added
- IRCv3 capability `invite-notify` support added

# 2023.4 (2023-08-03)

Added:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ cargo run --release

Halloy supports the following IRCv3.2 capabilities

- `away-notify`
- `batch`
- `server-time`
- `sasl=PLAIN,EXTERNAL`
- `labeled-response`
- `echo-message` (server must also support `labeled-response`)
| Capabilities |
|---------------------------------------------------------------------------|
| [away-notify](https://ircv3.net/specs/extensions/away-notify) |
| [batch](https://ircv3.net/specs/extensions/batch) |
| [server-time](https://ircv3.net/specs/extensions/server-time) |
| [labeled-response](https://ircv3.net/specs/extensions/labeled-response) |
| [echo-message](https://ircv3.net/specs/extensions/echo-message) |
| [invite-notify](https://ircv3.net/specs/extensions/invite-notify) |
| [userhost-in-names](https://ircv3.net/specs/extensions/userhost-in-names) |
| [sasl-3.1](https://ircv3.net/specs/extensions/sasl-3.1) |

## Why?
<div align="center">
Expand All @@ -66,10 +70,6 @@ Halloy supports the following IRCv3.2 capabilities

Halloy is released under the GPL-3.0 License. For more details, see the [LICENSE](LICENSE) file.

## Disclaimer

Halloy is still in the early stages of development. Bugs and incomplete features may be present. Use it at your own risk.

## Contact

For any questions, suggestions, or issues, please open an issue on the [GitHub repository](https://github.com/squidowl/halloy/issues).
22 changes: 22 additions & 0 deletions data/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ pub enum Brodcast {
ourself: bool,
channels: Vec<String>,
},
Invite {
inviter: User,
channel: String,
user_channels: Vec<String>,
},
}

#[derive(Debug)]
Expand Down Expand Up @@ -272,6 +277,12 @@ impl Client {

let contains = |s| self.listed_caps.iter().any(|cap| cap == s);

if contains("invite-notify") {
requested.push("invite-notify");
}
if contains("userhost-in-names") {
requested.push("userhost-in-names");
}
if contains("away-notify") {
requested.push("away-notify");
}
Expand Down Expand Up @@ -361,6 +372,17 @@ impl Client {
}
}
}
Command::INVITE(user, channel) => {
let user = User::from(Nick::from(user.as_str()));
let inviter = message.user()?;
let user_channels = self.user_channels(user.nickname());

return Some(vec![Event::Brodcast(Brodcast::Invite {
inviter,
channel: channel.clone(),
user_channels,
})]);
}
Command::NICK(nick) => {
let old_user = message.user()?;
let ourself = self.nickname() == old_user.nickname();
Expand Down
10 changes: 10 additions & 0 deletions data/src/history/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ impl Manager {
)
}
}
Broadcast::Invite {
inviter,
channel,
user_channels,
} => message::broadcast::invite(inviter, channel, user_channels),
};

messages.into_iter().for_each(|message| {
Expand Down Expand Up @@ -519,4 +524,9 @@ pub enum Broadcast {
ourself: bool,
user_channels: Vec<String>,
},
Invite {
inviter: Nick,
channel: String,
user_channels: Vec<String>,
},
}
10 changes: 10 additions & 0 deletions data/src/message/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,13 @@ pub fn nickname(

expand(channels, queries, false, Cause::Server(None), text)
}

pub fn invite(
inviter: Nick,
channel: String,
channels: impl IntoIterator<Item = String>,
) -> Vec<Message> {
let text = format!(" ∙ {inviter} invited you to join {channel}");

expand(channels, [], false, Cause::Server(None), text)
}
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,20 @@ impl Application for Halloy {
channels,
);
}
data::client::Brodcast::Invite {
inviter,
channel,
user_channels,
} => {
let inviter = inviter.nickname();

dashboard.broadcast_invite(
&server,
inviter.to_owned(),
channel,
user_channels,
);
}
},
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/screen/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,23 @@ impl Dashboard {
);
}

pub fn broadcast_invite(
&mut self,
server: &Server,
inviter: Nick,
channel: String,
user_channels: Vec<String>,
) {
self.history.broadcast(
server,
Broadcast::Invite {
inviter,
channel,
user_channels,
},
);
}

pub fn broadcast_connecting(&mut self, server: &Server) {
self.history.broadcast(server, Broadcast::Connecting);
}
Expand Down

0 comments on commit 3f42b8d

Please sign in to comment.