Skip to content

Commit f70d9ff

Browse files
Death916casperstorm
authored andcommitted
feat: implement channel monitor
1 parent de2ea29 commit f70d9ff

18 files changed

Lines changed: 649 additions & 9 deletions

File tree

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,30 @@
2727
/docs/node_modules/
2828
/docs/.vitepress/cache/
2929
/docs/.vitepress/dist/
30+
31+
# Nix and Direnv
32+
.envrc
33+
.direnv/
34+
shell.nix
35+
36+
# Devenv
37+
.devenv*
38+
devenv.local.nix
39+
devenv.local.yaml
40+
41+
# direnv
42+
.direnv
43+
44+
# pre-commit
45+
.pre-commit-config.yaml
46+
47+
# Devenv
48+
.devenv*
49+
devenv.local.nix
50+
devenv.local.yaml
51+
52+
# direnv
53+
.direnv
54+
55+
# pre-commit
56+
.pre-commit-config.yaml

assets/fontello/config.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@
211211
"css": "eraser",
212212
"code": 61741,
213213
"src": "fontawesome"
214+
},
215+
{
216+
"uid": "757afacc32d82967975cbb3b45cfb41b",
217+
"css": "desktop",
218+
"code": 61704,
219+
"src": "fontawesome"
214220
}
215221
]
216-
}
222+
}

data/src/buffer.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ pub enum Internal {
4747
FileTransfers,
4848
Logs,
4949
Highlights,
50+
#[strum(serialize = "Channel Monitor")]
51+
ChannelMonitor,
5052
#[strum(serialize = "Channel Discovery")]
5153
ChannelDiscovery(Option<Server>),
5254
}
@@ -125,6 +127,7 @@ impl Internal {
125127
Self::FileTransfers,
126128
Self::Logs,
127129
Self::Highlights,
130+
Self::ChannelMonitor,
128131
Self::ChannelDiscovery(None),
129132
];
130133

@@ -133,6 +136,7 @@ impl Internal {
133136
Internal::FileTransfers => "file-transfers",
134137
Internal::Logs => "logs",
135138
Internal::Highlights => "highlights",
139+
Internal::ChannelMonitor => "channel-monitor",
136140
Internal::ChannelDiscovery(_) => "channel-discovery",
137141
}
138142
.to_string()
@@ -147,6 +151,9 @@ impl From<config::sidebar::InternalBuffer> for Internal {
147151
}
148152
config::sidebar::InternalBuffer::Logs => Self::Logs,
149153
config::sidebar::InternalBuffer::Highlights => Self::Highlights,
154+
config::sidebar::InternalBuffer::ChannelMonitor => {
155+
Self::ChannelMonitor
156+
}
150157
config::sidebar::InternalBuffer::ChannelDiscovery => {
151158
Self::ChannelDiscovery(None)
152159
}

data/src/config/sidebar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ pub enum OrderChannelsBy {
299299
pub enum InternalBuffer {
300300
FileTransfers,
301301
ChannelDiscovery,
302+
ChannelMonitor,
302303
Highlights,
303304
Logs,
304305
}

data/src/history.rs

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

5253
impl Kind {
@@ -112,6 +113,7 @@ impl Kind {
112113
}
113114
message::Target::Logs { .. } => None,
114115
message::Target::Highlights { .. } => None,
116+
message::Target::ChannelMonitor { .. } => None,
115117
}
116118
}
117119

@@ -131,6 +133,9 @@ impl Kind {
131133
Some(Kind::Highlights)
132134
}
133135
Buffer::Internal(buffer::Internal::FileTransfers) => None,
136+
Buffer::Internal(buffer::Internal::ChannelMonitor) => {
137+
Some(Kind::ChannelMonitor)
138+
}
134139
Buffer::Internal(buffer::Internal::ChannelDiscovery(_)) => None,
135140
}
136141
}
@@ -144,6 +149,7 @@ impl Kind {
144149
Kind::Query(server, _) => Some(server),
145150
Kind::Logs => None,
146151
Kind::Highlights => None,
152+
Kind::ChannelMonitor => None,
147153
}
148154
}
149155

@@ -154,6 +160,7 @@ impl Kind {
154160
Kind::Query(_, nick) => Some(Target::Query(nick.clone())),
155161
Kind::Logs => None,
156162
Kind::Highlights => None,
163+
Kind::ChannelMonitor => None,
157164
}
158165
}
159166
}
@@ -168,6 +175,7 @@ impl fmt::Display for Kind {
168175
Kind::Query(server, nick) => write!(f, "user {nick} on {server}"),
169176
Kind::Logs => write!(f, "logs"),
170177
Kind::Highlights => write!(f, "highlights"),
178+
Kind::ChannelMonitor => write!(f, "channel monitor"),
171179
}
172180
}
173181
}
@@ -186,6 +194,9 @@ impl From<Kind> for Buffer {
186194
}
187195
Kind::Logs => Buffer::Internal(buffer::Internal::Logs),
188196
Kind::Highlights => Buffer::Internal(buffer::Internal::Highlights),
197+
Kind::ChannelMonitor => {
198+
Buffer::Internal(buffer::Internal::ChannelMonitor)
199+
}
189200
}
190201
}
191202
}
@@ -398,6 +409,7 @@ async fn path(kind: &Kind) -> Result<PathBuf, Error> {
398409
}
399410
Kind::Logs => "logs".to_string(),
400411
Kind::Highlights => "highlights".to_string(),
412+
Kind::ChannelMonitor => "channel_monitor".to_string(),
401413
};
402414

403415
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
@@ -478,6 +478,14 @@ impl Manager {
478478
.collect()
479479
}
480480

481+
pub fn record_channel_monitor_message(
482+
&mut self,
483+
message: crate::Message,
484+
) -> Option<impl Future<Output = Message> + use<>> {
485+
self.data
486+
.add_message(history::Kind::ChannelMonitor, message, None)
487+
}
488+
481489
pub fn record_reaction(
482490
&mut self,
483491
server: &Server,
@@ -881,7 +889,8 @@ impl Manager {
881889
// Check if target is included/excluded.
882890
let target_ref = match &message.target {
883891
message::Target::Channel { channel, .. }
884-
| message::Target::Highlights { channel, .. } => {
892+
| message::Target::Highlights { channel, .. }
893+
| message::Target::ChannelMonitor { channel, .. } => {
885894
Some(channel.as_target_ref())
886895
}
887896

@@ -1150,6 +1159,10 @@ impl Manager {
11501159
}
11511160
| message::Target::Highlights {
11521161
channel, ..
1162+
}
1163+
| message::Target::ChannelMonitor {
1164+
channel,
1165+
..
11531166
} => Some(channel.as_target_ref()),
11541167

11551168
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
@@ -228,7 +228,7 @@ impl From<Encoded> for proto::Message {
228228
}
229229
}
230230

231-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
231+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
232232
pub enum Target {
233233
Server {
234234
source: Source,
@@ -249,6 +249,11 @@ pub enum Target {
249249
channel: target::Channel,
250250
source: Source,
251251
},
252+
ChannelMonitor {
253+
server: Server,
254+
channel: target::Channel,
255+
source: Source,
256+
},
252257
}
253258

254259
impl Target {
@@ -265,6 +270,7 @@ impl Target {
265270
Target::Query { .. } => None,
266271
Target::Logs { .. } => None,
267272
Target::Highlights { .. } => None,
273+
Target::ChannelMonitor { .. } => None,
268274
}
269275
}
270276

@@ -275,6 +281,7 @@ impl Target {
275281
Target::Query { source, .. } => source,
276282
Target::Logs { source } => source,
277283
Target::Highlights { source, .. } => source,
284+
Target::ChannelMonitor { source, .. } => source,
278285
}
279286
}
280287

@@ -285,6 +292,7 @@ impl Target {
285292
Target::Query { source, .. } => source,
286293
Target::Logs { source } => source,
287294
Target::Highlights { source, .. } => source,
295+
Target::ChannelMonitor { source, .. } => source,
288296
}
289297
}
290298

@@ -294,7 +302,8 @@ impl Target {
294302
Target::Query { query, .. } => Some(query.as_str()),
295303
Target::Server { .. }
296304
| Target::Logs { .. }
297-
| Target::Highlights { .. } => None,
305+
| Target::Highlights { .. }
306+
| Target::ChannelMonitor { .. } => None,
298307
}
299308
}
300309

@@ -304,7 +313,8 @@ impl Target {
304313
Target::Query { .. }
305314
| Target::Server { .. }
306315
| Target::Logs { .. }
307-
| Target::Highlights { .. } => None,
316+
| Target::Highlights { .. }
317+
| Target::ChannelMonitor { .. } => None,
308318
}
309319
}
310320
}
@@ -1061,6 +1071,13 @@ pub fn condense(
10611071
channel: channel.clone(),
10621072
source,
10631073
},
1074+
Target::ChannelMonitor {
1075+
server, channel, ..
1076+
} => Target::ChannelMonitor {
1077+
server: server.clone(),
1078+
channel: channel.clone(),
1079+
source,
1080+
},
10641081
};
10651082

10661083
let nick_associations = find_nickname_associations(messages);

0 commit comments

Comments
 (0)