Skip to content

Commit 5c56534

Browse files
committed
feat: implement Channel Monitor
1 parent fd75a43 commit 5c56534

17 files changed

Lines changed: 615 additions & 8 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@
2727
/docs/node_modules/
2828
/docs/.vitepress/cache/
2929
/docs/.vitepress/dist/
30+
31+
# Nix and Direnv
32+
.envrc
33+
.direnv/
34+
shell.nix

assets/fontello/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@
289289
"css": "reply-1",
290290
"code": 59419,
291291
"src": "entypo"
292+
"uid": "757afacc32d82967975cbb3b45cfb41b",
293+
"css": "desktop",
294+
"code": 61704,
295+
"src": "fontawesome"
292296
}
293297
]
294298
}

data/src/buffer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub enum Internal {
3535
FileTransfers,
3636
Logs,
3737
Highlights,
38+
#[strum(serialize = "Channel Monitor")]
39+
ChannelMonitor,
3840
#[strum(serialize = "Channel Discovery")]
3941
ChannelDiscovery(Option<Server>),
4042
}
@@ -106,6 +108,7 @@ impl Internal {
106108
Self::FileTransfers,
107109
Self::Logs,
108110
Self::Highlights,
111+
Self::ChannelMonitor,
109112
Self::ChannelDiscovery(None),
110113
];
111114

@@ -114,6 +117,7 @@ impl Internal {
114117
Internal::FileTransfers => "file-transfers",
115118
Internal::Logs => "logs",
116119
Internal::Highlights => "highlights",
120+
Internal::ChannelMonitor => "channel-monitor",
117121
Internal::ChannelDiscovery(_) => "channel-discovery",
118122
}
119123
.to_string()

data/src/history.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub enum Kind {
4646
Query(Server, target::Query),
4747
Logs,
4848
Highlights,
49+
ChannelMonitor,
4950
}
5051

5152
impl Kind {
@@ -111,6 +112,7 @@ impl Kind {
111112
}
112113
message::Target::Logs { .. } => None,
113114
message::Target::Highlights { .. } => None,
115+
message::Target::ChannelMonitor { .. } => None,
114116
}
115117
}
116118

@@ -130,6 +132,9 @@ impl Kind {
130132
Some(Kind::Highlights)
131133
}
132134
Buffer::Internal(buffer::Internal::FileTransfers) => None,
135+
Buffer::Internal(buffer::Internal::ChannelMonitor) => {
136+
Some(Kind::ChannelMonitor)
137+
}
133138
Buffer::Internal(buffer::Internal::ChannelDiscovery(_)) => None,
134139
}
135140
}
@@ -143,6 +148,7 @@ impl Kind {
143148
Kind::Query(server, _) => Some(server),
144149
Kind::Logs => None,
145150
Kind::Highlights => None,
151+
Kind::ChannelMonitor => None,
146152
}
147153
}
148154

@@ -153,6 +159,7 @@ impl Kind {
153159
Kind::Query(_, nick) => Some(Target::Query(nick.clone())),
154160
Kind::Logs => None,
155161
Kind::Highlights => None,
162+
Kind::ChannelMonitor => None,
156163
}
157164
}
158165
}
@@ -167,6 +174,7 @@ impl fmt::Display for Kind {
167174
Kind::Query(server, nick) => write!(f, "user {nick} on {server}"),
168175
Kind::Logs => write!(f, "logs"),
169176
Kind::Highlights => write!(f, "highlights"),
177+
Kind::ChannelMonitor => write!(f, "channel monitor"),
170178
}
171179
}
172180
}
@@ -185,6 +193,9 @@ impl From<Kind> for Buffer {
185193
}
186194
Kind::Logs => Buffer::Internal(buffer::Internal::Logs),
187195
Kind::Highlights => Buffer::Internal(buffer::Internal::Highlights),
196+
Kind::ChannelMonitor => {
197+
Buffer::Internal(buffer::Internal::ChannelMonitor)
198+
}
188199
}
189200
}
190201
}
@@ -394,6 +405,7 @@ async fn path(kind: &Kind) -> Result<PathBuf, Error> {
394405
}
395406
Kind::Logs => "logs".to_string(),
396407
Kind::Highlights => "highlights".to_string(),
408+
Kind::ChannelMonitor => "channel_monitor".to_string(),
397409
};
398410

399411
let hashed_name = seahash::hash(name.as_bytes());

data/src/history/filter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ impl Filter {
287287
| Kind::Channel(server, _)
288288
| Kind::Query(server, _) => target_server == server,
289289
Kind::Highlights | Kind::Logs => false,
290+
Kind::ChannelMonitor => false,
290291
},
291292
}
292293
}

data/src/history/manager.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@ impl Manager {
473473
.collect()
474474
}
475475

476+
pub fn record_channel_monitor_message(
477+
&mut self,
478+
message: crate::Message,
479+
) -> Option<impl Future<Output = Message> + use<>> {
480+
self.data
481+
.add_message(history::Kind::ChannelMonitor, message, None)
482+
}
483+
476484
pub fn record_reaction(
477485
&mut self,
478486
server: &Server,
@@ -837,7 +845,8 @@ impl Manager {
837845
// Check if target is included/excluded.
838846
let target_ref = match &message.target {
839847
message::Target::Channel { channel, .. }
840-
| message::Target::Highlights { channel, .. } => {
848+
| message::Target::Highlights { channel, .. }
849+
| message::Target::ChannelMonitor { channel, .. } => {
841850
Some(channel.as_target_ref())
842851
}
843852

@@ -1106,6 +1115,10 @@ impl Manager {
11061115
}
11071116
| message::Target::Highlights {
11081117
channel, ..
1118+
}
1119+
| message::Target::ChannelMonitor {
1120+
channel,
1121+
..
11091122
} => Some(channel.as_target_ref()),
11101123

11111124
message::Target::Query { query, .. } => {

data/src/history/metadata.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ async fn path(kind: &Kind) -> Result<PathBuf, Error> {
219219
}
220220
Kind::Logs => "logs-metadata".to_string(),
221221
Kind::Highlights => "highlights-metadata".to_string(),
222+
Kind::ChannelMonitor => "channel-monitor-metadata".to_string(),
222223
};
223224

224225
let hashed_name = seahash::hash(name.as_bytes());

data/src/message.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl From<Encoded> for proto::Message {
209209
}
210210
}
211211

212-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
212+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
213213
pub enum Target {
214214
Server {
215215
source: Source,
@@ -230,6 +230,11 @@ pub enum Target {
230230
channel: target::Channel,
231231
source: Source,
232232
},
233+
ChannelMonitor {
234+
server: Server,
235+
channel: target::Channel,
236+
source: Source,
237+
},
233238
}
234239

235240
impl Target {
@@ -246,6 +251,7 @@ impl Target {
246251
Target::Query { .. } => None,
247252
Target::Logs { .. } => None,
248253
Target::Highlights { .. } => None,
254+
Target::ChannelMonitor { .. } => None,
249255
}
250256
}
251257

@@ -256,6 +262,7 @@ impl Target {
256262
Target::Query { source, .. } => source,
257263
Target::Logs { source } => source,
258264
Target::Highlights { source, .. } => source,
265+
Target::ChannelMonitor { source, .. } => source,
259266
}
260267
}
261268

@@ -266,6 +273,7 @@ impl Target {
266273
Target::Query { source, .. } => source,
267274
Target::Logs { source } => source,
268275
Target::Highlights { source, .. } => source,
276+
Target::ChannelMonitor { source, .. } => source,
269277
}
270278
}
271279

@@ -275,7 +283,8 @@ impl Target {
275283
Target::Query { query, .. } => Some(query.as_str()),
276284
Target::Server { .. }
277285
| Target::Logs { .. }
278-
| Target::Highlights { .. } => None,
286+
| Target::Highlights { .. }
287+
| Target::ChannelMonitor { .. } => None,
279288
}
280289
}
281290

@@ -285,7 +294,8 @@ impl Target {
285294
Target::Query { .. }
286295
| Target::Server { .. }
287296
| Target::Logs { .. }
288-
| Target::Highlights { .. } => None,
297+
| Target::Highlights { .. }
298+
| Target::ChannelMonitor { .. } => None,
289299
}
290300
}
291301
}
@@ -1009,6 +1019,13 @@ pub fn condense(
10091019
channel: channel.clone(),
10101020
source,
10111021
},
1022+
Target::ChannelMonitor {
1023+
server, channel, ..
1024+
} => Target::ChannelMonitor {
1025+
server: server.clone(),
1026+
channel: channel.clone(),
1027+
source,
1028+
},
10121029
};
10131030

10141031
let nick_associations = find_nickname_associations(messages);

0 commit comments

Comments
 (0)