feat(daemon): expose watching over the RPC surface and the CLI
The watch subscription was reachable only from the library. It is most useful against a daemon -- that is the session that stays connected long enough to receive the server's status pushes -- so it needs the wire. - proto: user.watch / user.unwatch / user.watched, with a Watched response - SessionApi gains watch_user / unwatch_user / watched_users, so a local and a remote session are still interchangeable above the seam - CLI: `watch add`, `watch remove`, `watch list`, documented in SKILL.md including the caveat that a one-shot run's watch ends with the run - docs/openrpc.json regenerated from the wire types
This commit is contained in:
@@ -15,7 +15,7 @@ use crate::daemon::proto::{
|
||||
Members, MessageParams, Messages, Method, PROTOCOL_VERSION, QueryParams,
|
||||
Request, Response, RoomRef, RpcError, SayParams, SearchResults, Searches,
|
||||
Seconds, SharesStatus, SlotsParams, TransferRef, Uploads, UserRef,
|
||||
UserResult,
|
||||
UserResult, Watched,
|
||||
};
|
||||
use mirror::Mirror;
|
||||
use serde::de::DeserializeOwned;
|
||||
@@ -757,6 +757,30 @@ impl SessionApi for RemoteSession {
|
||||
)
|
||||
}
|
||||
|
||||
fn watch_user(&self, username: &str) -> Result<()> {
|
||||
self.tell(
|
||||
Method::UserWatch,
|
||||
UserRef {
|
||||
username: username.to_string(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn unwatch_user(&self, username: &str) -> Result<()> {
|
||||
self.tell(
|
||||
Method::UserUnwatch,
|
||||
UserRef {
|
||||
username: username.to_string(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn watched_users(&self) -> Vec<String> {
|
||||
self.request::<_, Watched>(Method::UserWatched, ())
|
||||
.map(|watched| watched.users)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn user_info(&self, username: &str) -> Option<UserInfo> {
|
||||
self.request::<_, UserResult>(
|
||||
Method::UserInfoOf,
|
||||
|
||||
Reference in New Issue
Block a user